diff options
author | phk <phk@FreeBSD.org> | 1995-12-17 21:11:22 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-12-17 21:11:22 +0000 |
commit | baca7dc09c90e600a6551ac34435856837a2a2fd (patch) | |
tree | 61d7dcedc2def4bb6a26042792d2bba3fd77067b /sys/kern/kern_sysctl.c | |
parent | 360eaa7e3c653a77886be48b7b1a7fcfee5f396c (diff) | |
download | FreeBSD-src-baca7dc09c90e600a6551ac34435856837a2a2fd.zip FreeBSD-src-baca7dc09c90e600a6551ac34435856837a2a2fd.tar.gz |
Add an obscure feature, needed for debugging.
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r-- | sys/kern/kern_sysctl.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 58b5d12..a06b214 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 - * $Id: kern_sysctl.c,v 1.56 1995/12/07 12:46:52 davidg Exp $ + * $Id: kern_sysctl.c,v 1.57 1995/12/14 08:31:36 phk Exp $ */ #include <sys/param.h> @@ -563,7 +563,7 @@ sysctl_sysctl_name2oid SYSCTL_HANDLER_ARGS return (error); } -SYSCTL_PROC(_sysctl, 3, name2oid, CTLFLAG_RW, 0, 0, +SYSCTL_PROC(_sysctl, 3, name2oid, CTLFLAG_RW|CTLFLAG_ANYBODY, 0, 0, sysctl_sysctl_name2oid, "I", ""); static int @@ -698,7 +698,7 @@ sysctl_handle_opaque SYSCTL_HANDLER_ARGS * XXX: rather untested at this point */ static int -sysctl_old_kernel(struct sysctl_req *req, void *p, int l) +sysctl_old_kernel(struct sysctl_req *req, const void *p, int l) { int i = 0; @@ -715,7 +715,7 @@ sysctl_old_kernel(struct sysctl_req *req, void *p, int l) } static int -sysctl_new_kernel(struct sysctl_req *req, void *p, int l) +sysctl_new_kernel(struct sysctl_req *req, const void *p, int l) { if (!req->newptr) return 0; @@ -730,7 +730,7 @@ sysctl_new_kernel(struct sysctl_req *req, void *p, int l) * Transfer function to/from user space. */ static int -sysctl_old_user(struct sysctl_req *req, void *p, int l) +sysctl_old_user(struct sysctl_req *req, const void *p, int l) { int error = 0, i = 0; @@ -807,11 +807,16 @@ sysctl_root SYSCTL_HANDLER_ARGS } return ENOENT; found: - /* If writing isn't allowed */ if (req->newptr && !((*oidpp)->oid_kind & CTLFLAG_WR)) return (EPERM); + /* Most likely only root can write */ + if (!((*oidpp)->oid_kind & CTLFLAG_ANYBODY) && + req->newptr && req->p && + (i = suser(req->p->p_ucred, &req->p->p_acflag))) + return (i); + if (!(*oidpp)->oid_handler) return EINVAL; @@ -877,9 +882,6 @@ userland_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *old req.p = p; - if (new != NULL && (error = suser(p->p_ucred, &p->p_acflag))) - return (error); - if (oldlenp) { if (inkernel) { req.oldlen = *oldlenp; |