aboutsummaryrefslogtreecommitdiff
path: root/lib/libpam/modules/pam_lastlog
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2002-01-24 17:15:04 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2002-01-24 17:15:04 +0000
commit9201dc40bf99fdd879ffc2514149747fd5c0ef95 (patch)
tree907f8a7c6fd8ab59253eba64626f5aefa35034a0 /lib/libpam/modules/pam_lastlog
parent485318d4d86a3c923664ea269c082acfd0296225 (diff)
downloadsrc-9201dc40bf99fdd879ffc2514149747fd5c0ef95.tar.gz
src-9201dc40bf99fdd879ffc2514149747fd5c0ef95.zip
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)
Notes
Notes: svn path=/head/; revision=89748
Diffstat (limited to 'lib/libpam/modules/pam_lastlog')
-rw-r--r--lib/libpam/modules/pam_lastlog/pam_lastlog.86
-rw-r--r--lib/libpam/modules/pam_lastlog/pam_lastlog.c33
2 files changed, 14 insertions, 25 deletions
diff --git a/lib/libpam/modules/pam_lastlog/pam_lastlog.8 b/lib/libpam/modules/pam_lastlog/pam_lastlog.8
index bb01ee047a8b..3ce4f7f30eb5 100644
--- a/lib/libpam/modules/pam_lastlog/pam_lastlog.8
+++ b/lib/libpam/modules/pam_lastlog/pam_lastlog.8
@@ -73,11 +73,7 @@ and
databases.
The
.Fn pam_sm_close_session
-records the end of the session in the
-.Xr utmp 5
-and
-.Xr wtmp 5
-databases.
+function does nothing.
.Sh SEE ALSO
.Xr last 1 ,
.Xr lastlogin 1 ,
diff --git a/lib/libpam/modules/pam_lastlog/pam_lastlog.c b/lib/libpam/modules/pam_lastlog/pam_lastlog.c
index ff7c1d388b49..8db71f2dce45 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);
}