summaryrefslogtreecommitdiffstats
path: root/lib/libpam
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2011-11-07 19:57:42 +0000
committered <ed@FreeBSD.org>2011-11-07 19:57:42 +0000
commit518d5f51525d8e01b4befcc3f659020f16f76d4c (patch)
tree75b52ca326d77fc91655472984ee36b093144af1 /lib/libpam
parentf2e78d375a96a32ee88078d0baaa576822b9aa26 (diff)
downloadFreeBSD-src-518d5f51525d8e01b4befcc3f659020f16f76d4c.zip
FreeBSD-src-518d5f51525d8e01b4befcc3f659020f16f76d4c.tar.gz
Ensure pam_lastlog removes the /dev/ component of the TTY name.
Some consumers of PAM remove the /dev/ component (i.e. login), while others don't (i.e. su). We must ensure that the /dev/ component is removed to ensure that the utmpx entries properly work with tools such as w(1). Discussed with: des MFC after: 1 week
Diffstat (limited to 'lib/libpam')
-rw-r--r--lib/libpam/modules/pam_lastlog/pam_lastlog.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/libpam/modules/pam_lastlog/pam_lastlog.c b/lib/libpam/modules/pam_lastlog/pam_lastlog.c
index 14e47b80..72bb942 100644
--- a/lib/libpam/modules/pam_lastlog/pam_lastlog.c
+++ b/lib/libpam/modules/pam_lastlog/pam_lastlog.c
@@ -47,6 +47,8 @@ __FBSDID("$FreeBSD$");
#define _BSD_SOURCE
#include <sys/time.h>
+
+#include <paths.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
@@ -96,6 +98,9 @@ pam_sm_open_session(pam_handle_t *pamh, int flags,
pam_err = PAM_SERVICE_ERR;
goto err;
}
+ /* Strip /dev/ component. */
+ if (strncmp(tty, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
+ tty = (const char *)tty + sizeof(_PATH_DEV) - 1;
if ((flags & PAM_SILENT) == 0) {
if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0) {
OpenPOWER on IntegriCloud