summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2015-08-20 08:34:13 +0000
committered <ed@FreeBSD.org>2015-08-20 08:34:13 +0000
commit473deb7c5c488a9679f25b85cf5b4855b1bbe509 (patch)
tree250a616b94adb547eb776b37e6510e79f03a6377
parent99883f69b1bd93a4794151ebf0a8d1eb98466375 (diff)
downloadFreeBSD-src-473deb7c5c488a9679f25b85cf5b4855b1bbe509.zip
FreeBSD-src-473deb7c5c488a9679f25b85cf5b4855b1bbe509.tar.gz
MFC r285742:
Unbreak "last reboot". According to the last(1) man page, the "reboot" pseudo-user should print all system reboot entries. This got broken by the utmpx import, as records are typed. Re-add support for "last reboot" by specifically matching against SHUTDOWN_TIME and BOOT_TIME records. PR: 168844 Submitted by: matthew@
-rw-r--r--usr.bin/last/last.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index 945cc41..1db10b3 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
typedef struct arg {
char *name; /* argument */
+#define REBOOT_TYPE -1
#define HOST_TYPE -2
#define TTY_TYPE -3
#define USER_TYPE -4
@@ -180,6 +181,8 @@ main(int argc, char *argv[])
if (argc) {
setlinebuf(stdout);
for (argv += optind; *argv; ++argv) {
+ if (strcmp(*argv, "reboot") == 0)
+ addarg(REBOOT_TYPE, *argv);
#define COMPATIBILITY
#ifdef COMPATIBILITY
/* code to allow "last p5" to work */
@@ -389,6 +392,11 @@ want(struct utmpx *bp)
for (step = arglist; step; step = step->next)
switch(step->type) {
+ case REBOOT_TYPE:
+ if (bp->ut_type == BOOT_TIME ||
+ bp->ut_type == SHUTDOWN_TIME)
+ return (YES);
+ break;
case HOST_TYPE:
if (!strcasecmp(step->name, bp->ut_host))
return (YES);
OpenPOWER on IntegriCloud