summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-12-25 11:24:27 +0000
committered <ed@FreeBSD.org>2010-12-25 11:24:27 +0000
commited90afaa23c5496803cf8308eca8572275ff4c9e (patch)
tree2d50ba4b2d1b56e4ed3e8ee19bdc772f9a49f3a0 /usr.bin
parentcefd8b2a41e4b4bf7a16e2dea1e0c719a30d56a3 (diff)
downloadFreeBSD-src-ed90afaa23c5496803cf8308eca8572275ff4c9e.zip
FreeBSD-src-ed90afaa23c5496803cf8308eca8572275ff4c9e.tar.gz
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.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/lock/lock.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c
index 4107f32..f283fa6 100644
--- a/usr.bin/lock/lock.c
+++ b/usr.bin/lock/lock.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <ctype.h>
#include <errno.h>
+#include <paths.h>
#include <pwd.h>
#include <stdint.h>
#include <stdio.h>
@@ -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
OpenPOWER on IntegriCloud