diff options
author | Sebastien Marie <semarie@cvs.openbsd.org> | 2015-11-04 19:18:22 +0000 |
---|---|---|
committer | Sebastien Marie <semarie@cvs.openbsd.org> | 2015-11-04 19:18:22 +0000 |
commit | 4593ba46dad7a725892e82f011852593e966333e (patch) | |
tree | e7c4ce961bfa02093a21884e5dba59af8502996c /sys/kern | |
parent | 038b6993f2eb486056997bacb3a6abcd0d672397 (diff) |
move /etc/spwd.db blacklist outside PLEDGE_GETPW check.
so that all pledged programs would get it instead of only ones with PLEDGE_GETPW.
ok deraadt@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_pledge.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index c9e3a48a7b0..89a9d6f70dd 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.102 2015/11/03 16:14:14 deraadt Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.103 2015/11/04 19:18:21 semarie Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org> @@ -599,6 +599,18 @@ pledge_namei(struct proc *p, struct nameidata *ni, char *origpath) if (error) return (pledge_fail(p, error, 0)); + /* Blacklisted paths */ + switch (p->p_pledge_syscall) { + case SYS_stat: + case SYS_lstat: + case SYS_fstatat: + case SYS_fstat: + break; + default: + if (strcmp(path, "/etc/spwd.db") == 0) + return (EPERM); + } + /* Detect what looks like a mkstemp(3) family operation */ if ((p->p_p->ps_pledge & PLEDGE_TMPPATH) && (p->p_pledge_syscall == SYS_open) && @@ -641,8 +653,6 @@ pledge_namei(struct proc *p, struct nameidata *ni, char *origpath) /* getpw* and friends need a few files */ if ((ni->ni_pledge == PLEDGE_RPATH) && (p->p_p->ps_pledge & PLEDGE_GETPW)) { - if (strcmp(path, "/etc/spwd.db") == 0) - return (EPERM); if (strcmp(path, "/etc/pwd.db") == 0) return (0); if (strcmp(path, "/etc/group") == 0) |