Add support for ut_exit
This commit is contained in:
@@ -493,6 +493,9 @@
|
||||
/* Define to 1 if the system has the type `struct in6_addr'. */
|
||||
#undef HAVE_STRUCT_IN6_ADDR
|
||||
|
||||
/* Define to 1 if `ut_exit' is a member of `struct utmpx'. */
|
||||
#undef HAVE_STRUCT_UTMPX_UT_EXIT
|
||||
|
||||
/* Define to 1 if `ut_id' is a member of `struct utmpx'. */
|
||||
#undef HAVE_STRUCT_UTMPX_UT_ID
|
||||
|
||||
@@ -505,6 +508,9 @@
|
||||
/* 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 `ut_id' is a member of `struct utmp'. */
|
||||
#undef HAVE_STRUCT_UTMP_UT_ID
|
||||
|
||||
|
26
configure
vendored
26
configure
vendored
@@ -15066,6 +15066,19 @@ 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>
|
||||
@@ -15120,6 +15133,19 @@ cat >>confdefs.h <<_ACEOF
|
||||
_ACEOF
|
||||
|
||||
|
||||
fi
|
||||
ac_fn_c_check_member "$LINENO" "struct utmp" "ut_exit" "ac_cv_member_struct_utmp_ut_exit" "
|
||||
#include <sys/types.h>
|
||||
#include <utmp.h>
|
||||
|
||||
"
|
||||
if test "x$ac_cv_member_struct_utmp_ut_exit" = x""yes; then :
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_STRUCT_UTMP_UT_EXIT 1
|
||||
_ACEOF
|
||||
|
||||
|
||||
fi
|
||||
ac_fn_c_check_member "$LINENO" "struct utmp" "ut_pid" "ac_cv_member_struct_utmp_ut_pid" "
|
||||
#include <sys/types.h>
|
||||
|
@@ -1970,12 +1970,12 @@ 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_pid, struct utmpx.ut_tv, struct utmpx.ut_type], [], [], [
|
||||
AC_CHECK_MEMBERS([struct utmpx.ut_id, struct utmpx.ut_exit, struct utmpx.ut_pid, struct utmpx.ut_tv, struct utmpx.ut_type], [], [], [
|
||||
#include <sys/types.h>
|
||||
#include <utmpx.h>
|
||||
])
|
||||
else
|
||||
AC_CHECK_MEMBERS([struct utmp.ut_id, 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_exit, struct utmp.ut_pid, struct utmp.ut_tv, struct utmp.ut_type, struct utmp.ut_user], [], [], [
|
||||
#include <sys/types.h>
|
||||
#include <utmp.h>
|
||||
])
|
||||
|
@@ -118,7 +118,7 @@ cleanup(int gotsignal)
|
||||
#ifdef HAVE_SELINUX
|
||||
selinux_restore_tty();
|
||||
#endif
|
||||
utmp_logout(slavename); /* XXX - only if CD_SET_UTMP */
|
||||
utmp_logout(slavename, 0); /* XXX - only if CD_SET_UTMP */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -655,7 +655,7 @@ pty_close(struct command_status *cstat)
|
||||
}
|
||||
}
|
||||
}
|
||||
utmp_logout(slavename); /* XXX - only if CD_SET_UTMP */
|
||||
utmp_logout(slavename, cstat->type == CMD_WSTATUS ? cstat->val : 0); /* XXX - only if CD_SET_UTMP */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -45,6 +45,6 @@ extern int signal_pipe[2];
|
||||
/* utmp.c */
|
||||
int utmp_login(const char *from_line, const char *to_line, int ttyfd,
|
||||
const char *user);
|
||||
int utmp_logout(const char *line);
|
||||
int utmp_logout(const char *line, int status);
|
||||
|
||||
#endif /* _SUDO_EXEC_H */
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdio.h>
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
@@ -190,7 +191,7 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd,
|
||||
}
|
||||
|
||||
int
|
||||
utmp_logout(const char *line)
|
||||
utmp_logout(const char *line, int status)
|
||||
{
|
||||
int rval = FALSE;
|
||||
sudo_utmp_t *ut, utbuf;
|
||||
@@ -205,6 +206,10 @@ utmp_logout(const char *line)
|
||||
memset(ut->ut_user, 0, sizeof(ut->ut_user));
|
||||
# if defined(HAVE_STRUCT_UTMPX_UT_TYPE) || 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)
|
||||
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)
|
||||
@@ -308,7 +313,7 @@ done:
|
||||
}
|
||||
|
||||
int
|
||||
utmp_logout(const char *line)
|
||||
utmp_logout(const char *line, int status)
|
||||
{
|
||||
sudo_utmp_t utbuf;
|
||||
int rval = FALSE;
|
||||
|
Reference in New Issue
Block a user