]> granicus.if.org Git - sudo/commitdiff
Add explicit check for struct utmpx.ut_exit.e_termination
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 29 Mar 2011 13:10:40 +0000 (09:10 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 29 Mar 2011 13:10:40 +0000 (09:10 -0400)
and struct utmpx.ut_exit.__e_termination.  HP-UX uses the latter.
Only update ut_exit if we detect one or the other.

config.h.in
configure
configure.in
src/utmp.c

index c3673df79234decedfc444b07fb423150b830b45..5addde1870913b411933f18b248fabe41bc3159b 100644 (file)
 /* Define to 1 if `ut_exit' is a member of `struct utmpx'. */
 #undef HAVE_STRUCT_UTMPX_UT_EXIT
 
+/* Define to 1 if `ut_exit.e_termination' is a member of `struct utmpx'. */
+#undef HAVE_STRUCT_UTMPX_UT_EXIT_E_TERMINATION
+
+/* Define to 1 if `ut_exit.__e_termination' is a member of `struct utmpx'. */
+#undef HAVE_STRUCT_UTMPX_UT_EXIT___E_TERMINATION
+
 /* Define to 1 if `ut_id' is a member of `struct utmpx'. */
 #undef HAVE_STRUCT_UTMPX_UT_ID
 
 /* Define to 1 if `ut_exit' is a member of `struct utmp'. */
 #undef HAVE_STRUCT_UTMP_UT_EXIT
 
+/* Define to 1 if `ut_exit.e_termination' is a member of `struct utmp'. */
+#undef HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION
+
+/* Define to 1 if `ut_exit.__e_termination' is a member of `struct utmp'. */
+#undef HAVE_STRUCT_UTMP_UT_EXIT___E_TERMINATION
+
 /* Define to 1 if `ut_id' is a member of `struct utmp'. */
 #undef HAVE_STRUCT_UTMP_UT_ID
 
index db5c3e2e0d177deda60305ec33143ac875d90127..30bce2c7e6d89c5f5cff18eb2599670d605e1450 100755 (executable)
--- a/configure
+++ b/configure
@@ -15063,19 +15063,6 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-fi
-ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_exit" "ac_cv_member_struct_utmpx_ut_exit" "
-       #include <sys/types.h>
-       #include <utmpx.h>
-
-"
-if test "x$ac_cv_member_struct_utmpx_ut_exit" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMPX_UT_EXIT 1
-_ACEOF
-
-
 fi
 ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_pid" "ac_cv_member_struct_utmpx_ut_pid" "
        #include <sys/types.h>
@@ -15117,29 +15104,49 @@ _ACEOF
 
 fi
 
-else
-    ac_fn_c_check_member "$LINENO" "struct utmp" "ut_id" "ac_cv_member_struct_utmp_ut_id" "
+                ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_exit.__e_termination" "ac_cv_member_struct_utmpx_ut_exit___e_termination" "
        #include <sys/types.h>
-       #include <utmp.h>
+       #include <utmpx.h>
 
 "
-if test "x$ac_cv_member_struct_utmp_ut_id" = x""yes; then :
+if test "x$ac_cv_member_struct_utmpx_ut_exit___e_termination" = x""yes; then :
 
 cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMP_UT_ID 1
+#define HAVE_STRUCT_UTMPX_UT_EXIT___E_TERMINATION 1
+_ACEOF
+
+$as_echo "#define HAVE_STRUCT_UTMPX_UT_EXIT 1" >>confdefs.h
+
+else
+
+       ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_exit.e_termination" "ac_cv_member_struct_utmpx_ut_exit_e_termination" "
+           #include <sys/types.h>
+           #include <utmpx.h>
+
+"
+if test "x$ac_cv_member_struct_utmpx_ut_exit_e_termination" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMPX_UT_EXIT_E_TERMINATION 1
 _ACEOF
 
+$as_echo "#define HAVE_STRUCT_UTMPX_UT_EXIT 1" >>confdefs.h
 
 fi
-ac_fn_c_check_member "$LINENO" "struct utmp" "ut_exit" "ac_cv_member_struct_utmp_ut_exit" "
+
+
+fi
+
+else
+    ac_fn_c_check_member "$LINENO" "struct utmp" "ut_id" "ac_cv_member_struct_utmp_ut_id" "
        #include <sys/types.h>
        #include <utmp.h>
 
 "
-if test "x$ac_cv_member_struct_utmp_ut_exit" = x""yes; then :
+if test "x$ac_cv_member_struct_utmp_ut_id" = x""yes; then :
 
 cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMP_UT_EXIT 1
+#define HAVE_STRUCT_UTMP_UT_ID 1
 _ACEOF
 
 
@@ -15195,6 +15202,39 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+fi
+
+                ac_fn_c_check_member "$LINENO" "struct utmp" "ut_exit.__e_termination" "ac_cv_member_struct_utmp_ut_exit___e_termination" "
+       #include <sys/types.h>
+       #include <utmp.h>
+
+"
+if test "x$ac_cv_member_struct_utmp_ut_exit___e_termination" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMP_UT_EXIT___E_TERMINATION 1
+_ACEOF
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT 1" >>confdefs.h
+
+else
+
+       ac_fn_c_check_member "$LINENO" "struct utmp" "ut_exit.e_termination" "ac_cv_member_struct_utmp_ut_exit_e_termination" "
+           #include <sys/types.h>
+           #include <utmp.h>
+
+"
+if test "x$ac_cv_member_struct_utmp_ut_exit_e_termination" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION 1
+_ACEOF
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT 1" >>confdefs.h
+
+fi
+
+
 fi
 
 fi
@@ -21327,6 +21367,8 @@ fi
 
 
 
+
+
 
 
 
index 275f458098643f0e6c6794da2be5db3c31b96bda..35c8bf1276b39f680f4d0b6ff745c0dc52dd1e89 100644 (file)
@@ -1967,12 +1967,36 @@ dnl
 dnl Check for utmp/utmpx struct members.
 dnl
 if test $ac_cv_header_utmpx_h = "yes"; then
-    AC_CHECK_MEMBERS([struct utmpx.ut_id, struct utmpx.ut_exit, struct utmpx.ut_pid, struct utmpx.ut_tv, struct utmpx.ut_type], [], [], [
+    AC_CHECK_MEMBERS([struct utmpx.ut_id, struct utmpx.ut_pid, struct utmpx.ut_tv, struct utmpx.ut_type], [], [], [
+       #include <sys/types.h>
+       #include <utmpx.h>
+    ])
+    dnl
+    dnl Check for ut_exit.__e_termination first, then ut_exit.e_termination
+    dnl
+    AC_CHECK_MEMBERS([struct utmpx.ut_exit.__e_termination], [AC_DEFINE(HAVE_STRUCT_UTMPX_UT_EXIT)], [
+       AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_termination], [AC_DEFINE(HAVE_STRUCT_UTMPX_UT_EXIT)], [], [
+           #include <sys/types.h>
+           #include <utmpx.h>
+       ])
+    ], [
        #include <sys/types.h>
        #include <utmpx.h>
     ])
 else
-    AC_CHECK_MEMBERS([struct utmp.ut_id, struct utmp.ut_exit, struct utmp.ut_pid, struct utmp.ut_tv, struct utmp.ut_type, struct utmp.ut_user], [], [], [
+    AC_CHECK_MEMBERS([struct utmp.ut_id, struct utmp.ut_pid, struct utmp.ut_tv, struct utmp.ut_type, struct utmp.ut_user], [], [], [
+       #include <sys/types.h>
+       #include <utmp.h>
+    ])
+    dnl
+    dnl Check for ut_exit.__e_termination first, then ut_exit.e_termination
+    dnl
+    AC_CHECK_MEMBERS([struct utmp.ut_exit.__e_termination], [AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT)], [
+       AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination], [AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT)], [], [
+           #include <sys/types.h>
+           #include <utmp.h>
+       ])
+    ], [
        #include <sys/types.h>
        #include <utmp.h>
     ])
