]> The Tcpdump Group git mirrors - tcpdump/blobdiff - configure.ac
Autoconf: Get --with-user and --with-chroot right. [skip appveyor]
[tcpdump] / configure.ac
index 21a0f701b05802fa78d0e2c08643562c60874dc4..1eed05a14277562946bf972eac1580e6ad571a3c 100644 (file)
@@ -153,31 +153,42 @@ yes)      AC_MSG_RESULT(yes)
        ;;
 esac
 
-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 "$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([yes, to user "$withval"])
-else
-       AC_MSG_RESULT(no)
-fi
+AC_ARG_WITH(
+       [user],
+       [AS_HELP_STRING([--with-user=USERNAME],
+               [drop privileges by default to USERNAME]
+       )],
+       [],
+       [withval=no])
+AS_CASE(["$withval"],
+       [no], [AC_MSG_RESULT(no)],
+       [''|yes], [AC_MSG_ERROR([--with-user requires a username])],
+       [
+               AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
+                   [define if should drop privileges by default])
+               AC_MSG_RESULT([yes, to user "$withval"])
+       ]
+)
 
-AC_ARG_WITH(chroot, [  --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
 AC_MSG_CHECKING([whether to chroot])
-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([yes, to directory "$withval"])
-else
-       AC_MSG_RESULT(no)
-fi
+AC_ARG_WITH(
+       [chroot],
+       [AS_HELP_STRING([--with-chroot=DIRECTORY],
+               [when dropping privileges, chroot to DIRECTORY]
+       )],
+       [],
+       [withval=no]
+)
+AS_CASE(["$withval"],
+       [no], [AC_MSG_RESULT(no)],
+       [''|yes], [AC_MSG_ERROR([--with-chroot requires a directory])],
+       [
+               AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
+                   [define if should chroot when dropping privileges])
+               AC_MSG_RESULT([yes, to directory "$withval"])
+       ]
+)
 
 AC_ARG_WITH(sandbox-capsicum,
        AS_HELP_STRING([--with-sandbox-capsicum],