/* Define to 1 if you have the `getutid' function. */
#undef HAVE_GETUTID
+/* Define to 1 if you have the `getutsid' function. */
+#undef HAVE_GETUTSID
+
/* Define to 1 if you have the `getutxid' function. */
#undef HAVE_GETUTXID
/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
#undef HAVE_STRUCT_TM_TM_GMTOFF
-/* 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_pid' is a member of `struct utmpx'. */
-#undef HAVE_STRUCT_UTMPX_UT_PID
-
-/* Define to 1 if `ut_tv' is a member of `struct utmpx'. */
-#undef HAVE_STRUCT_UTMPX_UT_TV
-
-/* Define to 1 if `ut_type' is a member of `struct utmpx'. */
-#undef HAVE_STRUCT_UTMPX_UT_TYPE
-
/* Define to 1 if `ut_exit' is a member of `struct utmp'. */
#undef HAVE_STRUCT_UTMP_UT_EXIT
/* Define to 1 if you have the `utimes' function. */
#undef HAVE_UTIMES
+/* Define to 1 if you have the <utmps.h> header file. */
+#undef HAVE_UTMPS_H
+
/* Define to 1 if you have the <utmpx.h> header file. */
#undef HAVE_UTMPX_H
as_fn_append ac_header_list " netgroup.h"
as_fn_append ac_header_list " paths.h"
as_fn_append ac_header_list " spawn.h"
-as_fn_append ac_header_list " utmpx.h"
as_fn_append ac_header_list " wordexp.h"
as_fn_append ac_header_list " sys/sockio.h"
as_fn_append ac_header_list " sys/bsdtypes.h"
+for ac_header in utmps.h utmpx.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+done
for ac_header in endian.h sys/endian.h machine/endian.h
do :
_ACEOF
-if test $ac_cv_header_utmpx_h = "yes"; then
- ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_id" "ac_cv_member_struct_utmpx_ut_id" "
+if test $ac_cv_header_utmps_h = "yes"; then
+
+ ac_fn_c_check_member "$LINENO" "struct utmps" "ut_id" "ac_cv_member_struct_utmps_ut_id" "
# include <sys/types.h>
-# include <utmpx.h>
+# include <utmps.h>
"
-if test "x$ac_cv_member_struct_utmpx_ut_id" = xyes; then :
+if test "x$ac_cv_member_struct_utmps_ut_id" = xyes; then :
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_ID 1" >>confdefs.h
+
+
+fi
+
+ ac_fn_c_check_member "$LINENO" "struct utmps" "ut_pid" "ac_cv_member_struct_utmps_ut_pid" "
+# include <sys/types.h>
+# include <utmps.h>
+
+"
+if test "x$ac_cv_member_struct_utmps_ut_pid" = xyes; then :
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_PID 1" >>confdefs.h
+
+
+fi
+
+ ac_fn_c_check_member "$LINENO" "struct utmps" "ut_tv" "ac_cv_member_struct_utmps_ut_tv" "
+# include <sys/types.h>
+# include <utmps.h>
+
+"
+if test "x$ac_cv_member_struct_utmps_ut_tv" = xyes; then :
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_TV 1" >>confdefs.h
+
+
+fi
+
+ ac_fn_c_check_member "$LINENO" "struct utmps" "ut_type" "ac_cv_member_struct_utmps_ut_type" "
+# include <sys/types.h>
+# include <utmps.h>
+
+"
+if test "x$ac_cv_member_struct_utmps_ut_type" = xyes; then :
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_TYPE 1" >>confdefs.h
+
+
+fi
+
+ if test "utmps" = "utmp"; then
+ ac_fn_c_check_member "$LINENO" "struct utmp" "ut_user" "ac_cv_member_struct_utmp_ut_user" "
+# include <sys/types.h>
+# include <utmps.h>
+
+"
+if test "x$ac_cv_member_struct_utmp_ut_user" = xyes; then :
cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMPX_UT_ID 1
+#define HAVE_STRUCT_UTMP_UT_USER 1
_ACEOF
fi
-ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_pid" "ac_cv_member_struct_utmpx_ut_pid" "
+
+ fi
+ ac_fn_c_check_member "$LINENO" "struct utmps" "ut_exit.__e_termination" "ac_cv_member_struct_utmps_ut_exit___e_termination" "
+# include <sys/types.h>
+# include <utmps.h>
+
+"
+if test "x$ac_cv_member_struct_utmps_ut_exit___e_termination" = xyes; then :
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT___E_TERMINATION 1" >>confdefs.h
+
+
+else
+
+ ac_fn_c_check_member "$LINENO" "struct utmps" "ut_exit.e_termination" "ac_cv_member_struct_utmps_ut_exit_e_termination" "
+# include <sys/types.h>
+# include <utmps.h>
+
+"
+if test "x$ac_cv_member_struct_utmps_ut_exit_e_termination" = xyes; then :
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION 1" >>confdefs.h
+
+
+fi
+
+
+fi
+
+
+elif test $ac_cv_header_utmpx_h = "yes"; then
+
+ ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_id" "ac_cv_member_struct_utmpx_ut_id" "
+# include <sys/types.h>
+# include <utmpx.h>
+
+"
+if test "x$ac_cv_member_struct_utmpx_ut_id" = xyes; then :
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_ID 1" >>confdefs.h
+
+
+fi
+
+ ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_pid" "ac_cv_member_struct_utmpx_ut_pid" "
# include <sys/types.h>
# include <utmpx.h>
"
if test "x$ac_cv_member_struct_utmpx_ut_pid" = xyes; then :
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMPX_UT_PID 1
-_ACEOF
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_PID 1" >>confdefs.h
fi
-ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_tv" "ac_cv_member_struct_utmpx_ut_tv" "
+
+ ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_tv" "ac_cv_member_struct_utmpx_ut_tv" "
# include <sys/types.h>
# include <utmpx.h>
"
if test "x$ac_cv_member_struct_utmpx_ut_tv" = xyes; then :
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMPX_UT_TV 1
-_ACEOF
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_TV 1" >>confdefs.h
fi
-ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_type" "ac_cv_member_struct_utmpx_ut_type" "
+
+ ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_type" "ac_cv_member_struct_utmpx_ut_type" "
# include <sys/types.h>
# include <utmpx.h>
"
if test "x$ac_cv_member_struct_utmpx_ut_type" = xyes; then :
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_TYPE 1" >>confdefs.h
+
+
+fi
+
+ if test "utmpx" = "utmp"; then
+ ac_fn_c_check_member "$LINENO" "struct utmp" "ut_user" "ac_cv_member_struct_utmp_ut_user" "
+# include <sys/types.h>
+# include <utmpx.h>
+
+"
+if test "x$ac_cv_member_struct_utmp_ut_user" = xyes; then :
+
cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMPX_UT_TYPE 1
+#define HAVE_STRUCT_UTMP_UT_USER 1
_ACEOF
fi
- ac_fn_c_check_member "$LINENO" "struct utmpx" "ut_exit.__e_termination" "ac_cv_member_struct_utmpx_ut_exit___e_termination" "
+ fi
+ 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" = xyes; 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
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT___E_TERMINATION 1" >>confdefs.h
+
else
"
if test "x$ac_cv_member_struct_utmpx_ut_exit_e_termination" = xyes; 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
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION 1" >>confdefs.h
+
fi
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 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_id" = xyes; then :
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMP_UT_ID 1
-_ACEOF
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_ID 1" >>confdefs.h
fi
-ac_fn_c_check_member "$LINENO" "struct utmp" "ut_pid" "ac_cv_member_struct_utmp_ut_pid" "
+
+ ac_fn_c_check_member "$LINENO" "struct utmp" "ut_pid" "ac_cv_member_struct_utmp_ut_pid" "
# include <sys/types.h>
# include <utmp.h>
"
if test "x$ac_cv_member_struct_utmp_ut_pid" = xyes; then :
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMP_UT_PID 1
-_ACEOF
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_PID 1" >>confdefs.h
fi
-ac_fn_c_check_member "$LINENO" "struct utmp" "ut_tv" "ac_cv_member_struct_utmp_ut_tv" "
+
+ ac_fn_c_check_member "$LINENO" "struct utmp" "ut_tv" "ac_cv_member_struct_utmp_ut_tv" "
# include <sys/types.h>
# include <utmp.h>
"
if test "x$ac_cv_member_struct_utmp_ut_tv" = xyes; then :
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMP_UT_TV 1
-_ACEOF
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_TV 1" >>confdefs.h
fi
-ac_fn_c_check_member "$LINENO" "struct utmp" "ut_type" "ac_cv_member_struct_utmp_ut_type" "
+
+ ac_fn_c_check_member "$LINENO" "struct utmp" "ut_type" "ac_cv_member_struct_utmp_ut_type" "
# include <sys/types.h>
# include <utmp.h>
"
if test "x$ac_cv_member_struct_utmp_ut_type" = xyes; then :
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_UTMP_UT_TYPE 1
-_ACEOF
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_TYPE 1" >>confdefs.h
fi
-ac_fn_c_check_member "$LINENO" "struct utmp" "ut_user" "ac_cv_member_struct_utmp_ut_user" "
+
+ if test "utmp" = "utmp"; then
+ ac_fn_c_check_member "$LINENO" "struct utmp" "ut_user" "ac_cv_member_struct_utmp_ut_user" "
# include <sys/types.h>
# include <utmp.h>
fi
- ac_fn_c_check_member "$LINENO" "struct utmp" "ut_exit.__e_termination" "ac_cv_member_struct_utmp_ut_exit___e_termination" "
+ 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" = xyes; 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
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT___E_TERMINATION 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" "
"
if test "x$ac_cv_member_struct_utmp_ut_exit_e_termination" = xyes; 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
+
+$as_echo "#define HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION 1" >>confdefs.h
+
+
fi
fi
+
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking type of array argument to getgroups" >&5
utmp_style=LEGACY
-for ac_func in getutxid getutid
+for ac_func in getutsid getutxid getutid
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"
-
-
AC_HEADER_DIRENT
AC_HEADER_STDBOOL
AC_HEADER_MAJOR
-AC_CHECK_HEADERS_ONCE([netgroup.h paths.h spawn.h utmpx.h wordexp.h sys/sockio.h sys/bsdtypes.h sys/select.h sys/stropts.h sys/sysmacros.h sys/syscall.h sys/statvfs.h])
+AC_CHECK_HEADERS_ONCE([netgroup.h paths.h spawn.h wordexp.h sys/sockio.h sys/bsdtypes.h sys/select.h sys/stropts.h sys/sysmacros.h sys/syscall.h sys/statvfs.h])
+AC_CHECK_HEADERS([utmps.h] [utmpx.h], [break])
AC_CHECK_HEADERS([endian.h] [sys/endian.h] [machine/endian.h], [break])
AC_CHECK_HEADERS([procfs.h] [sys/procfs.h], [AC_CHECK_MEMBERS(struct psinfo.pr_ttydev, [AC_CHECK_FUNCS([_ttyname_dev])], [], [AC_INCLUDES_DEFAULT
#ifdef HAVE_PROCFS_H
AC_CHECK_SIZEOF([id_t])
AC_CHECK_SIZEOF([long long])
AC_CHECK_SIZEOF([time_t])
-dnl
-dnl Check for utmp/utmpx struct members.
-dnl We need to have already defined _GNU_SOURCE on glibc which only has
-dnl __e_termination visible when _GNU_SOURCE is *not* defined.
-dnl
-if test $ac_cv_header_utmpx_h = "yes"; then
- 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>
- ])
+if test $ac_cv_header_utmps_h = "yes"; then
+ SUDO_CHECK_UTMP_MEMBERS([utmps])
+elif test $ac_cv_header_utmpx_h = "yes"; then
+ SUDO_CHECK_UTMP_MEMBERS([utmpx])
else
- 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>
- ])
+ SUDO_CHECK_UTMP_MEMBERS([utmp])
fi
dnl
])
utmp_style=LEGACY
-AC_CHECK_FUNCS([getutxid getutid], [utmp_style=POSIX; break])
+AC_CHECK_FUNCS([getutsid getutxid getutid], [utmp_style=POSIX; break])
if test "$utmp_style" = "LEGACY"; then
AC_CHECK_FUNCS([getttyent ttyslot], [break])
AC_CHECK_FUNCS([fseeko])
AH_TEMPLATE(clockid_t, [Define to `int' if <time.h> does not define.])
AH_TEMPLATE(sig_atomic_t, [Define to `int' if <signal.h> does not define.])
AH_TEMPLATE(socklen_t, [Define to `unsigned int' if <sys/socket.h> doesn't define.])
-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'.])
AH_TEMPLATE(HAVE___FUNC__, [Define to 1 if the compiler supports the C99 __func__ variable.])
AH_TEMPLATE(HAVE___INTERPOSE, [Define to 1 if you have dyld with __interpose attribute support.])
AH_TEMPLATE(SUDO_KRB5_INSTANCE, [An instance string to append to the username (separated by a slash) for Kerberos V authentication.])
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 There are three different utmp variants we need to check for.
+dnl SUDO_CHECK_UTMP_MEMBERS(utmp_type)
+dnl
+AC_DEFUN([SUDO_CHECK_UTMP_MEMBERS], [
+ dnl
+ dnl Check for utmp/utmpx/utmps struct members.
+ dnl
+ AC_CHECK_MEMBER([struct $1.ut_id], [
+ AC_DEFINE(HAVE_STRUCT_UTMP_UT_ID, 1, [Define to 1 if `ut_id' is a member of `struct utmp'.])
+ ], [], [
+# include <sys/types.h>
+# include <$1.h>
+ ])
+ AC_CHECK_MEMBER([struct $1.ut_pid], [
+ AC_DEFINE(HAVE_STRUCT_UTMP_UT_PID, 1, [Define to 1 if `ut_pid' is a member of `struct utmp'.])
+ ], [], [
+# include <sys/types.h>
+# include <$1.h>
+ ])
+ AC_CHECK_MEMBER([struct $1.ut_tv], [
+ AC_DEFINE(HAVE_STRUCT_UTMP_UT_TV, 1, [Define to 1 if `ut_tv' is a member of `struct utmp'.])
+ ], [], [
+# include <sys/types.h>
+# include <$1.h>
+ ])
+ AC_CHECK_MEMBER([struct $1.ut_type], [
+ AC_DEFINE(HAVE_STRUCT_UTMP_UT_TYPE, 1, [Define to 1 if `ut_type' is a member of `struct utmp'.])
+ ], [], [
+# include <sys/types.h>
+# include <$1.h>
+ ])
+ dnl
+ dnl Older struct utmp has ut_name instead of ut_user
+ dnl
+ if test "$1" = "utmp"; then
+ AC_CHECK_MEMBERS([struct utmp.ut_user], [], [], [
+# include <sys/types.h>
+# include <$1.h>
+ ])
+ fi
+ dnl
+ dnl Check for ut_exit.__e_termination first, then ut_exit.e_termination
+ dnl We need to have already defined _GNU_SOURCE on glibc which only has
+ dnl __e_termination visible when _GNU_SOURCE is *not* defined.
+ dnl
+ AC_CHECK_MEMBER([struct $1.ut_exit.__e_termination], [
+ AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT, 1, [Define to 1 if `ut_exit' is a member of `struct utmp'.])
+ AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT___E_TERMINATION, 1, [Define to 1 if `ut_exit.__e_termination' is a member of `struct utmp'.])
+ ], [
+ AC_CHECK_MEMBER([struct $1.ut_exit.e_termination], [
+ AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT, 1, [Define to 1 if `ut_exit' is a member of `struct utmp'.])
+ AC_DEFINE(HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION, 1, [Define to 1 if `ut_exit.e_termination' is a member of `struct utmp'.])
+ ], [], [
+# include <sys/types.h>
+# include <$1.h>
+ ])
+ ], [
+# include <sys/types.h>
+# include <$1.h>
+ ])
+])
+
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.
#endif /* HAVE_STRINGS_H */
#include <unistd.h>
#include <time.h>
-#ifdef HAVE_UTMPX_H
+#if defined(HAVE_UTMPS_H)
+# include <utmps.h>
+#elif defined(HAVE_UTMPX_H)
# include <utmpx.h>
#else
# include <utmp.h>
-#endif /* HAVE_UTMPX_H */
+#endif /* HAVE_UTMPS_H */
#ifdef HAVE_GETTTYENT
# include <ttyent.h>
#endif
#include "sudo_exec.h"
/*
- * Simplify handling of utmp vs. utmpx
+ * Simplify handling of different utmp types.
*/
-#if !defined(HAVE_GETUTXID) && defined(HAVE_GETUTID)
-# define getutxline(u) getutline(u)
-# define pututxline(u) pututline(u)
-# define setutxent() setutent()
-# define endutxent() endutent()
-#endif /* !HAVE_GETUTXID && HAVE_GETUTID */
-
-#ifdef HAVE_GETUTXID
+#if defined(HAVE_GETUTSID)
+# define sudo_getutline(u) GETUTSLINE(u)
+# define sudo_pututline(u) PUTUTSLINE(u)
+# define sudo_setutent() SETUTSENT()
+# define sudo_endutent() ENDUTSENT()
+#elif defined(HAVE_GETUTXID)
+# define sudo_getutline(u) getutxline(u)
+# define sudo_pututline(u) pututxline(u)
+# define sudo_setutent() setutxent()
+# define sudo_endutent() endutxent()
+#elif defined(HAVE_GETUTID)
+# define sudo_getutline(u) getutline(u)
+# define sudo_pututline(u) pututline(u)
+# define sudo_setutent() setutent()
+# define sudo_endutent() endutent()
+#endif
+
+#if defined(HAVE_GETUTSID)
+typedef struct utmps sudo_utmp_t;
+#elif defined(HAVE_GETUTXID)
typedef struct utmpx sudo_utmp_t;
#else
typedef struct utmp sudo_utmp_t;
-/* Older systems have ut_name, not us_user */
+/* Older systems have ut_name, not ut_user */
# if !defined(HAVE_STRUCT_UTMP_UT_USER) && !defined(ut_user)
# define ut_user ut_name
# 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)
+/* HP-UX has __e_termination and __e_exit, others may lack the __ */
+#if 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)
+#if defined(HAVE_GETUTSID) || defined(HAVE_GETUTXID) || defined(HAVE_GETUTID)
/*
* Create ut_id from the new ut_line and the old ut_id.
*/
debug_return;
}
-#endif /* HAVE_GETUTXID || HAVE_GETUTID */
+#endif /* HAVE_GETUTSID || HAVE_GETUTXID || HAVE_GETUTID */
/*
* Store time in utmp structure.
debug_decl(utmp_settime, SUDO_DEBUG_UTMP)
if (gettimeofday(&tv, NULL) == 0) {
-#if defined(HAVE_STRUCT_UTMP_UT_TV) || defined(HAVE_STRUCT_UTMPX_UT_TV)
+#if defined(HAVE_STRUCT_UTMP_UT_TV)
ut->ut_tv.tv_sec = tv.tv_sec;
ut->ut_tv.tv_usec = tv.tv_usec;
#else
if (user != NULL)
strncpy(ut_new->ut_user, user, sizeof(ut_new->ut_user));
strncpy(ut_new->ut_line, line, sizeof(ut_new->ut_line));
-#if defined(HAVE_STRUCT_UTMPX_UT_ID) || defined(HAVE_STRUCT_UTMP_UT_ID)
+#if defined(HAVE_STRUCT_UTMP_UT_ID)
utmp_setid(ut_old, ut_new);
#endif
-#if defined(HAVE_STRUCT_UTMPX_UT_PID) || defined(HAVE_STRUCT_UTMP_UT_PID)
+#if defined(HAVE_STRUCT_UTMP_UT_PID)
ut_new->ut_pid = getpid();
#endif
utmp_settime(ut_new);
-#if defined(HAVE_STRUCT_UTMPX_UT_TYPE) || defined(HAVE_STRUCT_UTMP_UT_TYPE)
+#if defined(HAVE_STRUCT_UTMP_UT_TYPE)
ut_new->ut_type = USER_PROCESS;
#endif
debug_return;
* There are two basic utmp file types:
*
* POSIX: sequential access with new entries appended to the end.
- * Manipulated via {get,put}utent()/{get,put}getutxent().
+ * Manipulated via {get,put}[sx]?utent()
*
* Legacy: sparse file indexed by ttyslot() * sizeof(struct utmp)
*/
-#if defined(HAVE_GETUTXID) || defined(HAVE_GETUTID)
+#if defined(HAVE_GETUTSID) || defined(HAVE_GETUTXID) || defined(HAVE_GETUTID)
bool
utmp_login(const char *from_line, const char *to_line, int ttyfd,
const char *user)
/* Strip off /dev/ prefix from line as needed. */
if (strncmp(to_line, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
to_line += sizeof(_PATH_DEV) - 1;
- setutxent();
+ sudo_setutent();
if (from_line != NULL) {
if (strncmp(from_line, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
from_line += sizeof(_PATH_DEV) - 1;
/* Lookup old line. */
memset(&utbuf, 0, sizeof(utbuf));
strncpy(utbuf.ut_line, from_line, sizeof(utbuf.ut_line));
- ut_old = getutxline(&utbuf);
+ ut_old = sudo_getutline(&utbuf);
}
utmp_fill(to_line, user, ut_old, &utbuf);
- if (pututxline(&utbuf) != NULL)
+ if (sudo_pututline(&utbuf) != NULL)
ret = true;
- endutxent();
+ sudo_endutent();
debug_return_bool(ret);
}
memset(&utbuf, 0, sizeof(utbuf));
strncpy(utbuf.ut_line, line, sizeof(utbuf.ut_line));
- if ((ut = getutxline(&utbuf)) != NULL) {
+ if ((ut = sudo_getutline(&utbuf)) != NULL) {
memset(ut->ut_user, 0, sizeof(ut->ut_user));
-# if defined(HAVE_STRUCT_UTMPX_UT_TYPE) || defined(HAVE_STRUCT_UTMP_UT_TYPE)
+# if defined(HAVE_STRUCT_UTMP_UT_TYPE)
ut->ut_type = DEAD_PROCESS;
# endif
-# if defined(HAVE_STRUCT_UTMPX_UT_EXIT) || defined(HAVE_STRUCT_UTMP_UT_EXIT)
+# if defined(HAVE_STRUCT_UTMP_UT_EXIT)
ut->ut_exit.__e_termination = WIFSIGNALED(status) ? WTERMSIG(status) : 0;
ut->ut_exit.__e_exit = WIFEXITED(status) ? WEXITSTATUS(status) : 0;
# endif
utmp_settime(ut);
- if (pututxline(ut) != NULL)
+ if (sudo_pututline(ut) != NULL)
ret = true;
}
debug_return_bool(ret);
}
-#else /* !HAVE_GETUTXID && !HAVE_GETUTID */
+#else /* !HAVE_GETUTSID && !HAVE_GETUTXID && !HAVE_GETUTID */
/*
* Find the slot for the specified line (tty name and file descriptor).
}
}
utmp_fill(to_line, user, ut_old, &utbuf);
-#ifdef HAVE_FSEEKO
+# ifdef HAVE_FSEEKO
if (fseeko(fp, slot * (off_t)sizeof(utbuf), SEEK_SET) == 0) {
-#else
+# else
if (fseek(fp, slot * (long)sizeof(utbuf), SEEK_SET) == 0) {
-#endif
+# endif
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1)
ret = true;
}
# endif
utmp_settime(&utbuf);
/* Back up and overwrite record. */
-#ifdef HAVE_FSEEKO
+# ifdef HAVE_FSEEKO
if (fseeko(fp, (off_t)0 - (off_t)sizeof(utbuf), SEEK_CUR) == 0) {
-#else
+# else
if (fseek(fp, 0L - (long)sizeof(utbuf), SEEK_CUR) == 0) {
-#endif
+# endif
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1)
ret = true;
}
debug_return_bool(ret);
}
-#endif /* HAVE_GETUTXID || HAVE_GETUTID */
+#endif /* HAVE_GETUTSID || HAVE_GETUTXID || HAVE_GETUTID */