summaryrefslogtreecommitdiff
path: root/usr.bin/nice/nice.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-19 18:53:36 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-19 18:53:36 +0000
commitee52efdcd8d0ed8cac1d0be8b9a10f0a72dfca41 (patch)
tree4bcba19c63a4f56b7168929ff2a37e8732087fc7 /usr.bin/nice/nice.c
parent0fd6c8662f5f990b93d166940679f3c145233581 (diff)
pledge "stdio exec proc" early on, setpriority, then pledge "stdio exec"
from Theo Buehler
Diffstat (limited to 'usr.bin/nice/nice.c')
-rw-r--r--usr.bin/nice/nice.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/nice/nice.c b/usr.bin/nice/nice.c
index e992069c745..d48e067e181 100644
--- a/usr.bin/nice/nice.c
+++ b/usr.bin/nice/nice.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nice.c,v 1.14 2014/02/13 20:51:10 tedu Exp $ */
+/* $OpenBSD: nice.c,v 1.15 2015/10/19 18:53:35 deraadt Exp $ */
/* $NetBSD: nice.c,v 1.9 1995/08/31 23:30:58 jtc Exp $ */
/*
@@ -53,6 +53,9 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
+ if (pledge("stdio exec proc", NULL) == -1)
+ err(1, "pledge");
+
/* handle obsolete -number syntax */
if (argc > 1 && argv[1][0] == '-' &&
isdigit((unsigned char)argv[1][1])) {
@@ -70,7 +73,6 @@ main(int argc, char *argv[])
if (errstr)
errx(1, "increment is %s", errstr);
break;
- case '?':
default:
usage();
break;
@@ -84,16 +86,16 @@ main(int argc, char *argv[])
errno = 0;
prio += getpriority(PRIO_PROCESS, 0);
- if (errno) {
+ if (errno)
err(1, "getpriority");
- /* NOTREACHED */
- }
if (setpriority(PRIO_PROCESS, 0, prio))
warn("setpriority");
+ if (pledge("stdio exec", NULL) == -1)
+ err(1, "pledge");
+
execvp(argv[0], &argv[0]);
err((errno == ENOENT) ? 127 : 126, "%s", argv[0]);
- /* NOTREACHED */
}
static void