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
This commit is contained in:
Ed Schouten 2011-11-07 19:57:42 +00:00
parent 18707510b7
commit f1b61fc829
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=227314

View File

@ -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) {