Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Aug 2015 08:34:14 +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-10@freebsd.org
Subject:   svn commit: r286952 - stable/10/usr.bin/last
Message-ID:  <201508200834.t7K8YE3V025587@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Thu Aug 20 08:34:13 2015
New Revision: 286952
URL: https://svnweb.freebsd.org/changeset/base/286952

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

Modified:
  stable/10/usr.bin/last/last.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/last/last.c
==============================================================================
--- stable/10/usr.bin/last/last.c	Thu Aug 20 07:41:33 2015	(r286951)
+++ stable/10/usr.bin/last/last.c	Thu Aug 20 08:34:13 2015	(r286952)
@@ -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);



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