aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2016-12-16 01:47:08 +0000
committerConrad Meyer <cem@FreeBSD.org>2016-12-16 01:47:08 +0000
commit941e22d17d46fefc701405faca9124c39f299d92 (patch)
tree9c7ea21afb51caff07b038c96de7ae70b4fd863d /usr.bin
parentec055aeff50e6b6311e3307fed436a89d01085da (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/last/last.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index 1db10b399dfa4..1f31ae3c79d30 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -40,8 +40,11 @@ static const char sccsid[] = "@(#)last.c 8.2 (Berkeley) 4/2/94";
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/capsicum.h>
+#include <sys/queue.h>
#include <sys/stat.h>
+#include <capsicum_helpers.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
@@ -56,7 +59,6 @@ __FBSDID("$FreeBSD$");
#include <timeconv.h>
#include <unistd.h>
#include <utmpx.h>
-#include <sys/queue.h>
#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);