@@ -3010,6 +3034,8 @@ AH_TEMPLATE(USE_STOW, [Define to 1 if you use GNU stow packaging.])
 AH_TEMPLATE(WITHOUT_PASSWD, [Define to avoid using the passwd/shadow file for authentication.])
 AH_TEMPLATE(sig_atomic_t, [Define to `int' if <signal.h> does not define.])
 AH_TEMPLATE(__signed, [Define to `signed' or nothing if compiler does not support a signed type qualifier.])
+AH_TEMPLATE(HAVE_STRUCT_UTMP_UT_EXIT, [Define to 1 if `ut_exit' is a member of `struct utmp'.])
+AH_TEMPLATE(HAVE_STRUCT_UTMPX_UT_EXIT, [Define to 1 if `ut_exit' is a member of `struct utmpx'.])
 
 dnl
 dnl Bits to copy verbatim into config.h.in
index f8bd119d1a013424a0f7200b4fa0946eda044d36..dc6d45fe6fb166d3f4aecc2154b246992f2e1bac 100644 (file)
@@ -77,6 +77,14 @@ typedef struct utmp sudo_utmp_t;
 # endif
 #endif
 
+/* HP-UX has __e_termination and __e_exit, others lack the __ */
+#if defined(HAVE_STRUCT_UTMPX_UT_EXIT_E_TERMINATION) || defined(HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION)
+# undef  __e_termination
+# define __e_termination       e_termination
+# undef  __e_exit
+# define __e_exit              e_exit
+#endif
+
 #if defined(HAVE_GETUTXID) || defined(HAVE_GETUTID)
 /*
  * Create ut_id from the new ut_line and the old ut_id.
@@ -208,8 +216,8 @@ utmp_logout(const char *line, int status)
        ut->ut_type = DEAD_PROCESS;
 # endif
 # if defined(HAVE_STRUCT_UTMPX_UT_EXIT) || defined(HAVE_STRUCT_UTMP_UT_EXIT)
-       ut->ut_exit.e_exit = WEXITSTATUS(status);
-       ut->ut_exit.e_termination = WIFEXITED(status) ? WEXITSTATUS(status) : 0;
+       ut->ut_exit.__e_exit = WEXITSTATUS(status);
+       ut->ut_exit.__e_termination = WIFEXITED(status) ? WEXITSTATUS(status) : 0;
 # endif
        utmp_settime(ut);
        if (pututxline(ut) != NULL)