summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-11 03:08:21 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-11 03:08:21 +0000
commit31a9155b0e47397dc9778dc10d4b29fed247cdf7 (patch)
tree5c39c42ba143282f6ab4a3d0634611c9cb7a6222 /usr.bin
parenta0465c1b0468413af5f3d7f87745305aab589774 (diff)
fix a regression spotted by chris@. the -f and -I arguments fetch process
arguments using kvm_getargs, after the pledge() has been made. someone brave should refactor this, hoisting the argument fetching to between kvm_getprocs() and pledge() - storing the argument data as neccessary. the current situation is also a race -- it fetches the data twice.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/pkill/pkill.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c
index 4cc99b3649f..5df4fd44329 100644
--- a/usr.bin/pkill/pkill.c
+++ b/usr.bin/pkill/pkill.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pkill.c,v 1.37 2015/10/10 14:25:42 deraadt Exp $ */
+/* $OpenBSD: pkill.c,v 1.38 2015/10/11 03:08:20 deraadt Exp $ */
/* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */
/*-
@@ -83,7 +83,6 @@ int pgrep;
int signum = SIGTERM;
int newest;
int oldest;
-char *pledge_choice = "stdio proc";
int quiet;
int inverse;
int longfmt;
@@ -155,7 +154,6 @@ main(int argc, char **argv)
if (strcmp(__progname, "pgrep") == 0) {
action = grepact;
- pledge_choice = "stdio";
pgrep = 1;
} else {
action = killact;
@@ -275,8 +273,15 @@ main(int argc, char **argv)
if (plist == NULL)
errx(STATUS_ERROR, "kvm_getprocs() failed");
- if (pledge(pledge_choice, NULL) == -1)
- err(1, "pledge");
+ if (matchargs == 0 && confirmkill == 0) {
+ if (action == killact) {
+ if (pledge("stdio proc", NULL) == -1)
+ err(1, "pledge");
+ } else if (action == grepact) {
+ if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
+ }
+ }
/*
* Allocate memory which will be used to keep track of the