From 97b60e3eb2929171f1b284247002431890244c06 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" <Todd.Miller@courtesan.com> Date: Wed, 13 Nov 2013 14:45:47 -0700 Subject: [PATCH] From Daniel Richard G. (bug #622) Add an autogen.sh script that rebuilds the autoconf world. Move old aclocal.m4 contents to m4/sudo.m4. New (generayed) aclocal.m4 contains the m4_include directives. Some tests had #include directives where the '#' was not in column 1. Updated obsolete macro usage via autoupdate. --- MANIFEST | 2 + aclocal.m4 | 518 ++++++++++++--------------------------------------- autogen.sh | 20 ++ config.h.in | 7 +- configure | 112 +++++++---- configure.in | 18 +- ltmain.sh | 0 m4/sudo.m4 | 395 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 626 insertions(+), 446 deletions(-) create mode 100755 autogen.sh mode change 100755 => 100644 ltmain.sh create mode 100644 m4/sudo.m4 diff --git a/MANIFEST b/MANIFEST index a41e67672..41372474f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -7,6 +7,7 @@ NEWS README README.LDAP aclocal.m4 +autogen.sh common/Makefile.in common/aix.c common/alloc.c @@ -161,6 +162,7 @@ m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 +m4/sudo.m4 mkdep.pl mkinstalldirs mkpkg diff --git a/aclocal.m4 b/aclocal.m4 index e87c85265..fe5f1629f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,408 +1,136 @@ -dnl Local m4 macros for autoconf (used by sudo) -dnl -dnl Copyright (c) 1994-1996, 1998-2005, 2007-2013 -dnl Todd C. Miller <Todd.Miller@courtesan.com> -dnl -dnl XXX - should cache values in all cases!!! -dnl -dnl checks for programs - -dnl -dnl check for sendmail in well-known locations -dnl -AC_DEFUN([SUDO_PROG_SENDMAIL], [AC_MSG_CHECKING([for sendmail]) -found=no -for p in "/usr/sbin/sendmail" "/usr/lib/sendmail" "/usr/etc/sendmail" "/usr/ucblib/sendmail" "/usr/local/lib/sendmail" "/usr/local/bin/sendmail"; do - if test -f "$p"; then - found=yes - AC_MSG_RESULT([$p]) - SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SENDMAIL, "$p") - break - fi -done -if test X"$found" != X"yes"; then - AC_MSG_RESULT([not found]) -fi -])dnl - -dnl -dnl check for vi in well-known locations -dnl -AC_DEFUN([SUDO_PROG_VI], [AC_MSG_CHECKING([for vi]) -found=no -for editor in "/usr/bin/vi" "/bin/vi" "/usr/ucb/vi" "/usr/bsd/vi" "/usr/local/bin/vi"; do - if test -f "$editor"; then - found=yes - AC_MSG_RESULT([$editor]) - SUDO_DEFINE_UNQUOTED(_PATH_VI, "$editor") - break - fi -done -if test X"$found" != X"yes"; then - AC_MSG_RESULT([not found]) -fi -])dnl - -dnl -dnl check for mv in well-known locations -dnl -AC_DEFUN([SUDO_PROG_MV], [AC_MSG_CHECKING([for mv]) -found=no -for p in "/usr/bin/mv" "/bin/mv" "/usr/ucb/mv" "/usr/sbin/mv"; do - if test -f "$p"; then - found=yes - AC_MSG_RESULT([$p]) - SUDO_DEFINE_UNQUOTED(_PATH_MV, "$p") - break - fi -done -if test X"$found" != X"yes"; then - AC_MSG_RESULT([not found]) -fi -])dnl - -dnl -dnl check for bourne shell in well-known locations -dnl -AC_DEFUN([SUDO_PROG_BSHELL], [AC_MSG_CHECKING([for bourne shell]) -found=no -for p in "/bin/sh" "/usr/bin/sh" "/sbin/sh" "/usr/sbin/sh" "/bin/ksh" "/usr/bin/ksh" "/bin/bash" "/usr/bin/bash"; do - if test -f "$p"; then - found=yes - AC_MSG_RESULT([$p]) - SUDO_DEFINE_UNQUOTED(_PATH_BSHELL, "$p") - break - fi -done -if test X"$found" != X"yes"; then - AC_MSG_RESULT([not found]) -fi -])dnl - -dnl -dnl check for utmp file -dnl -AC_DEFUN([SUDO_PATH_UTMP], [AC_MSG_CHECKING([for utmp file path]) -found=no -for p in "/var/run/utmp" "/var/adm/utmp" "/etc/utmp"; do - if test -r "$p"; then - found=yes - AC_MSG_RESULT([$p]) - SUDO_DEFINE_UNQUOTED(_PATH_UTMP, "$p") - break - fi -done -if test X"$found" != X"yes"; then - AC_MSG_RESULT([not found]) -fi -])dnl - -dnl -dnl Where the log file goes, use /var/log if it exists, else /{var,usr}/adm -dnl -AC_DEFUN([SUDO_LOGFILE], [AC_MSG_CHECKING(for log file location) -if test -n "$with_logpath"; then - AC_MSG_RESULT($with_logpath) - SUDO_DEFINE_UNQUOTED(_PATH_SUDO_LOGFILE, "$with_logpath") -elif test -d "/var/log"; then - AC_MSG_RESULT(/var/log/sudo.log) - SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/var/log/sudo.log") -elif test -d "/var/adm"; then - AC_MSG_RESULT(/var/adm/sudo.log) - SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/var/adm/sudo.log") -elif test -d "/usr/adm"; then - AC_MSG_RESULT(/usr/adm/sudo.log) - SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/usr/adm/sudo.log") -else - AC_MSG_RESULT(unknown, you will have to set _PATH_SUDO_LOGFILE by hand) -fi -])dnl - -dnl -dnl Where the timestamp files go. -dnl -AC_DEFUN([SUDO_TIMEDIR], [AC_MSG_CHECKING(for timestamp file location) -timedir="$with_timedir" -if test -z "$timedir"; then - for d in /var/db /var/lib /var/adm /usr/adm; do - if test -d "$d"; then - timedir="$d/sudo" - break - fi - done -fi -AC_MSG_RESULT([$timedir]) -SUDO_DEFINE_UNQUOTED(_PATH_SUDO_TIMEDIR, "$timedir") -])dnl - -dnl -dnl Where the I/O log files go, use /var/log/sudo-io if -dnl /var/log exists, else /{var,usr}/adm/sudo-io -dnl -AC_DEFUN([SUDO_IO_LOGDIR], [ - AC_MSG_CHECKING(for I/O log dir location) - if test "${with_iologdir-yes}" != "yes"; then - iolog_dir="$with_iologdir" - elif test -d "/var/log"; then - iolog_dir="/var/log/sudo-io" - elif test -d "/var/adm"; then - iolog_dir="/var/adm/sudo-io" - else - iolog_dir="/usr/adm/sudo-io" - fi - if test "${with_iologdir}" != "no"; then - SUDO_DEFINE_UNQUOTED(_PATH_SUDO_IO_LOGDIR, "$iolog_dir") - fi - AC_MSG_RESULT($iolog_dir) -])dnl - -dnl -dnl check for working fnmatch(3) -dnl -AC_DEFUN([SUDO_FUNC_FNMATCH], -[AC_MSG_CHECKING([for working fnmatch with FNM_CASEFOLD]) -AC_CACHE_VAL(sudo_cv_func_fnmatch, -[rm -f conftestdata; > conftestdata -AC_TRY_RUN([#include <fnmatch.h> -main() { exit(fnmatch("/*/bin/echo *", "/usr/bin/echo just a test", FNM_CASEFOLD)); }], [sudo_cv_func_fnmatch=yes], [sudo_cv_func_fnmatch=no], - [sudo_cv_func_fnmatch=no]) -rm -f core core.* *.core]) -AC_MSG_RESULT($sudo_cv_func_fnmatch) -AS_IF([test $sudo_cv_func_fnmatch = yes], [$1], [$2])]) - -dnl -dnl Attempt to check for working PIE support. -dnl This is a bit of a hack but on Solaris 10 with GNU ld and GNU as -dnl we can end up with strange values from malloc(). -dnl A better check would be to verify that ASLR works with PIE. -dnl -AC_DEFUN([SUDO_WORKING_PIE], -[AC_MSG_CHECKING([for working PIE support]) -AC_CACHE_VAL(sudo_cv_working_pie, -[rm -f conftestdata; > conftestdata -AC_TRY_RUN(AC_INCLUDES_DEFAULT([]) -[main() { char *p = malloc(1024); if (p == NULL) return 1; memset(p, 0, 1024); return 0; }], [sudo_cv_working_pie=yes], [sudo_cv_working_pie=no], - [sudo_cv_working_pie=no]) -rm -f core core.* *.core]) -AC_MSG_RESULT($sudo_cv_working_pie) -AS_IF([test $sudo_cv_working_pie = yes], [$1], [$2])]) - -dnl -dnl check for isblank(3) -dnl -AC_DEFUN([SUDO_FUNC_ISBLANK], - [AC_CACHE_CHECK([for isblank], [sudo_cv_func_isblank], - [AC_TRY_LINK([#include <ctype.h>], [return (isblank('a'));], - sudo_cv_func_isblank=yes, sudo_cv_func_isblank=no)]) -] [ - if test "$sudo_cv_func_isblank" = "yes"; then - AC_DEFINE(HAVE_ISBLANK, 1, [Define if you have isblank(3).]) - else - AC_LIBOBJ(isblank) +# generated automatically by aclocal 1.11.6 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, +# Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# longlong.m4 serial 17 +dnl Copyright (C) 1999-2007, 2009-2012 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +# Define HAVE_LONG_LONG_INT if 'long long int' works. +# This fixes a bug in Autoconf 2.61, and can be faster +# than what's in Autoconf 2.62 through 2.68. + +# Note: If the type 'long long int' exists but is only 32 bits large +# (as on some very old compilers), HAVE_LONG_LONG_INT will not be +# defined. In this case you can treat 'long long int' like 'long int'. + +AC_DEFUN([AC_TYPE_LONG_LONG_INT], +[ + AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) + AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], + [ac_cv_type_long_long_int=yes + if test "x${ac_cv_prog_cc_c99-no}" = xno; then + ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int + if test $ac_cv_type_long_long_int = yes; then + dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. + dnl If cross compiling, assume the bug is not important, since + dnl nobody cross compiles for this platform as far as we know. + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[@%:@include <limits.h> + @%:@ifndef LLONG_MAX + @%:@ define HALF \ + (1LL << (sizeof (long long int) * CHAR_BIT - 2)) + @%:@ define LLONG_MAX (HALF - 1 + HALF) + @%:@endif]], + [[long long int n = 1; + int i; + for (i = 0; ; i++) + { + long long int m = n << i; + if (m >> i != n) + return 1; + if (LLONG_MAX / 2 < m) + break; + } + return 0;]])], + [], + [ac_cv_type_long_long_int=no], + [:]) + fi + fi]) + if test $ac_cv_type_long_long_int = yes; then + AC_DEFINE([HAVE_LONG_LONG_INT], [1], + [Define to 1 if the system has the type 'long long int'.]) fi ]) -AC_DEFUN([SUDO_CHECK_LIB], [ - _sudo_check_lib_extras=`echo "$5"|sed -e 's/[ ]*//g' -e 's/-l/_/g'` - AC_MSG_CHECKING([for $2 in -l$1${5+ }$5]) - AC_CACHE_VAL([sudo_cv_lib_$1''_$2$_sudo_check_lib_extras], [ - SUDO_CHECK_LIB_OLIBS="$LIBS" - LIBS="$LIBS -l$1${5+ }$5" - AC_LINK_IFELSE( - [AC_LANG_CALL([], [$2])], - [eval sudo_cv_lib_$1''_$2$_sudo_check_lib_extras=yes], - [eval sudo_cv_lib_$1''_$2$_sudo_check_lib_extras=no] - ) - LIBS="$SUDO_CHECK_LIB_OLIBS" - ]) - if eval test \$sudo_cv_lib_$1''_$2$_sudo_check_lib_extras = "yes"; then - AC_MSG_RESULT([yes]) - $3 - else - AC_MSG_RESULT([no]) - $4 - fi -]) - -dnl -dnl check unsetenv() return value -dnl -AC_DEFUN([SUDO_FUNC_UNSETENV_VOID], - [AC_CACHE_CHECK([whether unsetenv returns void], [sudo_cv_func_unsetenv_void], - [AC_RUN_IFELSE([AC_LANG_PROGRAM( - [AC_INCLUDES_DEFAULT - int unsetenv(); - ], [ - [return unsetenv("FOO") != 0;] - ]) - ], - [sudo_cv_func_unsetenv_void=no], - [sudo_cv_func_unsetenv_void=yes], - [sudo_cv_func_unsetenv_void=no])]) - if test $sudo_cv_func_unsetenv_void = yes; then - AC_DEFINE(UNSETENV_VOID, 1, - [Define to 1 if the `unsetenv' function returns void instead of `int'.]) - fi - ]) - -dnl -dnl check putenv() argument for const -dnl -AC_DEFUN([SUDO_FUNC_PUTENV_CONST], -[AC_CACHE_CHECK([whether putenv takes a const argument], -sudo_cv_func_putenv_const, -[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT -int putenv(const char *string) {return 0;}], [])], - [sudo_cv_func_putenv_const=yes], - [sudo_cv_func_putenv_const=no]) - ]) - if test $sudo_cv_func_putenv_const = yes; then - AC_DEFINE(PUTENV_CONST, const, [Define to const if the `putenv' takes a const argument.]) - else - AC_DEFINE(PUTENV_CONST, []) +# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. +# This fixes a bug in Autoconf 2.61, and can be faster +# than what's in Autoconf 2.62 through 2.68. + +# Note: If the type 'unsigned long long int' exists but is only 32 bits +# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT +# will not be defined. In this case you can treat 'unsigned long long int' +# like 'unsigned long int'. + +AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], +[ + AC_CACHE_CHECK([for unsigned long long int], + [ac_cv_type_unsigned_long_long_int], + [ac_cv_type_unsigned_long_long_int=yes + if test "x${ac_cv_prog_cc_c99-no}" = xno; then + AC_LINK_IFELSE( + [_AC_TYPE_LONG_LONG_SNIPPET], + [], + [ac_cv_type_unsigned_long_long_int=no]) + fi]) + if test $ac_cv_type_unsigned_long_long_int = yes; then + AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], + [Define to 1 if the system has the type 'unsigned long long int'.]) fi ]) -dnl -dnl check for sa_len field in struct sockaddr -dnl -AC_DEFUN([SUDO_SOCK_SA_LEN], [ - AC_CHECK_MEMBER([struct sockaddr.sa_len], - [AC_DEFINE(HAVE_STRUCT_SOCKADDR_SA_LEN, 1, [Define if your struct sockadr has an sa_len field.])], - [], - [ #include <sys/types.h> - #include <sys/socket.h>] - )] -) -dnl -dnl check for max length of uid_t in string representation. -dnl we can't really trust UID_MAX or MAXUID since they may exist -dnl only for backwards compatibility. -dnl -AC_DEFUN([SUDO_UID_T_LEN], -[AC_REQUIRE([AC_TYPE_UID_T]) -AC_MSG_CHECKING(max length of uid_t) -AC_CACHE_VAL(sudo_cv_uid_t_len, -[rm -f conftestdata -AC_TRY_RUN( -[#include <stdio.h> -#include <pwd.h> -#include <limits.h> -#include <sys/types.h> -#include <sys/param.h> -main() { - FILE *f; - char b[1024]; - uid_t u = (uid_t) -1; - - if ((f = fopen("conftestdata", "w")) == NULL) - exit(1); - - (void) sprintf(b, "%lu", (unsigned long) u); - (void) fprintf(f, "%d\n", strlen(b)); - (void) fclose(f); - exit(0); -}], sudo_cv_uid_t_len=`cat conftestdata`, sudo_cv_uid_t_len=10, sudo_cv_uid_t_len=10) -]) -rm -f conftestdata -AC_MSG_RESULT($sudo_cv_uid_t_len) -AC_DEFINE_UNQUOTED(MAX_UID_T_LEN, $sudo_cv_uid_t_len, [Define to the max length of a uid_t in string context (excluding the NUL).]) -]) - -dnl -dnl Append a libpath to an LDFLAGS style variable if not already present. -dnl Also appends to the _R version unless rpath is disabled. -dnl -AC_DEFUN([SUDO_APPEND_LIBPATH], [ - case "${$1}" in - *"-L$2"|*"-L$2 ") - ;; - *) - $1="${$1} -L$2" - if test X"$enable_rpath" = X"yes"; then - $1_R="${$1_R} -R$2" - fi - ;; - esac -]) - -dnl -dnl Append a directory to CPPFLAGS if not already present. -dnl -AC_DEFUN([SUDO_APPEND_CPPFLAGS], [ - case "${CPPFLAGS}" in - *"$1"|*"$1 ") - ;; - *) - if test X"${CPPFLAGS}" = X""; then - CPPFLAGS="$1" - else - CPPFLAGS="${CPPFLAGS} $1" - fi - ;; - esac -]) - -dnl -dnl Determine the mail spool location -dnl NOTE: must be run *after* check for paths.h -dnl -AC_DEFUN([SUDO_MAILDIR], [ -maildir=no -if test X"$ac_cv_header_paths_h" = X"yes"; then -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT -#include <paths.h>], -[char *p = _PATH_MAILDIR;])], [maildir=yes], []) -fi -if test $maildir = no; then - # Solaris has maillock.h which defines MAILDIR - AC_CHECK_HEADERS(maillock.h, [ - SUDO_DEFINE(_PATH_MAILDIR, MAILDIR) - maildir=yes - ]) - if test $maildir = no; then - for d in /var/mail /var/spool/mail /usr/spool/mail; do - if test -d "$d"; then - maildir=yes - SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "$d") - break - fi - done - if test $maildir = no; then - # unable to find mail dir, hope for the best - SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "/var/mail") - fi - fi -fi +# Expands to a C program that can be used to test for simultaneous support +# of 'long long' and 'unsigned long long'. We don't want to say that +# 'long long' is available if 'unsigned long long' is not, or vice versa, +# because too many programs rely on the symmetry between signed and unsigned +# integer types (excluding 'bool'). +AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], +[ + AC_LANG_PROGRAM( + [[/* For now, do not test the preprocessor; as of 2007 there are too many + implementations with broken preprocessors. Perhaps this can + be revisited in 2012. In the meantime, code should not expect + #if to work with literals wider than 32 bits. */ + /* Test literals. */ + long long int ll = 9223372036854775807ll; + long long int nll = -9223372036854775807LL; + unsigned long long int ull = 18446744073709551615ULL; + /* Test constant expressions. */ + typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) + ? 1 : -1)]; + typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 + ? 1 : -1)]; + int i = 63;]], + [[/* Test availability of runtime routines for shift and division. */ + long long int llmax = 9223372036854775807ll; + unsigned long long int ullmax = 18446744073709551615ull; + return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) + | (llmax / ll) | (llmax % ll) + | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) + | (ullmax / ull) | (ullmax % ull));]]) ]) -dnl -dnl private versions of AC_DEFINE and AC_DEFINE_UNQUOTED that don't support -dnl tracing that we use to define paths for pathnames.h so autoheader doesn't -dnl put them in config.h.in. An awful hack. -dnl -m4_define([SUDO_DEFINE], -[cat >>confdefs.h <<\EOF -[@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1) -EOF -]) - -m4_define([SUDO_DEFINE_UNQUOTED], -[cat >>confdefs.h <<EOF -[@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1) -EOF -]) - -dnl -dnl Pull in libtool macros -dnl +m4_include([m4/ax_check_compile_flag.m4]) +m4_include([m4/ax_check_link_flag.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) -dnl -dnl Pull in other non-standard macros -dnl -m4_include([m4/ax_check_compile_flag.m4]) -m4_include([m4/ax_check_link_flag.m4]) +m4_include([m4/sudo.m4]) diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 000000000..f17572477 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# OpenBSD may have multiple versions of autoconf and automake installed +# If the user hasn't chosen one themselves, we do here. +if [ "`/usr/bin/uname 2>&1`" = "OpenBSD" ]; then + if [ X"$AUTOMAKE_VERSION" = X"" ]; then + AUTOMAKE_VERSION=1.11; export AUTOMAKE_VERSION + fi + if [ X"$AUTOCONF_VERSION" = X"" ]; then + AUTOCONF_VERSION=2.69; export AUTOCONF_VERSION + fi +fi + +set -ex + +autoreconf -f -i -v -Wall -I m4 + +rm -rf autom4te.cache + +exit 0 diff --git a/config.h.in b/config.h.in index 396812e07..d95c3b804 100644 --- a/config.h.in +++ b/config.h.in @@ -364,7 +364,7 @@ /* Define to 1 if you have the <login_cap.h> header file. */ #undef HAVE_LOGIN_CAP_H -/* Define to 1 if the system has the type `long long int'. */ +/* Define to 1 if the system has the type 'long long int'. */ #undef HAVE_LONG_LONG_INT /* Define to 1 if you have the `lrand48' function. */ @@ -602,7 +602,7 @@ /* Define to 1 if `pr_ttydev' is a member of `struct psinfo'. */ #undef HAVE_STRUCT_PSINFO_PR_TTYDEV -/* Define if your struct sockadr has an sa_len field. */ +/* Define if your struct sockaddr has an sa_len field. */ #undef HAVE_STRUCT_SOCKADDR_SA_LEN /* Define to 1 if the system has the type `struct timespec'. */ @@ -718,6 +718,9 @@ /* Define to 1 if you have the `unsetenv' function. */ #undef HAVE_UNSETENV +/* Define to 1 if the system has the type 'unsigned long long int'. */ +#undef HAVE_UNSIGNED_LONG_LONG_INT + /* Define to 1 if you have the <util.h> header file. */ #undef HAVE_UTIL_H diff --git a/configure b/configure index ad4fa4daa..d04009085 100755 --- a/configure +++ b/configure @@ -575,6 +575,7 @@ PACKAGE_STRING='sudo 1.8.9' PACKAGE_BUGREPORT='http://www.sudo.ws/bugs/' PACKAGE_URL='' +ac_unique_file="src/sudo.c" ac_config_libobj_dir=compat # Factoring default headers for most tests. ac_includes_default="\ @@ -2825,6 +2826,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h pathnames.h" + { $as_echo "$as_me:${as_lineno-$LINENO}: Configuring Sudo version $PACKAGE_VERSION" >&5 $as_echo "$as_me: Configuring Sudo version $PACKAGE_VERSION" >&6;} @@ -16131,27 +16133,29 @@ _ACEOF fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long long int" >&5 -$as_echo_n "checking for long long int... " >&6; } -if ${ac_cv_type_long_long_int+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned long long int" >&5 +$as_echo_n "checking for unsigned long long int... " >&6; } +if ${ac_cv_type_unsigned_long_long_int+:} false; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_cv_type_unsigned_long_long_int=yes + if test "x${ac_cv_prog_cc_c99-no}" = xno; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* For now, do not test the preprocessor; as of 2007 there are too many - implementations with broken preprocessors. Perhaps this can - be revisited in 2012. In the meantime, code should not expect - #if to work with literals wider than 32 bits. */ + implementations with broken preprocessors. Perhaps this can + be revisited in 2012. In the meantime, code should not expect + #if to work with literals wider than 32 bits. */ /* Test literals. */ long long int ll = 9223372036854775807ll; long long int nll = -9223372036854775807LL; unsigned long long int ull = 18446744073709551615ULL; /* Test constant expressions. */ typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) - ? 1 : -1)]; + ? 1 : -1)]; typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 - ? 1 : -1)]; + ? 1 : -1)]; int i = 63; int main () @@ -16160,46 +16164,73 @@ main () long long int llmax = 9223372036854775807ll; unsigned long long int ullmax = 18446744073709551615ull; return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) - | (llmax / ll) | (llmax % ll) - | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) - | (ullmax / ull) | (ullmax % ull)); + | (llmax / ll) | (llmax % ll) + | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) + | (ullmax / ull) | (ullmax % ull)); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - if test "$cross_compiling" = yes; then : + +else + ac_cv_type_unsigned_long_long_int=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_unsigned_long_long_int" >&5 +$as_echo "$ac_cv_type_unsigned_long_long_int" >&6; } + if test $ac_cv_type_unsigned_long_long_int = yes; then + +$as_echo "#define HAVE_UNSIGNED_LONG_LONG_INT 1" >>confdefs.h + + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long long int" >&5 +$as_echo_n "checking for long long int... " >&6; } +if ${ac_cv_type_long_long_int+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_cv_type_long_long_int=yes + if test "x${ac_cv_prog_cc_c99-no}" = xno; then + ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int + if test $ac_cv_type_long_long_int = yes; then + if test "$cross_compiling" = yes; then : + : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <limits.h> - #ifndef LLONG_MAX - # define HALF \ - (1LL << (sizeof (long long int) * CHAR_BIT - 2)) - # define LLONG_MAX (HALF - 1 + HALF) - #endif + #ifndef LLONG_MAX + # define HALF \ + (1LL << (sizeof (long long int) * CHAR_BIT - 2)) + # define LLONG_MAX (HALF - 1 + HALF) + #endif int main () { long long int n = 1; - int i; - for (i = 0; ; i++) - { - long long int m = n << i; - if (m >> i != n) - return 1; - if (LLONG_MAX / 2 < m) - break; - } - return 0; + int i; + for (i = 0; ; i++) + { + long long int m = n << i; + if (m >> i != n) + return 1; + if (LLONG_MAX / 2 < m) + break; + } + return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : - ac_cv_type_long_long_int=yes + else ac_cv_type_long_long_int=no fi @@ -16207,11 +16238,8 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi -else - ac_cv_type_long_long_int=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + fi + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_long_int" >&5 $as_echo "$ac_cv_type_long_long_int" >&6; } @@ -16390,6 +16418,7 @@ if test "$cross_compiling" = yes; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + #include <stdio.h> #include <pwd.h> #include <limits.h> @@ -16431,8 +16460,9 @@ _ACEOF - ac_fn_c_check_member "$LINENO" "struct sockaddr" "sa_len" "ac_cv_member_struct_sockaddr_sa_len" " #include <sys/types.h> - #include <sys/socket.h> + ac_fn_c_check_member "$LINENO" "struct sockaddr" "sa_len" "ac_cv_member_struct_sockaddr_sa_len" " +# include <sys/types.h> +# include <sys/socket.h> " if test "x$ac_cv_member_struct_sockaddr_sa_len" = xyes; then : @@ -17728,8 +17758,9 @@ else ;; esac - ac_fn_c_check_decl "$LINENO" "F_CLOSEM" "ac_cv_have_decl_F_CLOSEM" " #include <limits.h> - #include <fcntl.h> + ac_fn_c_check_decl "$LINENO" "F_CLOSEM" "ac_cv_have_decl_F_CLOSEM" " +# include <limits.h> +# include <fcntl.h> " if test "x$ac_cv_have_decl_F_CLOSEM" = xyes; then : $as_echo "#define HAVE_FCNTL_CLOSEM 1" >>confdefs.h @@ -19888,8 +19919,9 @@ fi $as_echo_n "checking for RFC1938-compliant skeychallenge... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include <stdio.h> - #include <skey.h> + +# include <stdio.h> +# include <skey.h> int main () { diff --git a/configure.in b/configure.in index dbce2d169..00b7ca60b 100644 --- a/configure.in +++ b/configure.in @@ -3,8 +3,10 @@ dnl Process this file with GNU autoconf to produce a configure script. dnl dnl Copyright (c) 1994-1996,1998-2013 Todd C. Miller <Todd.Miller@courtesan.com> dnl +AC_PREREQ([2.59]) AC_INIT([sudo], [1.8.9], [http://www.sudo.ws/bugs/], [sudo]) AC_CONFIG_HEADER([config.h pathnames.h]) +AC_CONFIG_SRCDIR([src/sudo.c]) dnl dnl Note: this must come after AC_INIT dnl @@ -2387,9 +2389,9 @@ AC_CHECK_FUNCS(getopt_long, [], [AC_LIBOBJ(getopt_long) AC_MSG_RESULT($sudo_cv_optreset) ]) AC_CHECK_FUNCS(closefrom, [], [AC_LIBOBJ(closefrom) - AC_CHECK_DECL(F_CLOSEM, AC_DEFINE(HAVE_FCNTL_CLOSEM), [], - [ #include <limits.h> - #include <fcntl.h> ]) + AC_CHECK_DECL(F_CLOSEM, AC_DEFINE(HAVE_FCNTL_CLOSEM), [], [ +# include <limits.h> +# include <fcntl.h> ]) ]) AC_CHECK_FUNCS(mkstemps mkdtemp, [], [ AC_CHECK_FUNCS(random lrand48, [break]) @@ -3007,9 +3009,7 @@ if test ${with_kerb5-'no'} != "no"; then AC_CHECK_FUNCS(krb5_get_init_creds_opt_alloc, [ AC_CACHE_CHECK([whether krb5_get_init_creds_opt_free takes a context], sudo_cv_krb5_get_init_creds_opt_free_two_args, [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include <krb5.h>]], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <krb5.h>]], [[krb5_get_init_creds_opt_free(NULL, NULL);]] )], [sudo_cv_krb5_get_init_creds_opt_free_two_args=yes], @@ -3126,9 +3126,9 @@ if test "${with_skey-'no'}" = "yes"; then AC_MSG_CHECKING([for RFC1938-compliant skeychallenge]) AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include <stdio.h> - #include <skey.h>]], + [AC_LANG_PROGRAM([[ +# include <stdio.h> +# include <skey.h>]], [[skeychallenge(NULL, NULL, NULL, 0);]] )], [ AC_DEFINE(HAVE_RFC1938_SKEYCHALLENGE) diff --git a/ltmain.sh b/ltmain.sh old mode 100755 new mode 100644 diff --git a/m4/sudo.m4 b/m4/sudo.m4 new file mode 100644 index 000000000..652fac640 --- /dev/null +++ b/m4/sudo.m4 @@ -0,0 +1,395 @@ +dnl Local m4 macros for autoconf (used by sudo) +dnl +dnl Copyright (c) 1994-1996, 1998-2005, 2007-2013 +dnl Todd C. Miller <Todd.Miller@courtesan.com> +dnl +dnl XXX - should cache values in all cases!!! +dnl +dnl checks for programs + +dnl +dnl check for sendmail in well-known locations +dnl +AC_DEFUN([SUDO_PROG_SENDMAIL], [AC_MSG_CHECKING([for sendmail]) +found=no +for p in "/usr/sbin/sendmail" "/usr/lib/sendmail" "/usr/etc/sendmail" "/usr/ucblib/sendmail" "/usr/local/lib/sendmail" "/usr/local/bin/sendmail"; do + if test -f "$p"; then + found=yes + AC_MSG_RESULT([$p]) + SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SENDMAIL, "$p") + break + fi +done +if test X"$found" != X"yes"; then + AC_MSG_RESULT([not found]) +fi +])dnl + +dnl +dnl check for vi in well-known locations +dnl +AC_DEFUN([SUDO_PROG_VI], [AC_MSG_CHECKING([for vi]) +found=no +for editor in "/usr/bin/vi" "/bin/vi" "/usr/ucb/vi" "/usr/bsd/vi" "/usr/local/bin/vi"; do + if test -f "$editor"; then + found=yes + AC_MSG_RESULT([$editor]) + SUDO_DEFINE_UNQUOTED(_PATH_VI, "$editor") + break + fi +done +if test X"$found" != X"yes"; then + AC_MSG_RESULT([not found]) +fi +])dnl + +dnl +dnl check for mv in well-known locations +dnl +AC_DEFUN([SUDO_PROG_MV], [AC_MSG_CHECKING([for mv]) +found=no +for p in "/usr/bin/mv" "/bin/mv" "/usr/ucb/mv" "/usr/sbin/mv"; do + if test -f "$p"; then + found=yes + AC_MSG_RESULT([$p]) + SUDO_DEFINE_UNQUOTED(_PATH_MV, "$p") + break + fi +done +if test X"$found" != X"yes"; then + AC_MSG_RESULT([not found]) +fi +])dnl + +dnl +dnl check for bourne shell in well-known locations +dnl +AC_DEFUN([SUDO_PROG_BSHELL], [AC_MSG_CHECKING([for bourne shell]) +found=no +for p in "/bin/sh" "/usr/bin/sh" "/sbin/sh" "/usr/sbin/sh" "/bin/ksh" "/usr/bin/ksh" "/bin/bash" "/usr/bin/bash"; do + if test -f "$p"; then + found=yes + AC_MSG_RESULT([$p]) + SUDO_DEFINE_UNQUOTED(_PATH_BSHELL, "$p") + break + fi +done +if test X"$found" != X"yes"; then + AC_MSG_RESULT([not found]) +fi +])dnl + +dnl +dnl check for utmp file +dnl +AC_DEFUN([SUDO_PATH_UTMP], [AC_MSG_CHECKING([for utmp file path]) +found=no +for p in "/var/run/utmp" "/var/adm/utmp" "/etc/utmp"; do + if test -r "$p"; then + found=yes + AC_MSG_RESULT([$p]) + SUDO_DEFINE_UNQUOTED(_PATH_UTMP, "$p") + break + fi +done +if test X"$found" != X"yes"; then + AC_MSG_RESULT([not found]) +fi +])dnl + +dnl +dnl Where the log file goes, use /var/log if it exists, else /{var,usr}/adm +dnl +AC_DEFUN([SUDO_LOGFILE], [AC_MSG_CHECKING(for log file location) +if test -n "$with_logpath"; then + AC_MSG_RESULT($with_logpath) + SUDO_DEFINE_UNQUOTED(_PATH_SUDO_LOGFILE, "$with_logpath") +elif test -d "/var/log"; then + AC_MSG_RESULT(/var/log/sudo.log) + SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/var/log/sudo.log") +elif test -d "/var/adm"; then + AC_MSG_RESULT(/var/adm/sudo.log) + SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/var/adm/sudo.log") +elif test -d "/usr/adm"; then + AC_MSG_RESULT(/usr/adm/sudo.log) + SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/usr/adm/sudo.log") +else + AC_MSG_RESULT(unknown, you will have to set _PATH_SUDO_LOGFILE by hand) +fi +])dnl + +dnl +dnl Where the timestamp files go. +dnl +AC_DEFUN([SUDO_TIMEDIR], [AC_MSG_CHECKING(for timestamp file location) +timedir="$with_timedir" +if test -z "$timedir"; then + for d in /var/db /var/lib /var/adm /usr/adm; do + if test -d "$d"; then + timedir="$d/sudo" + break + fi + done +fi +AC_MSG_RESULT([$timedir]) +SUDO_DEFINE_UNQUOTED(_PATH_SUDO_TIMEDIR, "$timedir") +])dnl + +dnl +dnl Where the I/O log files go, use /var/log/sudo-io if +dnl /var/log exists, else /{var,usr}/adm/sudo-io +dnl +AC_DEFUN([SUDO_IO_LOGDIR], [ + AC_MSG_CHECKING(for I/O log dir location) + if test "${with_iologdir-yes}" != "yes"; then + iolog_dir="$with_iologdir" + elif test -d "/var/log"; then + iolog_dir="/var/log/sudo-io" + elif test -d "/var/adm"; then + iolog_dir="/var/adm/sudo-io" + else + iolog_dir="/usr/adm/sudo-io" + fi + if test "${with_iologdir}" != "no"; then + SUDO_DEFINE_UNQUOTED(_PATH_SUDO_IO_LOGDIR, "$iolog_dir") + fi + AC_MSG_RESULT($iolog_dir) +])dnl + +dnl +dnl check for working fnmatch(3) +dnl +AC_DEFUN([SUDO_FUNC_FNMATCH], +[AC_MSG_CHECKING([for working fnmatch with FNM_CASEFOLD]) +AC_CACHE_VAL(sudo_cv_func_fnmatch, +[rm -f conftestdata; > conftestdata +AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <fnmatch.h> +main() { exit(fnmatch("/*/bin/echo *", "/usr/bin/echo just a test", FNM_CASEFOLD)); }]])], [sudo_cv_func_fnmatch=yes], [sudo_cv_func_fnmatch=no], + [sudo_cv_func_fnmatch=no]) +rm -f core core.* *.core]) +AC_MSG_RESULT($sudo_cv_func_fnmatch) +AS_IF([test $sudo_cv_func_fnmatch = yes], [$1], [$2])]) + +dnl +dnl Attempt to check for working PIE support. +dnl This is a bit of a hack but on Solaris 10 with GNU ld and GNU as +dnl we can end up with strange values from malloc(). +dnl A better check would be to verify that ASLR works with PIE. +dnl +AC_DEFUN([SUDO_WORKING_PIE], +[AC_MSG_CHECKING([for working PIE support]) +AC_CACHE_VAL(sudo_cv_working_pie, +[rm -f conftestdata; > conftestdata +AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT +main() { char *p = malloc(1024); if (p == NULL) return 1; memset(p, 0, 1024); return 0; }])], [sudo_cv_working_pie=yes], [sudo_cv_working_pie=no], + [sudo_cv_working_pie=no]) +rm -f core core.* *.core]) +AC_MSG_RESULT($sudo_cv_working_pie) +AS_IF([test $sudo_cv_working_pie = yes], [$1], [$2])]) + +dnl +dnl check for isblank(3) +dnl +AC_DEFUN([SUDO_FUNC_ISBLANK], + [AC_CACHE_CHECK([for isblank], [sudo_cv_func_isblank], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ctype.h>]], [[return (isblank('a'));]])], + [sudo_cv_func_isblank=yes], [sudo_cv_func_isblank=no])]) +] [ + if test "$sudo_cv_func_isblank" = "yes"; then + AC_DEFINE(HAVE_ISBLANK, 1, [Define if you have isblank(3).]) + else + AC_LIBOBJ(isblank) + fi +]) + +AC_DEFUN([SUDO_CHECK_LIB], [ + _sudo_check_lib_extras=`echo "$5"|sed -e 's/[ ]*//g' -e 's/-l/_/g'` + AC_MSG_CHECKING([for $2 in -l$1${5+ }$5]) + AC_CACHE_VAL([sudo_cv_lib_$1''_$2$_sudo_check_lib_extras], [ + SUDO_CHECK_LIB_OLIBS="$LIBS" + LIBS="$LIBS -l$1${5+ }$5" + AC_LINK_IFELSE( + [AC_LANG_CALL([], [$2])], + [eval sudo_cv_lib_$1''_$2$_sudo_check_lib_extras=yes], + [eval sudo_cv_lib_$1''_$2$_sudo_check_lib_extras=no] + ) + LIBS="$SUDO_CHECK_LIB_OLIBS" + ]) + if eval test \$sudo_cv_lib_$1''_$2$_sudo_check_lib_extras = "yes"; then + AC_MSG_RESULT([yes]) + $3 + else + AC_MSG_RESULT([no]) + $4 + fi +]) + +dnl +dnl check unsetenv() return value +dnl +AC_DEFUN([SUDO_FUNC_UNSETENV_VOID], + [AC_CACHE_CHECK([whether unsetenv returns void], [sudo_cv_func_unsetenv_void], + [AC_RUN_IFELSE([AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT + int unsetenv(); + ], [ + [return unsetenv("FOO") != 0;] + ]) + ], + [sudo_cv_func_unsetenv_void=no], + [sudo_cv_func_unsetenv_void=yes], + [sudo_cv_func_unsetenv_void=no])]) + if test $sudo_cv_func_unsetenv_void = yes; then + AC_DEFINE(UNSETENV_VOID, 1, + [Define to 1 if the `unsetenv' function returns void instead of `int'.]) + fi + ]) + +dnl +dnl check putenv() argument for const +dnl +AC_DEFUN([SUDO_FUNC_PUTENV_CONST], +[AC_CACHE_CHECK([whether putenv takes a const argument], +sudo_cv_func_putenv_const, +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT +int putenv(const char *string) {return 0;}], [])], + [sudo_cv_func_putenv_const=yes], + [sudo_cv_func_putenv_const=no]) + ]) + if test $sudo_cv_func_putenv_const = yes; then + AC_DEFINE(PUTENV_CONST, const, [Define to const if the `putenv' takes a const argument.]) + else + AC_DEFINE(PUTENV_CONST, []) + fi +]) + +dnl +dnl check for sa_len field in struct sockaddr +dnl +AC_DEFUN([SUDO_SOCK_SA_LEN], [ + AC_CHECK_MEMBER([struct sockaddr.sa_len], + [AC_DEFINE(HAVE_STRUCT_SOCKADDR_SA_LEN, 1, [Define if your struct sockaddr has an sa_len field.])], + [], [ +# include <sys/types.h> +# include <sys/socket.h>] + )] +) + +dnl +dnl check for max length of uid_t in string representation. +dnl we can't really trust UID_MAX or MAXUID since they may exist +dnl only for backwards compatibility. +dnl +AC_DEFUN([SUDO_UID_T_LEN], +[AC_REQUIRE([AC_TYPE_UID_T]) +AC_MSG_CHECKING(max length of uid_t) +AC_CACHE_VAL(sudo_cv_uid_t_len, +[rm -f conftestdata +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include <stdio.h> +#include <pwd.h> +#include <limits.h> +#include <sys/types.h> +#include <sys/param.h> +main() { + FILE *f; + char b[1024]; + uid_t u = (uid_t) -1; + + if ((f = fopen("conftestdata", "w")) == NULL) + exit(1); + + (void) sprintf(b, "%lu", (unsigned long) u); + (void) fprintf(f, "%d\n", strlen(b)); + (void) fclose(f); + exit(0); +}]])], [sudo_cv_uid_t_len=`cat conftestdata`], [sudo_cv_uid_t_len=10], [sudo_cv_uid_t_len=10]) +]) +rm -f conftestdata +AC_MSG_RESULT($sudo_cv_uid_t_len) +AC_DEFINE_UNQUOTED(MAX_UID_T_LEN, $sudo_cv_uid_t_len, [Define to the max length of a uid_t in string context (excluding the NUL).]) +]) + +dnl +dnl Append a libpath to an LDFLAGS style variable if not already present. +dnl Also appends to the _R version unless rpath is disabled. +dnl +AC_DEFUN([SUDO_APPEND_LIBPATH], [ + case "${$1}" in + *"-L$2"|*"-L$2 ") + ;; + *) + $1="${$1} -L$2" + if test X"$enable_rpath" = X"yes"; then + $1_R="${$1_R} -R$2" + fi + ;; + esac +]) + +dnl +dnl Append a directory to CPPFLAGS if not already present. +dnl +AC_DEFUN([SUDO_APPEND_CPPFLAGS], [ + case "${CPPFLAGS}" in + *"$1"|*"$1 ") + ;; + *) + if test X"${CPPFLAGS}" = X""; then + CPPFLAGS="$1" + else + CPPFLAGS="${CPPFLAGS} $1" + fi + ;; + esac +]) + +dnl +dnl Determine the mail spool location +dnl NOTE: must be run *after* check for paths.h +dnl +AC_DEFUN([SUDO_MAILDIR], [ +maildir=no +if test X"$ac_cv_header_paths_h" = X"yes"; then +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT +#include <paths.h>], +[char *p = _PATH_MAILDIR;])], [maildir=yes], []) +fi +if test $maildir = no; then + # Solaris has maillock.h which defines MAILDIR + AC_CHECK_HEADERS(maillock.h, [ + SUDO_DEFINE(_PATH_MAILDIR, MAILDIR) + maildir=yes + ]) + if test $maildir = no; then + for d in /var/mail /var/spool/mail /usr/spool/mail; do + if test -d "$d"; then + maildir=yes + SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "$d") + break + fi + done + if test $maildir = no; then + # unable to find mail dir, hope for the best + SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "/var/mail") + fi + fi +fi +]) + +dnl +dnl private versions of AC_DEFINE and AC_DEFINE_UNQUOTED that don't support +dnl tracing that we use to define paths for pathnames.h so autoheader doesn't +dnl put them in config.h.in. An awful hack. +dnl +m4_define([SUDO_DEFINE], +[cat >>confdefs.h <<\EOF +[@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1) +EOF +]) + +m4_define([SUDO_DEFINE_UNQUOTED], +[cat >>confdefs.h <<EOF +[@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1) +EOF +]) -- 2.40.0