Refine two blocks in configure.ac such that each option correctly
handles both of the Autoconf-supplied values ("yes" and "no") and, when
the option is properly enabled, the message is easier to understand.
See also commit
9aca99a. While at it, use $withval more to unify the
code and squelch the following warnings from Autoconf 2.71:
configure.ac:188: warning: back quotes and double quotes must not be
escaped in: $as_me:${as_lineno-$LINENO}: result: to \"$withval\"
configure.ac:188: warning: back quotes and double quotes must not be
escaped in: to \"$withval\"
configure.ac:198: warning: back quotes and double quotes must not be
escaped in: $as_me:${as_lineno-$LINENO}: result: to \"$withval\"
configure.ac:198: warning: back quotes and double quotes must not be
escaped in: to \"$withval\"
User experience before:
./configure
checking whether to drop root privileges by default... no
checking whether to chroot... no
./configure --with-user=someuser --with-chroot=/some/dir/
checking whether to drop root privileges by default... to "someuser"
checking whether to chroot... to "/some/dir/"
./configure --without-user --without-chroot
checking whether to drop root privileges by default... to "no"
checking whether to chroot... no
./configure --with-user
checking whether to drop root privileges by default... to "yes"
./configure --with-chroot
checking whether to chroot... to "yes"
User experience after:
./configure
checking whether to drop root privileges by default... no
checking whether to chroot... no
./configure --with-user=someuser --with-chroot=/some/dir/
checking whether to drop root privileges by default... yes, to user
"someuser"
checking whether to chroot... yes, to directory "/some/dir/"
./configure --without-user --without-chroot
checking whether to drop root privileges by default... no
checking whether to chroot... no
./configure --with-user
configure: error: --with-user requires a username
./configure --with-chroot
configure: error: --with-chroot requires a directory
AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME])
AC_MSG_CHECKING([whether to drop root privileges by default])
-if test ! -z "$with_user" ; then
+if test ! -z "$withval" && test "$withval" != "no" ; then
+ if test "$withval" = "yes" ; then
+ AC_MSG_ERROR([--with-user requires a username])
+ fi
AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
[define if should drop privileges by default])
- AC_MSG_RESULT(to \"$withval\")
+ AC_MSG_RESULT([yes, to user "$withval"])
else
AC_MSG_RESULT(no)
fi
AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
AC_MSG_CHECKING([whether to chroot])
-if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then
+if test ! -z "$withval" && test "$withval" != "no" ; then
+ if test "$withval" = "yes" ; then
+ AC_MSG_ERROR([--with-chroot requires a directory])
+ fi
AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
[define if should chroot when dropping privileges])
- AC_MSG_RESULT(to \"$withval\")
+ AC_MSG_RESULT([yes, to directory "$withval"])
else
AC_MSG_RESULT(no)
fi