From owner-svn-src-all@freebsd.org Tue Jul 21 10:52:07 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 459349A79F6; Tue, 21 Jul 2015 10:52:07 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 31C77144A; Tue, 21 Jul 2015 10:52:07 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6LAq6eW002182; Tue, 21 Jul 2015 10:52:06 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6LAq6qQ002181; Tue, 21 Jul 2015 10:52:06 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201507211052.t6LAq6qQ002181@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Tue, 21 Jul 2015 10:52:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285742 - head/usr.bin/last X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2015 10:52:07 -0000 Author: ed Date: Tue Jul 21 10:52:05 2015 New Revision: 285742 URL: https://svnweb.freebsd.org/changeset/base/285742 Log: 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@ MFC after: 1 month Modified: head/usr.bin/last/last.c Modified: head/usr.bin/last/last.c ============================================================================== --- head/usr.bin/last/last.c Tue Jul 21 09:57:13 2015 (r285741) +++ head/usr.bin/last/last.c Tue Jul 21 10:52:05 2015 (r285742) @@ -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);