diff options
author | des <des@FreeBSD.org> | 2002-04-20 16:44:32 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2002-04-20 16:44:32 +0000 |
commit | dc33f36d34bfebcf9ef7fec00121328942ba7184 (patch) | |
tree | 7c145f5d17a87446a1c5175ca021a6e2a8172f5b /lib/libpam/modules | |
parent | 69657315370005307a6b70440e55dbd184b3c6db (diff) | |
download | FreeBSD-src-dc33f36d34bfebcf9ef7fec00121328942ba7184.zip FreeBSD-src-dc33f36d34bfebcf9ef7fec00121328942ba7184.tar.gz |
Strip /dev/ from tty name, and clean up the "last login" printout.
Sponsored by: DARPA, NAI Labs
Diffstat (limited to 'lib/libpam/modules')
-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 fea8154..731f895 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) |