diff options
author | 2017-06-28 15:40:54 +0000 | |
---|---|---|
committer | 2017-06-28 15:40:54 +0000 | |
commit | a1ab19720752c38121e115066103953b607466d3 (patch) | |
tree | 19b17b6348cbe1e0453c4f5c26f4ea14e204bb3d /usr.bin/file/file.c | |
parent | resolv_conf_priority() is a function local to kroute.c, no (diff) | |
download | wireguard-openbsd-a1ab19720752c38121e115066103953b607466d3.tar.xz wireguard-openbsd-a1ab19720752c38121e115066103953b607466d3.zip |
perform an initial pledge very early on, and drop tzset to later.
ok nicm brynet
Diffstat (limited to 'usr.bin/file/file.c')
-rw-r--r-- | usr.bin/file/file.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/file/file.c b/usr.bin/file/file.c index 07082aeadda..4e17c26502f 100644 --- a/usr.bin/file/file.c +++ b/usr.bin/file/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.60 2017/06/28 13:37:56 brynet Exp $ */ +/* $OpenBSD: file.c,v 1.61 2017/06/28 15:40:54 deraadt Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org> @@ -104,12 +104,13 @@ main(int argc, char **argv) int opt, idx; char *home, *magicpath; struct passwd *pw; - FILE *magicfp; + FILE *magicfp = NULL; struct magic *m; struct input_file *inf = NULL; size_t len, width = 0; - tzset(); + if (pledge("stdio rpath getpw id", NULL) == -1) + err(1, "pledge"); for (;;) { opt = getopt_long(argc, argv, "bchiLsW", longopts, NULL); @@ -149,7 +150,6 @@ main(int argc, char **argv) } else if (argc == 0) usage(); - magicfp = NULL; if (geteuid() != 0 && !issetugid()) { home = getenv("HOME"); if (home == NULL || *home == '\0') { @@ -183,6 +183,8 @@ main(int argc, char **argv) } } + tzset(); + if (pledge("stdio getpw id", NULL) == -1) err(1, "pledge"); |