From daf634b728b9936dc8d1570003e522d81249dbbe Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 29 Jul 2014 10:52:43 -0600 Subject: [PATCH] Only include functions in util.exp that are actually in the library. Fixes a problem on Solaris where undefined functions that are listed as exported in the map file result in a link error. Also make sure we use our glob.c if the system is missing glob(). --- MANIFEST | 2 +- configure | 371 +++++++++++++++++++++++------ configure.ac | 117 +++++++-- include/sudo_compat.h | 10 +- lib/util/Makefile.in | 2 +- lib/util/{util.exp => util.exp.in} | 61 +---- m4/sudo.m4 | 11 + 7 files changed, 423 insertions(+), 151 deletions(-) rename lib/util/{util.exp => util.exp.in} (68%) diff --git a/MANIFEST b/MANIFEST index a0814248d..2e59c3a8f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -163,7 +163,7 @@ lib/util/sudo_dso.c lib/util/sudo_printf.c lib/util/term.c lib/util/ttysize.c -lib/util/util.exp +lib/util/util.exp.in lib/util/utimes.c lib/zlib/Makefile.in lib/zlib/adler32.c diff --git a/configure b/configure index 9f60d98c9..646421ce2 100755 --- a/configure +++ b/configure @@ -719,6 +719,7 @@ timeout vardir rundir iolog_dir +COMPAT_EXP RC_LINK INIT_DIR INIT_SCRIPT @@ -2972,6 +2973,7 @@ $as_echo "$as_me: Configuring Sudo version $PACKAGE_VERSION" >&6;} + # @@ -3054,7 +3056,7 @@ OS_INIT=os_init_common INIT_SCRIPT= INIT_DIR= RC_LINK= - +COMPAT_EXP= CHECKSHADOW=true shadow_defs= shadow_funcs= @@ -14264,6 +14266,12 @@ case "$host" in ;; esac + + for _sym in sudo_getcwd; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + $as_echo "#define PREFER_PORTABLE_GETCWD 1" >>confdefs.h @@ -14371,6 +14379,12 @@ fi done COMMON_OBJS="${COMMON_OBJS} aix.lo" + + for _sym in aix_prep_user_v1 aix_restoreauthdb_v1 aix_setauthdb_v1; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + ;; *-*-hiuxmpp*) : ${mansectsu='1m'} @@ -15209,6 +15223,13 @@ $as_echo "#define NO_VARIADIC_MACROS 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your C preprocessor doesn't support variadic macros, debugging support will be limited" >&5 $as_echo "$as_me: WARNING: Your C preprocessor doesn't support variadic macros, debugging support will be limited" >&2;} + + for _sym in sudo_debug_printf_nvm; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -17188,7 +17209,7 @@ $as_echo "#define HAVE_GETGROUPS 1" >>confdefs.h fi LIBS=$ac_save_LIBS -for ac_func in glob nl_langinfo regcomp strftime strrchr strtoll \ +for ac_func in killpg nl_langinfo regcomp strftime strrchr strtoll \ sysconf tzset do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -17328,6 +17349,12 @@ fi esac + for _sym in sudo_getgrouplist; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + fi done @@ -17347,6 +17374,12 @@ else ;; esac + + for _sym in sudo_getline; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + for ac_func in fgetln do : ac_fn_c_check_func "$LINENO" "fgetln" "ac_cv_func_fgetln" @@ -17849,7 +17882,8 @@ if test "x$ac_cv_func_utimes" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UTIMES 1 _ACEOF - for ac_func in futimes futimesat + + for ac_func in futimes futimesat do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -17861,40 +17895,37 @@ _ACEOF fi done + else - for ac_func in futime -do : - ac_fn_c_check_func "$LINENO" "futime" "ac_cv_func_futime" -if test "x$ac_cv_func_futime" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_FUTIME 1 -_ACEOF -fi -done - case " $LIBOBJS " in + case " $LIBOBJS " in *" utimes.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS utimes.$ac_objext" ;; esac -fi -done -for ac_func in killpg + for _sym in sudo_utimes; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + for ac_func in futime do : - ac_fn_c_check_func "$LINENO" "killpg" "ac_cv_func_killpg" -if test "x$ac_cv_func_killpg" = xyes; then : + ac_fn_c_check_func "$LINENO" "futime" "ac_cv_func_futime" +if test "x$ac_cv_func_futime" = xyes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_KILLPG 1 +#define HAVE_FUTIME 1 _ACEOF -else - case " $LIBOBJS " in - *" killpg.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS killpg.$ac_objext" - ;; -esac + for _sym in sudo_futimes; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + +fi +done + fi done @@ -17931,12 +17962,19 @@ if test $sudo_cv_func_fnmatch = yes; then : $as_echo "#define HAVE_FNMATCH 1" >>confdefs.h else - case " $LIBOBJS " in + + case " $LIBOBJS " in *" fnmatch.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS fnmatch.$ac_objext" ;; esac + + for _sym in sudo_fnmatch; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }fnm_test" fi @@ -17986,84 +18024,161 @@ esac fi -ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr" +for ac_func in glob +do : + ac_fn_c_check_func "$LINENO" "glob" "ac_cv_func_glob" +if test "x$ac_cv_func_glob" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_GLOB 1 +_ACEOF + +else + + case " $LIBOBJS " in + *" glob.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS glob.$ac_objext" + ;; +esac + + + for _sym in sudo_glob sudo_globfree; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + +fi +done + +for ac_func in memrchr +do : + ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr" if test "x$ac_cv_func_memrchr" = xyes; then : - $as_echo "#define HAVE_MEMRCHR 1" >>confdefs.h + cat >>confdefs.h <<_ACEOF +#define HAVE_MEMRCHR 1 +_ACEOF else - case " $LIBOBJS " in + + case " $LIBOBJS " in *" memrchr.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS memrchr.$ac_objext" ;; esac + + for _sym in sudo_memrchr; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + fi +done -ac_fn_c_check_func "$LINENO" "memset_s" "ac_cv_func_memset_s" +for ac_func in memset_s +do : + ac_fn_c_check_func "$LINENO" "memset_s" "ac_cv_func_memset_s" if test "x$ac_cv_func_memset_s" = xyes; then : - $as_echo "#define HAVE_MEMSET_S 1" >>confdefs.h + cat >>confdefs.h <<_ACEOF +#define HAVE_MEMSET_S 1 +_ACEOF else - case " $LIBOBJS " in + + case " $LIBOBJS " in *" memset_s.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS memset_s.$ac_objext" ;; esac + + for _sym in sudo_memset_s; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + fi +done -ac_fn_c_check_func "$LINENO" "pw_dup" "ac_cv_func_pw_dup" +for ac_func in pw_dup +do : + ac_fn_c_check_func "$LINENO" "pw_dup" "ac_cv_func_pw_dup" if test "x$ac_cv_func_pw_dup" = xyes; then : - $as_echo "#define HAVE_PW_DUP 1" >>confdefs.h + cat >>confdefs.h <<_ACEOF +#define HAVE_PW_DUP 1 +_ACEOF else - case " $LIBOBJS " in + + case " $LIBOBJS " in *" pw_dup.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS pw_dup.$ac_objext" ;; esac + + for _sym in sudo_pw_dup; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + fi +done -ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" +for ac_func in strlcpy +do : + ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" if test "x$ac_cv_func_strlcpy" = xyes; then : - $as_echo "#define HAVE_STRLCPY 1" >>confdefs.h + cat >>confdefs.h <<_ACEOF +#define HAVE_STRLCPY 1 +_ACEOF else - case " $LIBOBJS " in + + case " $LIBOBJS " in *" strlcpy.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext" ;; esac + + for _sym in sudo_strlcpy; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + fi +done -ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat" +for ac_func in strlcat +do : + ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat" if test "x$ac_cv_func_strlcat" = xyes; then : - $as_echo "#define HAVE_STRLCAT 1" >>confdefs.h + cat >>confdefs.h <<_ACEOF +#define HAVE_STRLCAT 1 +_ACEOF else - case " $LIBOBJS " in + + case " $LIBOBJS " in *" strlcat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strlcat.$ac_objext" ;; esac -fi -ac_fn_c_check_func "$LINENO" "strtonum" "ac_cv_func_strtonum" -if test "x$ac_cv_func_strtonum" = xyes; then : - $as_echo "#define HAVE_STRTONUM 1" >>confdefs.h + for _sym in sudo_strlcat; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done -else - case " $LIBOBJS " in - *" strtonum.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtonum.$ac_objext" - ;; -esac fi - +done for ac_func in clock_gettime do : @@ -18119,12 +18234,20 @@ if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then : SUDOERS_LIBS="${SUDOERS_LIBS} -lrt" else - case " $LIBOBJS " in + + case " $LIBOBJS " in *" clock_gettime.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS clock_gettime.$ac_objext" ;; esac + + for _sym in sudo_clock_gettime; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + fi @@ -18140,12 +18263,19 @@ if test "x$ac_cv_func_getopt_long" = xyes; then : _ACEOF else - case " $LIBOBJS " in + + case " $LIBOBJS " in *" getopt_long.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getopt_long.$ac_objext" ;; esac + + for _sym in sudo_getopt_long sudo_getopt_long_only; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for optreset" >&5 $as_echo_n "checking for optreset... " >&6; } if ${sudo_cv_optreset+:} false; then : @@ -18197,6 +18327,12 @@ else ;; esac + + for _sym in closefrom_fallback sudo_closefrom; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + ac_fn_c_check_decl "$LINENO" "F_CLOSEM" "ac_cv_have_decl_F_CLOSEM" " # include # include @@ -18219,8 +18355,10 @@ if eval test \"x\$"$as_ac_var"\" = x"yes"; then : #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF -else +fi +done +if test X"$ac_cv_func_mkstemps$ac_cv_func_mkdtemp" != X"yesyes"; then for ac_func in random lrand48 do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -18239,10 +18377,23 @@ done ;; esac + if test X"$ac_cv_func_mkstemps" = X"no"; then -fi -done + for _sym in sudo_mkstemps; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + fi + if test X"$ac_cv_func_mkdtemp" = X"no"; then + for _sym in sudo_mkdtemp; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + fi +fi for ac_func in snprintf vsnprintf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -18380,6 +18531,38 @@ esac fi fi +if test X"$ac_cv_have_working_snprintf" = X"no"; then + + for _sym in sudo_snprintf; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + +fi +if test X"$ac_cv_have_working_vsnprintf" = X"no"; then + + for _sym in sudo_vsnprintf; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + +fi +if test X"$ac_cv_func_asprintf" = X"no"; then + + for _sym in sudo_asprintf; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + +fi +if test X"$ac_cv_func_vasprintf" = X"no"; then + + for _sym in sudo_vasprintf; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + +fi # We wrap OpenBSD's strtonum() to get translatable error strings. for ac_func in strtonum do : @@ -18398,6 +18581,12 @@ case " $LIBOBJS " in ;; esac + + for _sym in sudo_strtonum; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + if test X"$ac_cv_type_struct_timespec" != X"no"; then ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim" "ac_cv_member_struct_stat_st_mtim" "$ac_includes_default" if test "x$ac_cv_member_struct_stat_st_mtim" = xyes; then : @@ -18419,9 +18608,11 @@ fi fi fi +FOUND_SHA2=no ac_fn_c_check_header_mongrel "$LINENO" "sha2.h" "ac_cv_header_sha2_h" "$ac_includes_default" if test "x$ac_cv_header_sha2_h" = xyes; then : + FOUND_SHA2=yes for ac_func in SHA224Update do : ac_fn_c_check_func "$LINENO" "SHA224Update" "ac_cv_func_SHA224Update" @@ -18543,11 +18734,9 @@ $as_echo "#define SHA2_VOID_PTR 1" >>confdefs.h LIBMD="-lmd" else - case " $LIBOBJS " in - *" sha2.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS sha2.$ac_objext" - ;; -esac + + # Does not have SHA224Update + FOUND_SHA2=no fi @@ -18556,16 +18745,23 @@ fi done -else - case " $LIBOBJS " in +fi + + +if test X"$FOUND_SHA2" = X"no"; then + case " $LIBOBJS " in *" sha2.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS sha2.$ac_objext" ;; esac -fi + for _sym in SHA224Final SHA224Init SHA224Pad SHA224Transform SHA224Update SHA256Final SHA256Init SHA256Pad SHA256Transform SHA256Update SHA384Final SHA384Init SHA384Pad SHA384Transform SHA384Update SHA512Final SHA512Init SHA512Pad SHA512Transform SHA512Update; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done +fi if test X"$with_noexec" != X"no"; then # Check for underscore versions of standard exec functions # unless we are using dyld symbole interposition @@ -19003,9 +19199,13 @@ $as_echo "no" >&6; } fi +found=false ac_fn_c_check_func "$LINENO" "inet_pton" "ac_cv_func_inet_pton" if test "x$ac_cv_func_inet_pton" = xyes; then : - $as_echo "#define HAVE_INET_PTON 1" >>confdefs.h + + found=true + $as_echo "#define HAVE_INET_PTON 1" >>confdefs.h + else @@ -19065,6 +19265,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + found=true $as_echo "#define HAVE_INET_PTON 1" >>confdefs.h NET_LIBS="${NET_LIBS} $libs" @@ -19081,13 +19282,19 @@ $as_echo "no" >&6; } fi -if test X"$ac_cv_func_inet_pton" != X"yes"; then +if test X"$found" != X"true"; then case " $LIBOBJS " in *" inet_pton.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS inet_pton.$ac_objext" ;; esac + + for _sym in sudo_inet_pton; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + fi ac_fn_c_check_func "$LINENO" "syslog" "ac_cv_func_syslog" if test "x$ac_cv_func_syslog" = xyes; then : @@ -19262,6 +19469,15 @@ for lib in $LIBS; do *) NET_LIBS="$NET_LIBS $lib";; esac done +if test X"$ax_cv_func_getaddrinfo" = X"no"; then + + for _sym in sudo_getaddrinfo sudo_freeaddrinfo sudo_gai_strerror; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + +fi + for ac_func in getprogname do : ac_fn_c_check_func "$LINENO" "getprogname" "ac_cv_func_getprogname" @@ -19315,6 +19531,12 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sudo_cv___progname" >&5 $as_echo "$sudo_cv___progname" >&6; } + for _sym in sudo_getprogname; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + + fi done @@ -19665,6 +19887,12 @@ else ;; esac + + for _sym in sudo_strsignal; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + HAVE_SIGLIST="false" ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" " $ac_includes_default @@ -19756,6 +19984,12 @@ else ;; esac + + for _sym in sudo_sig2str; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done + HAVE_SIGNAME="false" ac_fn_c_check_decl "$LINENO" "sys_signame" "ac_cv_have_decl_sys_signame" " $ac_includes_default @@ -22846,7 +23080,7 @@ test "$localedir" = '${datarootdir}/locale' && localedir='$(datarootdir)/locale' test "$localstatedir" = '${prefix}/var' && localstatedir='$(prefix)/var' test "$sysconfdir" = '${prefix}/etc' -a X"$with_stow" != X"yes" && sysconfdir='/etc' -ac_config_files="$ac_config_files Makefile doc/Makefile include/Makefile init.d/aix.sh init.d/hpux.sh lib/util/Makefile src/sudo_usage.h src/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers" +ac_config_files="$ac_config_files Makefile doc/Makefile include/Makefile init.d/aix.sh init.d/hpux.sh lib/util/Makefile lib/util/util.exp src/sudo_usage.h src/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -23839,6 +24073,7 @@ do "init.d/aix.sh") CONFIG_FILES="$CONFIG_FILES init.d/aix.sh" ;; "init.d/hpux.sh") CONFIG_FILES="$CONFIG_FILES init.d/hpux.sh" ;; "lib/util/Makefile") CONFIG_FILES="$CONFIG_FILES lib/util/Makefile" ;; + "lib/util/util.exp") CONFIG_FILES="$CONFIG_FILES lib/util/util.exp" ;; "src/sudo_usage.h") CONFIG_FILES="$CONFIG_FILES src/sudo_usage.h" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "plugins/sample/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/sample/Makefile" ;; diff --git a/configure.ac b/configure.ac index 30d928463..8c0552037 100644 --- a/configure.ac +++ b/configure.ac @@ -87,6 +87,7 @@ AC_SUBST([NO_VIZ]) AC_SUBST([INIT_SCRIPT]) AC_SUBST([INIT_DIR]) AC_SUBST([RC_LINK]) +AC_SUBST([COMPAT_EXP]) dnl dnl Variables that get substituted in docs (not overridden by environment) dnl @@ -214,7 +215,7 @@ OS_INIT=os_init_common INIT_SCRIPT= INIT_DIR= RC_LINK= - +COMPAT_EXP= dnl dnl Other vaiables dnl @@ -1636,6 +1637,7 @@ case "$host" in # getcwd(3) opens a pipe to getpwd(1)!?! AC_LIBOBJ(getcwd) + SUDO_APPEND_COMPAT_EXP(sudo_getcwd) AC_DEFINE(PREFER_PORTABLE_GETCWD) # system headers lack prototypes but gcc helps... @@ -1707,6 +1709,7 @@ case "$host" in # AIX-specific functions AC_CHECK_FUNCS(getuserattr setauthdb setrlimit64) COMMON_OBJS="${COMMON_OBJS} aix.lo" + SUDO_APPEND_COMPAT_EXP(aix_prep_user_v1 aix_restoreauthdb_v1 aix_setauthdb_v1) ;; *-*-hiuxmpp*) : ${mansectsu='1m'} @@ -2152,7 +2155,9 @@ AC_INCLUDES_DEFAULT ], [sudo_fprintf(stderr, "a %s", "test");])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_DEFINE([NO_VARIADIC_MACROS], [1], [Define if your C preprocessor does not support variadic macros.]) - AC_MSG_WARN([Your C preprocessor doesn't support variadic macros, debugging support will be limited])]) + AC_MSG_WARN([Your C preprocessor doesn't support variadic macros, debugging support will be limited]) + SUDO_APPEND_COMPAT_EXP(sudo_debug_printf_nvm) +]) dnl dnl Program checks @@ -2333,7 +2338,7 @@ dnl dnl Function checks dnl AC_FUNC_GETGROUPS -AC_CHECK_FUNCS(glob nl_langinfo regcomp strftime strrchr strtoll \ +AC_CHECK_FUNCS(killpg nl_langinfo regcomp strftime strrchr strtoll \ sysconf tzset) AC_CHECK_FUNCS(getgrouplist, [], [ case "$host_os" in @@ -2372,9 +2377,11 @@ AC_CHECK_FUNCS(getgrouplist, [], [ ;; esac AC_LIBOBJ(getgrouplist) + SUDO_APPEND_COMPAT_EXP(sudo_getgrouplist) ]) AC_CHECK_FUNCS(getline, [], [ AC_LIBOBJ(getline) + SUDO_APPEND_COMPAT_EXP(sudo_getline) AC_CHECK_FUNCS(fgetln) ]) dnl @@ -2456,21 +2463,56 @@ if test X"$with_interfaces" != X"no"; then fi AC_CHECK_FUNCS(lockf flock, [break]) AC_CHECK_FUNCS(innetgr _innetgr, [AC_CHECK_FUNCS(getdomainname) [break]]) -AC_CHECK_FUNCS(utimes, [AC_CHECK_FUNCS(futimes futimesat, [break])], [AC_CHECK_FUNCS(futime) AC_LIBOBJ(utimes)]) -AC_CHECK_FUNCS(killpg, [], [AC_LIBOBJ(killpg)]) -SUDO_FUNC_FNMATCH([AC_DEFINE(HAVE_FNMATCH)], [AC_LIBOBJ(fnmatch) +AC_CHECK_FUNCS(utimes, [ + AC_CHECK_FUNCS(futimes futimesat, [break]) +], [ + AC_LIBOBJ(utimes) + SUDO_APPEND_COMPAT_EXP(sudo_utimes) + AC_CHECK_FUNCS(futime, [SUDO_APPEND_COMPAT_EXP(sudo_futimes)]) +]) +SUDO_FUNC_FNMATCH([AC_DEFINE(HAVE_FNMATCH)], [ + AC_LIBOBJ(fnmatch) + SUDO_APPEND_COMPAT_EXP(sudo_fnmatch) COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }fnm_test" ]) SUDO_FUNC_ISBLANK -AC_REPLACE_FUNCS(memrchr memset_s pw_dup strlcpy strlcat strtonum) +AC_CHECK_FUNCS(glob, [], [ + AC_LIBOBJ(glob) + SUDO_APPEND_COMPAT_EXP(sudo_glob sudo_globfree) +]) +AC_CHECK_FUNCS(memrchr, [], [ + AC_LIBOBJ(memrchr) + SUDO_APPEND_COMPAT_EXP(sudo_memrchr) +]) +AC_CHECK_FUNCS(memset_s, [], [ + AC_LIBOBJ(memset_s) + SUDO_APPEND_COMPAT_EXP(sudo_memset_s) +]) +AC_CHECK_FUNCS(pw_dup, [], [ + AC_LIBOBJ(pw_dup) + SUDO_APPEND_COMPAT_EXP(sudo_pw_dup) +]) +AC_CHECK_FUNCS(strlcpy, [], [ + AC_LIBOBJ(strlcpy) + SUDO_APPEND_COMPAT_EXP(sudo_strlcpy) +]) +AC_CHECK_FUNCS(strlcat, [], [ + AC_LIBOBJ(strlcat) + SUDO_APPEND_COMPAT_EXP(sudo_strlcat) +]) AC_CHECK_FUNCS(clock_gettime, [], [ # On Solaris, clock_gettime is in librt AC_CHECK_LIB(rt, clock_gettime, [ AC_DEFINE(HAVE_CLOCK_GETTIME) SUDOERS_LIBS="${SUDOERS_LIBS} -lrt" - ], [AC_LIBOBJ(clock_gettime)]) + ], [ + AC_LIBOBJ(clock_gettime) + SUDO_APPEND_COMPAT_EXP(sudo_clock_gettime) + ]) ]) -AC_CHECK_FUNCS(getopt_long, [], [AC_LIBOBJ(getopt_long) +AC_CHECK_FUNCS(getopt_long, [], [ + AC_LIBOBJ(getopt_long) + SUDO_APPEND_COMPAT_EXP(sudo_getopt_long sudo_getopt_long_only) AC_MSG_CHECKING([for optreset]) AC_CACHE_VAL(sudo_cv_optreset, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern int optreset; optreset = 1; return optreset;]])], [sudo_cv_optreset=yes], [sudo_cv_optreset=no])]) @@ -2480,14 +2522,22 @@ AC_CHECK_FUNCS(getopt_long, [], [AC_LIBOBJ(getopt_long) AC_MSG_RESULT($sudo_cv_optreset) ]) AC_CHECK_FUNCS(closefrom, [], [AC_LIBOBJ(closefrom) + SUDO_APPEND_COMPAT_EXP(closefrom_fallback sudo_closefrom) AC_CHECK_DECL(F_CLOSEM, AC_DEFINE(HAVE_FCNTL_CLOSEM), [], [ # include # include ]) ]) -AC_CHECK_FUNCS(mkstemps mkdtemp, [], [ +AC_CHECK_FUNCS(mkstemps mkdtemp) +if test X"$ac_cv_func_mkstemps$ac_cv_func_mkdtemp" != X"yesyes"; then AC_CHECK_FUNCS(random lrand48, [break]) AC_LIBOBJ(mktemp) -]) + if test X"$ac_cv_func_mkstemps" = X"no"; then + SUDO_APPEND_COMPAT_EXP(sudo_mkstemps) + fi + if test X"$ac_cv_func_mkdtemp" = X"no"; then + SUDO_APPEND_COMPAT_EXP(sudo_mkdtemp) + fi +fi AX_FUNC_SNPRINTF AC_CHECK_FUNCS(asprintf vasprintf) if test X"$ac_cv_have_working_snprintf$ac_cv_have_working_vsnprintf" = X"yesyes"; then @@ -2496,24 +2546,46 @@ if test X"$ac_cv_have_working_snprintf$ac_cv_have_working_vsnprintf" = X"yesyes" AC_LIBOBJ(snprintf) fi fi +if test X"$ac_cv_have_working_snprintf" = X"no"; then + SUDO_APPEND_COMPAT_EXP(sudo_snprintf) +fi +if test X"$ac_cv_have_working_vsnprintf" = X"no"; then + SUDO_APPEND_COMPAT_EXP(sudo_vsnprintf) +fi +if test X"$ac_cv_func_asprintf" = X"no"; then + SUDO_APPEND_COMPAT_EXP(sudo_asprintf) +fi +if test X"$ac_cv_func_vasprintf" = X"no"; then + SUDO_APPEND_COMPAT_EXP(sudo_vasprintf) +fi # We wrap OpenBSD's strtonum() to get translatable error strings. AC_CHECK_FUNCS(strtonum) AC_LIBOBJ(strtonum) +SUDO_APPEND_COMPAT_EXP(sudo_strtonum) if test X"$ac_cv_type_struct_timespec" != X"no"; then AC_CHECK_MEMBER([struct stat.st_mtim], [AC_DEFINE(HAVE_ST_MTIM)] [AC_CHECK_MEMBER([struct stat.st_mtim.st__tim], AC_DEFINE(HAVE_ST__TIM))], [AC_CHECK_MEMBER([struct stat.st_mtimespec], AC_DEFINE([HAVE_ST_MTIMESPEC]))]) fi +FOUND_SHA2=no AC_CHECK_HEADER([sha2.h], [ + FOUND_SHA2=yes AC_CHECK_FUNCS(SHA224Update, [SUDO_FUNC_SHA2_VOID_PTR], [ # On some systems, SHA224Update is in libmd AC_CHECK_LIB(md, SHA224Update, [ AC_DEFINE(HAVE_SHA224UPDATE) SUDO_FUNC_SHA2_VOID_PTR LIBMD="-lmd" - ], [AC_LIBOBJ(sha2)]) + ], [ + # Does not have SHA224Update + FOUND_SHA2=no + ]) ]) -], [AC_LIBOBJ(sha2)]) +]) +if test X"$FOUND_SHA2" = X"no"; then + AC_LIBOBJ(sha2) + SUDO_APPEND_COMPAT_EXP(SHA224Final SHA224Init SHA224Pad SHA224Transform SHA224Update SHA256Final SHA256Init SHA256Pad SHA256Transform SHA256Update SHA384Final SHA384Init SHA384Pad SHA384Transform SHA384Update SHA512Final SHA512Init SHA512Pad SHA512Transform SHA512Update) +fi dnl dnl Function checks for sudo_noexec dnl @@ -2623,7 +2695,11 @@ dnl If inet_pton(3) not in libc, check -lnsl and -linet dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols dnl Some systems may have inet_pton() in libresolv. dnl -AC_CHECK_FUNC(inet_pton, [AC_DEFINE(HAVE_INET_PTON)], [ +found=false +AC_CHECK_FUNC(inet_pton, [ + found=true + AC_DEFINE(HAVE_INET_PTON) +], [ for libs in "-lsocket" "-linet" "-lsocket -lnsl" "-lresolv"; do _libs= for lib in $libs; do @@ -2637,6 +2713,7 @@ AC_CHECK_FUNC(inet_pton, [AC_DEFINE(HAVE_INET_PTON)], [ lib="`echo \"$libs\"|sed -e 's/^-l//' -e 's/ .*$//'`" extralibs="`echo \"$libs\"|sed 's/^-l[[^ ]]*//'`" SUDO_CHECK_LIB($lib, inet_pton, [ + found=true AC_DEFINE(HAVE_INET_PTON) NET_LIBS="${NET_LIBS} $libs" LIBS="${LIBS} $libs" @@ -2644,8 +2721,9 @@ AC_CHECK_FUNC(inet_pton, [AC_DEFINE(HAVE_INET_PTON)], [ ], [], [$extralibs]) done ]) -if test X"$ac_cv_func_inet_pton" != X"yes"; then +if test X"$found" != X"true"; then AC_LIBOBJ(inet_pton) + SUDO_APPEND_COMPAT_EXP(sudo_inet_pton) fi dnl dnl If syslog(3) not in libc, check -lsocket, -lnsl and -linet @@ -2677,6 +2755,10 @@ for lib in $LIBS; do *) NET_LIBS="$NET_LIBS $lib";; esac done +if test X"$ax_cv_func_getaddrinfo" = X"no"; then + SUDO_APPEND_COMPAT_EXP(sudo_getaddrinfo sudo_freeaddrinfo sudo_gai_strerror) +fi + dnl dnl Check for getprogname() or __progname dnl @@ -2688,6 +2770,7 @@ AC_CHECK_FUNCS(getprogname, [AC_CHECK_FUNCS(setprogname)], [ AC_DEFINE(HAVE___PROGNAME) fi AC_MSG_RESULT($sudo_cv___progname) + SUDO_APPEND_COMPAT_EXP(sudo_getprogname) ]) dnl dnl Check for __func__ or __FUNCTION__ @@ -2826,6 +2909,7 @@ dnl Check for strsignal() or sys_siglist dnl AC_CHECK_FUNCS(strsignal, [], [ AC_LIBOBJ(strsignal) + SUDO_APPEND_COMPAT_EXP(sudo_strsignal) HAVE_SIGLIST="false" AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], [ HAVE_SIGLIST="true" @@ -2844,6 +2928,7 @@ dnl Check for sig2str(), sys_signame or sys_sigabbrev dnl AC_CHECK_FUNCS(sig2str, [], [ AC_LIBOBJ(sig2str) + SUDO_APPEND_COMPAT_EXP(sudo_sig2str) HAVE_SIGNAME="false" AC_CHECK_DECLS([sys_signame, _sys_signame, __sys_signame, sys_sigabbrev], [ HAVE_SIGNAME="true" @@ -3886,7 +3971,7 @@ test "$sysconfdir" = '${prefix}/etc' -a X"$with_stow" != X"yes" && sysconfdir='/ dnl dnl Substitute into the Makefile and man pages dnl -AC_CONFIG_FILES([Makefile doc/Makefile include/Makefile init.d/aix.sh init.d/hpux.sh lib/util/Makefile src/sudo_usage.h src/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers]) +AC_CONFIG_FILES([Makefile doc/Makefile include/Makefile init.d/aix.sh init.d/hpux.sh lib/util/Makefile lib/util/util.exp src/sudo_usage.h src/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers]) AC_OUTPUT dnl diff --git a/include/sudo_compat.h b/include/sudo_compat.h index 67812362c..283cd4636 100644 --- a/include/sudo_compat.h +++ b/include/sudo_compat.h @@ -350,6 +350,11 @@ int innetgr(const char *, const char *, const char *, const char *); int getdomainname(char *, size_t); #endif +/* We wrap OpenBSD's strtonum() to get translatable error strings. */ +__dso_public long long sudo_strtonum(const char *, long long, long long, const char **); +#undef strtonum +#define strtonum(_a, _b, _c, _d) sudo_strtonum((_a), (_b), (_c), (_d)) + /* * Functions "missing" from libc. * All libc replacements are prefixed with "sudo_" to avoid namespace issues. @@ -453,11 +458,6 @@ __dso_public int sudo_sig2str(int, char *); # undef sig2str # define sig2str(_a, _b) sudo_sig2str((_a), (_b)) #endif /* HAVE_SIG2STR */ -#ifndef HAVE_STRTONUM -__dso_public long long sudo_strtonum(const char *, long long, long long, const char **); -# undef strtonum -# define strtonum(_a, _b, _c, _d) sudo_strtonum((_a), (_b), (_c), (_d)) -#endif /* HAVE_STRTONUM */ #ifndef HAVE_CLOCK_GETTIME # define CLOCK_REALTIME 0 # ifdef __MACH__ diff --git a/lib/util/Makefile.in b/lib/util/Makefile.in index 872e511ff..fe1548f97 100644 --- a/lib/util/Makefile.in +++ b/lib/util/Makefile.in @@ -39,7 +39,7 @@ localstatedir = @localstatedir@ # File extension, mode and map file to use for shared libraries/objects shlib_enable = @SHLIB_ENABLE@ shlib_mode = @SHLIB_MODE@ -shlib_exp = $(srcdir)/util.exp +shlib_exp = ./util.exp shlib_map = util.map shlib_opt = util.opt diff --git a/lib/util/util.exp b/lib/util/util.exp.in similarity index 68% rename from lib/util/util.exp rename to lib/util/util.exp.in index b611c80e6..9e308f795 100644 --- a/lib/util/util.exp +++ b/lib/util/util.exp.in @@ -1,33 +1,5 @@ -SHA224Final -SHA224Init -SHA224Pad -SHA224Transform -SHA224Update -SHA256Final -SHA256Init -SHA256Pad -SHA256Transform -SHA256Update -SHA384Final -SHA384Init -SHA384Pad -SHA384Transform -SHA384Update -SHA512Final -SHA512Init -SHA512Pad -SHA512Transform -SHA512Update -_sudo_printf -aix_prep_user_v1 -aix_restoreauthdb_v1 -aix_setauthdb_v1 -closefrom_fallback +@COMPAT_EXP@_sudo_printf initprogname -isblank -sudo_asprintf -sudo_clock_gettime -sudo_closefrom sudo_conf_askpass_path_v1 sudo_conf_debug_flags_v1 sudo_conf_disable_coredump_v1 @@ -54,7 +26,6 @@ sudo_debug_fd_set sudo_debug_fork sudo_debug_init sudo_debug_printf2 -sudo_debug_printf_nvm sudo_debug_vprintf2 sudo_debug_write2 sudo_dso_findsym_v1 @@ -89,48 +60,23 @@ sudo_fatal_callback_deregister_v1 sudo_fatal_callback_register_v1 sudo_fatal_nodebug_v1 sudo_fatalx_nodebug_v1 -sudo_fnmatch -sudo_freeaddrinfo -sudo_futimes -sudo_gai_strerror sudo_get_ttysize_v1 -sudo_getaddrinfo -sudo_getcwd -sudo_getgrouplist -sudo_getline -sudo_getopt_long -sudo_getopt_long_only -sudo_getprogname -sudo_glob -sudo_globfree -sudo_inet_pton sudo_lbuf_append_quoted_v1 sudo_lbuf_append_v1 sudo_lbuf_destroy_v1 sudo_lbuf_init_v1 sudo_lbuf_print_v1 sudo_lock_file_v1 -sudo_memrchr -sudo_memset_s -sudo_mkdtemp -sudo_mkstemps sudo_new_key_val_v1 sudo_parse_gids_v1 sudo_parseln_v1 sudo_printf -sudo_pw_dup sudo_secure_dir_v1 sudo_secure_file_v1 sudo_setgroups_v1 -sudo_sig2str -sudo_snprintf -sudo_strlcat -sudo_strlcpy -sudo_strsignal sudo_strtobool_v1 sudo_strtoid_v1 sudo_strtomode_v1 -sudo_strtonum sudo_term_cbreak_v1 sudo_term_copy_v1 sudo_term_erase @@ -138,14 +84,9 @@ sudo_term_kill sudo_term_noecho_v1 sudo_term_raw_v1 sudo_term_restore_v1 -sudo_utimes -sudo_vasprintf sudo_vfatal_nodebug_v1 sudo_vfatalx_nodebug_v1 -sudo_vsnprintf sudo_vwarn_nodebug_v1 sudo_vwarnx_nodebug_v1 -sudo_warn_gettext_v1 sudo_warn_nodebug_v1 -sudo_warn_strerror_v1 sudo_warnx_nodebug_v1 diff --git a/m4/sudo.m4 b/m4/sudo.m4 index d9d97fffa..35f18cae4 100644 --- a/m4/sudo.m4 +++ b/m4/sudo.m4 @@ -216,6 +216,7 @@ AC_DEFUN([SUDO_FUNC_ISBLANK], AC_DEFINE(HAVE_ISBLANK, 1, [Define if you have isblank(3).]) else AC_LIBOBJ(isblank) + SUDO_APPEND_COMPAT_EXP(isblank) fi ]) @@ -391,6 +392,16 @@ AC_DEFUN([SUDO_APPEND_CPPFLAGS], [ esac ]) +dnl +dnl Append one or more symbols to COMPAT_EXP +dnl +AC_DEFUN([SUDO_APPEND_COMPAT_EXP], [ + for _sym in $1; do + COMPAT_EXP="${COMPAT_EXP}${_sym} +" + done +]) + dnl dnl Determine the mail spool location dnl NOTE: must be run *after* check for paths.h -- 2.40.0