summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1995-12-17 21:11:22 +0000
committerphk <phk@FreeBSD.org>1995-12-17 21:11:22 +0000
commitbaca7dc09c90e600a6551ac34435856837a2a2fd (patch)
tree61d7dcedc2def4bb6a26042792d2bba3fd77067b /sys
parent360eaa7e3c653a77886be48b7b1a7fcfee5f396c (diff)
downloadFreeBSD-src-baca7dc09c90e600a6551ac34435856837a2a2fd.zip
FreeBSD-src-baca7dc09c90e600a6551ac34435856837a2a2fd.tar.gz
Add an obscure feature, needed for debugging.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_sysctl.c20
-rw-r--r--sys/sys/sysctl.h5
2 files changed, 14 insertions, 11 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;
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 7e72b9d..4d62887 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)sysctl.h 8.1 (Berkeley) 6/2/93
- * $Id: sysctl.h,v 1.37 1995/12/04 16:48:52 phk Exp $
+ * $Id: sysctl.h,v 1.38 1995/12/09 20:46:06 phk Exp $
*/
#ifndef _SYS_SYSCTL_H_
@@ -75,6 +75,7 @@ struct ctlname {
#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR)
#define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */
+#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */
#define OID_AUTO (-1)
@@ -92,7 +93,7 @@ struct sysctl_req {
void *oldptr;
int oldlen;
int oldidx;
- int (*oldfunc)(struct sysctl_req *, void *, int);
+ int (*oldfunc)(struct sysctl_req *, const void *, int);
void *newptr;
int newlen;
int newidx;
OpenPOWER on IntegriCloud