From bf53a76ea1b5a1f8151c0cf354b5302ee0321ca3 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Thu, 29 Jun 2023 16:09:43 +0100 Subject: [PATCH] Remove wtmp updating code --- instfiles/pam.d/xrdp-sesman.arch | 4 ++- instfiles/pam.d/xrdp-sesman.debian | 2 ++ instfiles/pam.d/xrdp-sesman.redhat | 3 +++ instfiles/pam.d/xrdp-sesman.suse | 3 +++ instfiles/pam.d/xrdp-sesman.system | 4 +++ sesman/sesexec/sessionrecord.c | 42 +++++------------------------- 6 files changed, 21 insertions(+), 37 deletions(-) diff --git a/instfiles/pam.d/xrdp-sesman.arch b/instfiles/pam.d/xrdp-sesman.arch index 2763612e..7b4a3616 100644 --- a/instfiles/pam.d/xrdp-sesman.arch +++ b/instfiles/pam.d/xrdp-sesman.arch @@ -1,4 +1,3 @@ -#%PAM-1.0 auth include system-remote-login -auth optional pam_gnome_keyring.so -auth optional pam_kwallet5.so @@ -8,5 +7,8 @@ account include system-remote-login password include system-remote-login session include system-remote-login +# For wtmp/lastlog support uncomment one of the following lines:- +#session optional pam_lastlog.so quiet +#session optional pam_lastlog2.so silent -session optional pam_gnome_keyring.so auto_start -session optional pam_kwallet5.so auto_start diff --git a/instfiles/pam.d/xrdp-sesman.debian b/instfiles/pam.d/xrdp-sesman.debian index a85ce751..2dd2ecb8 100644 --- a/instfiles/pam.d/xrdp-sesman.debian +++ b/instfiles/pam.d/xrdp-sesman.debian @@ -11,6 +11,8 @@ auth required pam_env.so readenv=1 envfile=/etc/default/locale # Set the loginuid process attribute. session required pam_loginuid.so +# Update wtmp/lastlog +session optional pam_lastlog.so quiet @include common-session -session optional pam_gnome_keyring.so auto_start -session optional pam_kwallet5.so auto_start diff --git a/instfiles/pam.d/xrdp-sesman.redhat b/instfiles/pam.d/xrdp-sesman.redhat index aa444ad6..02c0ed97 100644 --- a/instfiles/pam.d/xrdp-sesman.redhat +++ b/instfiles/pam.d/xrdp-sesman.redhat @@ -4,5 +4,8 @@ account include password-auth # Set the loginuid process attribute. session required pam_loginuid.so +# Update wtmp/lastlog +session optional pam_lastlog.so quiet + session include password-auth password include password-auth diff --git a/instfiles/pam.d/xrdp-sesman.suse b/instfiles/pam.d/xrdp-sesman.suse index 44e5b24e..87d40780 100644 --- a/instfiles/pam.d/xrdp-sesman.suse +++ b/instfiles/pam.d/xrdp-sesman.suse @@ -4,5 +4,8 @@ account include common-account # Set the loginuid process attribute. session required pam_loginuid.so +# Update lastlog database +session optional pam_lastlog2.so silent + session include common-session password include common-password diff --git a/instfiles/pam.d/xrdp-sesman.system b/instfiles/pam.d/xrdp-sesman.system index 5025a0f9..172360c6 100644 --- a/instfiles/pam.d/xrdp-sesman.system +++ b/instfiles/pam.d/xrdp-sesman.system @@ -2,4 +2,8 @@ auth include system-auth account include system-auth password include system-auth + +# For wtmp/lastlog support uncomment one of the following lines:- +#session optional pam_lastlog.so quiet +#session optional pam_lastlog2.so silent session include system-auth diff --git a/sesman/sesexec/sessionrecord.c b/sesman/sesexec/sessionrecord.c index 7f4c56ee..f50bf790 100644 --- a/sesman/sesexec/sessionrecord.c +++ b/sesman/sesexec/sessionrecord.c @@ -19,7 +19,10 @@ /** * * @file sessionrecord.c - * @brief utmp/wtmp handling code + * @brief utmp handling code + * + * wtmp/lastlog/btmp is handled by PAM or (on FreeBSD) UTX + * * Idea: Only implement actual utmp, i.e. utmpx for 99%. * See http://80386.nl/unix/utmpx/ */ @@ -28,7 +31,6 @@ #include #endif -#include #include #include #include @@ -52,34 +54,6 @@ typedef struct utmp _utmp; #define XRDP_LINE_FORMAT "xrdp:%d" -/* - * update the wtmp file on UTMPX platforms (~ Linux) - * but no on FreeBSD : FreeBSD uses utx to do the job - */ -#ifdef HAVE_UTMPX_H -#if !defined(__FreeBSD__) -static inline void -_updwtmp(const _utmp *ut) -{ - updwtmpx(_PATH_WTMP, ut); -} -#else -static inline void -_updwtmp(const _utmp ut) -{ -} -#endif -#elif defined(HAVE_UTMP_H) -/* Does such system still exist ? */ -_updwtmp(const _utmp *ut) -{ - log_message(LOG_LEVEL_DEBUG, - "Unsupported system: HAVE_UTMP_H defined without HAVE_UTMPX_H"); - updwtmp("/var/log/wtmp", ut); -} -#endif - - /* * Prepare the utmp struct and write it. * this can handle login and logout at once with the 'state' parameter @@ -109,10 +83,6 @@ add_xtmp_entry(int pid, const char *display_id, const char *user, const char *rh pututxline(&ut); /* closes utmp */ endutxent(); - - /* update the wtmp file if needed */ - - _updwtmp(&ut); } void @@ -121,7 +91,7 @@ utmp_login(int pid, int display, const char *user, const char *rhostname) char str_display[16]; log_message(LOG_LEVEL_DEBUG, - "adding login info for utmp/wtmp: %d - %d - %s - %s", + "adding login info for utmp: %d - %d - %s - %s", pid, display, user, rhostname); g_snprintf(str_display, 15, XRDP_LINE_FORMAT, display); @@ -134,7 +104,7 @@ utmp_logout(int pid, int display, const char *user, const char *rhostname) char str_display[16]; log_message(LOG_LEVEL_DEBUG, - "adding logout info for utmp/wtmp: %d - %d - %s - %s", + "adding logout info for utmp: %d - %d - %s - %s", pid, display, user, rhostname); g_snprintf(str_display, 15, XRDP_LINE_FORMAT, display);