summaryrefslogtreecommitdiffstats
path: root/lib/libpam/modules/pam_lastlog/pam_lastlog.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2002-01-24 17:15:04 +0000
committerdes <des@FreeBSD.org>2002-01-24 17:15:04 +0000
commit30cd8777d2844a2daeeb190d92f10e40785201f2 (patch)
tree907f8a7c6fd8ab59253eba64626f5aefa35034a0 /lib/libpam/modules/pam_lastlog/pam_lastlog.c
parentded7ff77e43b99e4f0599c910fe90f9292a49d1c (diff)
downloadFreeBSD-src-30cd8777d2844a2daeeb190d92f10e40785201f2.zip
FreeBSD-src-30cd8777d2844a2daeeb190d92f10e40785201f2.tar.gz
Change the order in which pam_sm_open_session() updates the logs. This
doesn't really make any difference, except it matches wtmp(5) better. Don't do anything in pam_sm_close_session(); init(8) will take care of utmp and wtmp when the tty is released. Clearing them here would make it possible to create a ghost session by logging in, running 'login -f $USER' and exiting the subshell. Sponsored by: DARPA, NAI Labs (but the bugs are all mine)
Diffstat (limited to 'lib/libpam/modules/pam_lastlog/pam_lastlog.c')
-rw-r--r--lib/libpam/modules/pam_lastlog/pam_lastlog.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/lib/libpam/modules/pam_lastlog/pam_lastlog.c b/lib/libpam/modules/pam_lastlog/pam_lastlog.c
index ff7c1d3..8db71f2 100644
--- a/lib/libpam/modules/pam_lastlog/pam_lastlog.c
+++ b/lib/libpam/modules/pam_lastlog/pam_lastlog.c
@@ -155,18 +155,6 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
}
/*
- * Record session in utmp(5) and wtmp(5).
- */
- bzero(&utmp, sizeof(utmp));
- time(&utmp.ut_time);
- /* note: does not need to be NUL-terminated */
- strncpy(utmp.ut_name, user, sizeof(utmp.ut_name));
- if (rhost != NULL)
- strncpy(utmp.ut_host, rhost, sizeof(utmp.ut_host));
- (void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
- login(&utmp);
-
- /*
* Record session in lastlog(5).
*/
llpos = (off_t)(pwd->pw_uid * sizeof(ll));
@@ -209,6 +197,19 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
goto file_err;
PAM_LOG("Login recorded in %s", _PATH_LASTLOG);
+
+ /*
+ * Record session in utmp(5) and wtmp(5).
+ */
+ bzero(&utmp, sizeof(utmp));
+ time(&utmp.ut_time);
+ /* note: does not need to be NUL-terminated */
+ strncpy(utmp.ut_name, user, sizeof(utmp.ut_name));
+ if (rhost != NULL)
+ strncpy(utmp.ut_host, rhost, sizeof(utmp.ut_host));
+ (void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
+ login(&utmp);
+
PAM_RETURN(PAM_IGNORE);
file_err:
@@ -221,19 +222,11 @@ PAM_EXTERN int
pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
{
struct options options;
- const char *tty;
- int pam_err;
pam_std_option(&options, NULL, argc, argv);
PAM_LOG("Options processed");
- pam_err = pam_get_item(pamh, PAM_TTY, (const void **)&tty);
- if (pam_err != PAM_SUCCESS)
- PAM_RETURN(pam_err);
- if (tty != NULL)
- logout(tty);
-
PAM_RETURN(PAM_SUCCESS);
}
OpenPOWER on IntegriCloud