diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2002-04-20 16:44:32 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2002-04-20 16:44:32 +0000 |
commit | 1583027008f6787e5094ad2cce3199ffe6410fab (patch) | |
tree | 7c145f5d17a87446a1c5175ca021a6e2a8172f5b /lib/libpam | |
parent | d1fef1792c1cf2fd37720298bab60f29f315e56c (diff) | |
download | src-1583027008f6787e5094ad2cce3199ffe6410fab.tar.gz src-1583027008f6787e5094ad2cce3199ffe6410fab.zip |
Strip /dev/ from tty name, and clean up the "last login" printout.
Sponsored by: DARPA, NAI Labs
Notes
Notes:
svn path=/head/; revision=95135
Diffstat (limited to 'lib/libpam')
-rw-r--r-- | lib/libpam/modules/pam_lastlog/pam_lastlog.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/libpam/modules/pam_lastlog/pam_lastlog.c b/lib/libpam/modules/pam_lastlog/pam_lastlog.c index fea8154c9747..731f895bd5b8 100644 --- a/lib/libpam/modules/pam_lastlog/pam_lastlog.c +++ b/lib/libpam/modules/pam_lastlog/pam_lastlog.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include <fcntl.h> #include <libutil.h> +#include <paths.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> @@ -90,6 +91,10 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, return (pam_err); if (tty == NULL) return (PAM_SERVICE_ERR); + if (strncmp(tty, _PATH_DEV, strlen(_PATH_DEV))) + tty += strlen(_PATH_DEV); + if (*tty == '\0') + return (PAM_SERVICE_ERR); fd = open(_PATH_LASTLOG, O_RDWR|O_CREAT, 0644); if (fd == -1) { @@ -104,15 +109,14 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, if (lseek(fd, llpos, L_SET) != llpos) goto file_err; if ((flags & PAM_SILENT) == 0) { - if (read(fd, &ll, sizeof(ll)) == sizeof(ll) && - ll.ll_time != 0) { - pam_info(pamh, "Last login: %.*s ", 24 - 5, - ctime(&ll.ll_time)); + if (read(fd, &ll, sizeof ll) == sizeof ll && ll.ll_time != 0) { if (*ll.ll_host != '\0') - pam_info(pamh, "from %.*s\n", + pam_info(pamh, "Last login: %.*s from %.*s", + 24 - 5, ctime(&ll.ll_time), (int)sizeof(ll.ll_host), ll.ll_host); else - pam_info(pamh, "on %.*s\n", + pam_info(pamh, "Last login: %.*s on %.*s", + 24 - 5, ctime(&ll.ll_time), (int)sizeof(ll.ll_line), ll.ll_line); } if (lseek(fd, llpos, L_SET) != llpos) |