Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Dec 1998 22:42:25 -0800 (PST)
From:      Don Lewis <Don.Lewis@tsc.tdk.com>
To:        hackers@FreeBSD.ORG
Subject:   restricting sysctl -w when securelevel > 0
Message-ID:  <199812120642.WAA21633@salsa.gv.tsc.tdk.com>

next in thread | raw e-mail | index | archive | help

I want to add some security related sysctl knobs and I don't want them
to be changeable when securelevel > 0.  Rather than using SYSCTL_PROC
and defining several very similar handlers, I think it would be better to
add a generic way of limiting write access when securelevel > 0.

Comments?

--- kern/kern_sysctl.c.orig	Tue Dec  8 20:40:52 1998
+++ kern/kern_sysctl.c	Fri Dec 11 22:27:10 1998
@@ -804,7 +804,8 @@
 	return ENOENT;
 found:
 	/* If writing isn't allowed */
-	if (req->newptr && !((*oidpp)->oid_kind & CTLFLAG_WR))
+	if (req->newptr && (!((*oidpp)->oid_kind & CTLFLAG_WR) ||
+	    (((*oidpp)->oid_kind & CTLFLAG_SECURE) && securelevel > 0)))
 		return (EPERM);
 
 	/* Most likely only root can write */
--- sys/sysctl.h.orig	Sat Sep  5 19:23:09 1998
+++ sys/sysctl.h	Fri Dec 11 22:24:37 1998
@@ -78,6 +78,7 @@
 #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 CTLFLAG_SECURE	0x08000000	/* Permit set only if securelevel<=0 */
 
 /*
  * USE THIS instead of a hardwired number from the categories below

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812120642.WAA21633>