From owner-svn-src-head@FreeBSD.ORG Sat Dec 25 11:24:28 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2CC9C1065693; Sat, 25 Dec 2010 11:24:28 +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 1C4A18FC0A; Sat, 25 Dec 2010 11:24:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBPBOSS4032163; Sat, 25 Dec 2010 11:24:28 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBPBOR25032161; Sat, 25 Dec 2010 11:24:27 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201012251124.oBPBOR25032161@svn.freebsd.org> From: Ed Schouten Date: Sat, 25 Dec 2010 11:24:27 +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: r216696 - head/usr.bin/lock X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Dec 2010 11:24:28 -0000 Author: ed Date: Sat Dec 25 11:24:27 2010 New Revision: 216696 URL: http://svn.freebsd.org/changeset/base/216696 Log: Slightly improve output of lock(1). - Remove the /dev/ portion of the TTY name. - In case we use lock -p, print the username that was used to obtain the password hash. Modified: head/usr.bin/lock/lock.c Modified: head/usr.bin/lock/lock.c ============================================================================== --- head/usr.bin/lock/lock.c Sat Dec 25 08:51:20 2010 (r216695) +++ head/usr.bin/lock/lock.c Sat Dec 25 11:24:27 2010 (r216696) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -99,6 +100,7 @@ main(int argc, char **argv) openlog("lock", LOG_ODELAY, LOG_AUTH); sectimeout = TIMEOUT; + pw = NULL; mypw = NULL; usemine = 0; no_timeout = 0; @@ -134,6 +136,8 @@ main(int argc, char **argv) gethostname(hostname, sizeof(hostname)); if (!(ttynam = ttyname(0))) errx(1, "not a terminal?"); + if (strncmp(ttynam, _PATH_DEV, strlen(_PATH_DEV)) == 0) + ttynam += strlen(_PATH_DEV); if (gettimeofday(&timval, (struct timezone *)NULL)) err(1, "gettimeofday"); nexttime = timval.tv_sec + (sectimeout * 60); @@ -193,7 +197,10 @@ main(int argc, char **argv) } /* header info */ - (void)printf("lock: %s on %s.", ttynam, hostname); + if (pw != NULL) + (void)printf("lock: %s using %s on %s.", pw->pw_name, ttynam, hostname); + else + (void)printf("lock: %s on %s.", ttynam, hostname); if (no_timeout) (void)printf(" no timeout."); else