From owner-svn-src-all@freebsd.org Fri Dec 16 01:47:10 2016 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 07F8BC829D3; Fri, 16 Dec 2016 01:47:10 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 CBAF714F4; Fri, 16 Dec 2016 01:47:09 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBG1l9QK016854; Fri, 16 Dec 2016 01:47:09 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBG1l984016853; Fri, 16 Dec 2016 01:47:09 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201612160147.uBG1l984016853@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Fri, 16 Dec 2016 01:47:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310139 - 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.23 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: Fri, 16 Dec 2016 01:47:10 -0000 Author: cem Date: Fri Dec 16 01:47:08 2016 New Revision: 310139 URL: https://svnweb.freebsd.org/changeset/base/310139 Log: Capsicumify last(1) Reviewed by: ed (earlier version), emaste (earlier version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8001 Modified: head/usr.bin/last/last.c Modified: head/usr.bin/last/last.c ============================================================================== --- head/usr.bin/last/last.c Fri Dec 16 01:44:50 2016 (r310138) +++ head/usr.bin/last/last.c Fri Dec 16 01:47:08 2016 (r310139) @@ -40,8 +40,11 @@ static const char sccsid[] = "@(#)last.c __FBSDID("$FreeBSD$"); #include +#include +#include #include +#include #include #include #include @@ -56,7 +59,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define NO 0 /* false/no */ #define YES 1 /* true/yes */ @@ -176,6 +178,19 @@ main(int argc, char *argv[]) usage(); } + if (caph_limit_stdio() < 0) + err(1, "can't limit stdio rights"); + + caph_cache_catpages(); + caph_cache_tzdata(); + + /* Cache UTX database. */ + if (setutxdb(UTXDB_LOG, file) != 0) + err(1, "%s", file != NULL ? file : "(default utx db)"); + + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "cap_enter"); + if (sflag && width == 8) usage(); if (argc) { @@ -213,8 +228,6 @@ wtmp(void) (void)time(&t); /* Load the last entries from the file. */ - if (setutxdb(UTXDB_LOG, file) != 0) - err(1, "%s", file); while ((ut = getutxent()) != NULL) { if (amount % 128 == 0) { buf = realloc(buf, (amount + 128) * sizeof *ut);