Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Jul 2011 19:19:50 +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-8@freebsd.org
Subject:   svn commit: r224296 - stable/8/usr.bin/lock
Message-ID:  <201107241919.p6OJJomX021241@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Sun Jul 24 19:19:50 2011
New Revision: 224296
URL: http://svn.freebsd.org/changeset/base/224296

Log:
  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.

Modified:
  stable/8/usr.bin/lock/lock.c
Directory Properties:
  stable/8/usr.bin/lock/   (props changed)

Modified: stable/8/usr.bin/lock/lock.c
==============================================================================
--- stable/8/usr.bin/lock/lock.c	Sun Jul 24 19:13:54 2011	(r224295)
+++ stable/8/usr.bin/lock/lock.c	Sun Jul 24 19:19:50 2011	(r224296)
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
 #include <err.h>
 #include <ctype.h>
 #include <errno.h>
+#include <paths.h>
 #include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -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



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