From owner-svn-src-all@FreeBSD.ORG Mon Nov 7 19:57:42 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C6D2106568A; Mon, 7 Nov 2011 19:57:42 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CE8D8FC0A; Mon, 7 Nov 2011 19:57:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA7Jvgah094136; Mon, 7 Nov 2011 19:57:42 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA7Jvg55094134; Mon, 7 Nov 2011 19:57:42 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201111071957.pA7Jvg55094134@svn.freebsd.org> From: Ed Schouten Date: Mon, 7 Nov 2011 19:57:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227314 - head/lib/libpam/modules/pam_lastlog X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2011 19:57:42 -0000 Author: ed Date: Mon Nov 7 19:57:42 2011 New Revision: 227314 URL: http://svn.freebsd.org/changeset/base/227314 Log: 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 Modified: head/lib/libpam/modules/pam_lastlog/pam_lastlog.c Modified: head/lib/libpam/modules/pam_lastlog/pam_lastlog.c ============================================================================== --- head/lib/libpam/modules/pam_lastlog/pam_lastlog.c Mon Nov 7 19:53:20 2011 (r227313) +++ head/lib/libpam/modules/pam_lastlog/pam_lastlog.c Mon Nov 7 19:57:42 2011 (r227314) @@ -47,6 +47,8 @@ __FBSDID("$FreeBSD$"); #define _BSD_SOURCE #include + +#include #include #include #include @@ -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) {