From 5ab9834766ced7aa65f74d6edbaa3bc02a77a637 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 24 Jul 2011 19:19:50 +0000 Subject: [PATCH] MFC r216696 and r216737: 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. git-svn-id: svn://svn.freebsd.org/base/stable/8@224296 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.bin/lock/lock.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c index 3b19e35bb..8448cb0a9 100644 --- a/usr.bin/lock/lock.c +++ b/usr.bin/lock/lock.c @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -102,6 +103,7 @@ main(int argc, char **argv) openlog("lock", LOG_ODELAY, LOG_AUTH); sectimeout = TIMEOUT; + pw = NULL; mypw = NULL; usemine = 0; no_timeout = 0; @@ -137,6 +139,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); @@ -196,7 +200,11 @@ 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 -- 2.45.0