diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2014-05-04 05:03:27 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2014-05-04 05:03:27 +0000 |
commit | 4381d904c0f58383676cc76eba40ea416585bcf0 (patch) | |
tree | a46faba79fe283e769946799fa5e59b9ea7544c6 /sys/kern/kern_sysctl.c | |
parent | e75387b5443d933b7afda70735259944f64e39d2 (diff) |
Add PS_SYSTEM, the process-level mirror of the thread-level P_SYSTEM,
and FORK_SYSTEM as a flag to set them. This eliminates needing to
peek into other processes threads in various places. Inspired by NetBSD
ok miod@ matthew@
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r-- | sys/kern/kern_sysctl.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 2d07834f844..e1950f3d766 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.247 2014/05/03 23:30:04 guenther Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.248 2014/05/04 05:03:26 guenther Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1252,7 +1252,7 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep, * processes */ pp = pr->ps_mainproc; - if ((pp->p_flag & P_SYSTEM) || (pr->ps_flags & PS_EXITING) + if ((pr->ps_flags & (PS_SYSTEM | PS_EXITING)) || pp->p_stat == SIDL || pp->p_stat == SZOMB) continue; if (arg > 0 && pp->p_pid != (pid_t)arg) { @@ -1284,7 +1284,7 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep, * skip system, exiting, embryonic and undead * processes */ - if ((pp->p_flag & P_SYSTEM) || (pr->ps_flags & PS_EXITING) + if ((pr->ps_flags & (PS_SYSTEM | PS_EXITING)) || pp->p_stat == SIDL || pp->p_stat == SZOMB) continue; if (arg >= 0 && pp->p_ucred->cr_uid != (uid_t)arg) { @@ -1418,7 +1418,7 @@ again: break; case KERN_PROC_ALL: - if (p->p_flag & P_SYSTEM) + if (pr->ps_flags & PS_SYSTEM) continue; break; @@ -1584,11 +1584,8 @@ sysctl_proc_args(int *name, u_int namelen, void *oldp, size_t *oldlenp, return (0); } - if (vp->p_flag & P_SYSTEM) - return (EINVAL); - - /* Exiting - don't bother, it will be gone soon anyway */ - if (vp->p_p->ps_flags & PS_EXITING) + /* Either system process or exiting/zombie */ + if (vp->p_p->ps_flags & (PS_SYSTEM | PS_EXITING)) return (EINVAL); /* Execing - danger. */ @@ -1774,15 +1771,12 @@ sysctl_proc_cwd(int *name, u_int namelen, void *oldp, size_t *oldlenp, return (0); } - if (findp->p_flag & P_SYSTEM) - return (EINVAL); - - /* Exiting - don't bother, it will be gone soon anyway */ - if (findp->p_p->ps_flags & PS_EXITING) + /* Either system process or exiting/zombie */ + if (findp->p_p->ps_flags & (PS_SYSTEM | PS_EXITING)) return (EINVAL); /* Only owner or root can get cwd */ - if (findp->p_ucred->cr_uid != cp->p_ucred->cr_uid && + if (findp->p_p->ps_ucred->cr_uid != cp->p_ucred->cr_uid && (error = suser(cp, 0)) != 0) return (error); |