From: Todd C. Miller Date: Mon, 27 Aug 2018 19:50:23 +0000 (-0600) Subject: Add a test for the 4-argument au_close() function found in Solaris X-Git-Tag: SUDO_1_8_25^2~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fdd72961220c5cc8cd646998fca248da370838cc;p=sudo Add a test for the 4-argument au_close() function found in Solaris 11 instead of assuming it is present if __sun is defined. Fixes a compilation error on OpenIndiana and older Solaris versions. --- diff --git a/config.h.in b/config.h.in index 920e84118..fd99abdaa 100644 --- a/config.h.in +++ b/config.h.in @@ -69,6 +69,10 @@ /* Define to 1 if you have the `auth_challenge' function. */ #undef HAVE_AUTH_CHALLENGE +/* Define to 1 if the `au_close' functions takes 4 arguments like Solaris 11. + */ +#undef HAVE_AU_CLOSE_SOLARIS11 + /* Define to 1 if you have the `bigcrypt' function. */ #undef HAVE_BIGCRYPT diff --git a/configure b/configure index e78bf5f53..8d213c66a 100755 --- a/configure +++ b/configure @@ -24601,6 +24601,46 @@ done fi fi +if test X"$with_bsm_audit" = X"yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether au_close() takes 4 arguments" >&5 +$as_echo_n "checking whether au_close() takes 4 arguments... " >&6; } +if ${sudo_cv_func_au_close_solaris11+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +#include +#include +#include + +int au_close(int d, int keep, au_event_t event, au_emod_t emod) {return 0;} +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + sudo_cv_func_au_close_solaris11=yes +else + sudo_cv_func_au_close_solaris11=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_func_au_close_solaris11" >&5 +$as_echo "$sudo_cv_func_au_close_solaris11" >&6; } + if test $sudo_cv_func_au_close_solaris11 = yes; then + +$as_echo "#define HAVE_AU_CLOSE_SOLARIS11 1" >>confdefs.h + + fi + +fi + if test X"$enable_poll" = X""; then for ac_func in ppoll poll do : diff --git a/configure.ac b/configure.ac index 0b303fccc..c8b3bfd46 100644 --- a/configure.ac +++ b/configure.ac @@ -3774,6 +3774,13 @@ if test ${with_passwd-'no'} != "no"; then fi fi +dnl +dnl Solaris 11 added a 4th argument to the au_close() function +dnl +if test X"$with_bsm_audit" = X"yes"; then + SUDO_FUNC_AU_CLOSE_SOLARIS11 +fi + dnl dnl Choose event subsystem backend: poll or select dnl diff --git a/m4/sudo.m4 b/m4/sudo.m4 index 6eda7d87a..df8966026 100644 --- a/m4/sudo.m4 +++ b/m4/sudo.m4 @@ -265,6 +265,26 @@ int putenv(const char *string) {return 0;}], [])], fi ]) +dnl +dnl check whether au_close() takes 3 or 4 arguments +dnl +AC_DEFUN([SUDO_FUNC_AU_CLOSE_SOLARIS11], +[AC_CACHE_CHECK([whether au_close() takes 4 arguments], +sudo_cv_func_au_close_solaris11, +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT +#include +#include +#include + +int au_close(int d, int keep, au_event_t event, au_emod_t emod) {return 0;}], [])], + [sudo_cv_func_au_close_solaris11=yes], + [sudo_cv_func_au_close_solaris11=no]) + ]) + if test $sudo_cv_func_au_close_solaris11 = yes; then + AC_DEFINE(HAVE_AU_CLOSE_SOLARIS11, 1, [Define to 1 if the `au_close' functions takes 4 arguments like Solaris 11.]) + fi +]) + dnl dnl Check if the data argument for the sha2 functions is void * or u_char * dnl diff --git a/plugins/sudoers/bsm_audit.c b/plugins/sudoers/bsm_audit.c index 80e4b2b1e..eaf92991e 100644 --- a/plugins/sudoers/bsm_audit.c +++ b/plugins/sudoers/bsm_audit.c @@ -174,7 +174,7 @@ bsm_audit_success(char *exec_args[]) debug_return_int(-1); } au_write(aufd, tok); -#ifdef __sun +#ifdef HAVE_AU_CLOSE_SOLARIS11 if (au_close(aufd, 1, sudo_audit_event, 0) == -1) #else if (au_close(aufd, 1, sudo_audit_event) == -1) @@ -265,7 +265,7 @@ bsm_audit_failure(char *exec_args[], char const *const fmt, va_list ap) debug_return_int(-1); } au_write(aufd, tok); -#ifdef __sun +#ifdef HAVE_AU_CLOSE_SOLARIS11 if (au_close(aufd, 1, sudo_audit_event, PAD_FAILURE) == -1) #else if (au_close(aufd, 1, sudo_audit_event) == -1)