Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Feb 2012 17:50:39 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r230952 - stable/9/lib/libpam/modules/pam_lastlog
Message-ID:  <201202031750.q13HodDw097658@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Fri Feb  3 17:50:39 2012
New Revision: 230952
URL: http://svn.freebsd.org/changeset/base/230952

Log:
  MFC r227314:
  
    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).

Modified:
  stable/9/lib/libpam/modules/pam_lastlog/pam_lastlog.c
Directory Properties:
  stable/9/lib/libpam/   (props changed)

Modified: stable/9/lib/libpam/modules/pam_lastlog/pam_lastlog.c
==============================================================================
--- stable/9/lib/libpam/modules/pam_lastlog/pam_lastlog.c	Fri Feb  3 17:36:32 2012	(r230951)
+++ stable/9/lib/libpam/modules/pam_lastlog/pam_lastlog.c	Fri Feb  3 17:50:39 2012	(r230952)
@@ -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, 
 		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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202031750.q13HodDw097658>