summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorSebastien Marie <semarie@cvs.openbsd.org>2016-03-11 05:57:17 +0000
committerSebastien Marie <semarie@cvs.openbsd.org>2016-03-11 05:57:17 +0000
commitf1c3da4377b09d9813c64e82b194a657fb6b366a (patch)
tree8d56eac02c7ec417b92a0fd07c5e92bbcd2dc6da /sys
parentc679d0a5b9018c8f5a8e56b9d4bae8d912077279 (diff)
pledge: define the meaning of passing NULL to one arguments of pledge(2) as "I
don't want to change the current value" it changes only the `request' argument behaviour when NULL is passed: previously it was traited as "" was passed. with help from jmc@ for man-page OK tb@ on previous version
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_pledge.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c
index e682b56b7b3..09d87a66ff7 100644
--- a/sys/kern/kern_pledge.c
+++ b/sys/kern/kern_pledge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_pledge.c,v 1.149 2016/02/17 21:52:06 millert Exp $ */
+/* $OpenBSD: kern_pledge.c,v 1.150 2016/03/11 05:57:16 semarie Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -418,20 +418,20 @@ sys_pledge(struct proc *p, void *v, register_t *retval)
flags |= f;
}
free(rbuf, M_TEMP, MAXPATHLEN);
- }
- if (flags & ~PLEDGE_USERSET)
- return (EINVAL);
+ if (flags & ~PLEDGE_USERSET)
+ return (EINVAL);
- if ((p->p_p->ps_flags & PS_PLEDGE)) {
- /* Already pledged, only allow reductions */
- if (((flags | p->p_p->ps_pledge) & PLEDGE_USERSET) !=
- (p->p_p->ps_pledge & PLEDGE_USERSET)) {
- return (EPERM);
- }
+ if ((p->p_p->ps_flags & PS_PLEDGE)) {
+ /* Already pledged, only allow reductions */
+ if (((flags | p->p_p->ps_pledge) & PLEDGE_USERSET) !=
+ (p->p_p->ps_pledge & PLEDGE_USERSET)) {
+ return (EPERM);
+ }
- flags &= p->p_p->ps_pledge;
- flags &= PLEDGE_USERSET; /* Relearn _ACTIVE */
+ flags &= p->p_p->ps_pledge;
+ flags &= PLEDGE_USERSET; /* Relearn _ACTIVE */
+ }
}
if (SCARG(uap, paths)) {
@@ -556,8 +556,11 @@ sys_pledge(struct proc *p, void *v, register_t *retval)
#endif
}
- p->p_p->ps_pledge = flags;
- p->p_p->ps_flags |= PS_PLEDGE;
+ if (SCARG(uap, request)) {
+ p->p_p->ps_pledge = flags;
+ p->p_p->ps_flags |= PS_PLEDGE;
+ }
+
return (0);
}