summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokan <okan@openbsd.org>2014-04-22 12:36:36 +0000
committerokan <okan@openbsd.org>2014-04-22 12:36:36 +0000
commitc1663df07620c702288550d10fbc39561ddf30cd (patch)
treed21f6e3373bada22f4779662ce30f9c4bc55bba8
parentifa_ifwithroute() is the only magic place where an AF_LINK sockaddr (diff)
downloadwireguard-openbsd-c1663df07620c702288550d10fbc39561ddf30cd.tar.xz
wireguard-openbsd-c1663df07620c702288550d10fbc39561ddf30cd.zip
Instead of special casing ftpd, uucpd and others that may have entries
in wtmp, go the other way and exclude entries we know ('console' and 'tty') from pid stripping, then strip the rest. idea, feedback and ok millert@
-rw-r--r--usr.bin/last/last.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index da20fa5d909..bd1682fc72e 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: last.c,v 1.41 2014/04/17 14:49:11 okan Exp $ */
+/* $OpenBSD: last.c,v 1.42 2014/04/22 12:36:36 okan Exp $ */
/* $NetBSD: last.c,v 1.6 1994/12/24 16:49:02 cgd Exp $ */
/*
@@ -414,11 +414,19 @@ want(struct utmp *bp, int check)
if (check) {
/*
- * when ftp logs in over a network, the entry in
- * the utmp file is the name plus its process id.
+ * some entries, such as ftp and uucp, will
+ * include process name plus id; exclude entries
+ * that start with 'console' and 'tty' from
+ * having the process id stripped.
*/
- if (!strncmp(bp->ut_line, "ftp", sizeof("ftp") - 1))
- bp->ut_line[3] = '\0';
+ if ((strncmp(bp->ut_line, "console", strlen("console")) != 0) &&
+ (strncmp(bp->ut_line, "tty", strlen("tty")) != 0)) {
+ char *s;
+ for (s = bp->ut_line;
+ *s != '\0' && !isdigit((unsigned char)*s); s++)
+ ;
+ *s = '\0';
+ }
}
if (snaptime) /* if snaptime is set, return NO */