Deleted Added
full compact
kern_sysctl.c (163606) kern_sysctl.c (164033)
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Mike Karels at Berkeley Software Design, Inc.
7 *
8 * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD

--- 22 unchanged lines hidden (view full) ---

31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
36 */
37
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Mike Karels at Berkeley Software Design, Inc.
7 *
8 * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD

--- 22 unchanged lines hidden (view full) ---

31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/sys/kern/kern_sysctl.c 163606 2006-10-22 11:52:19Z rwatson $");
39__FBSDID("$FreeBSD: head/sys/kern/kern_sysctl.c 164033 2006-11-06 13:42:10Z rwatson $");
40
41#include "opt_compat.h"
42#include "opt_mac.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/kernel.h>
47#include <sys/sysctl.h>
48#include <sys/malloc.h>
40
41#include "opt_compat.h"
42#include "opt_mac.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/kernel.h>
47#include <sys/sysctl.h>
48#include <sys/malloc.h>
49#include <sys/priv.h>
49#include <sys/proc.h>
50#include <sys/lock.h>
51#include <sys/mutex.h>
52#include <sys/sx.h>
53#include <sys/sysproto.h>
54
55#include <security/mac/mac_framework.h>
56

--- 450 unchanged lines hidden (view full) ---

507 }
508}
509
510static int
511sysctl_sysctl_debug(SYSCTL_HANDLER_ARGS)
512{
513 int error;
514
50#include <sys/proc.h>
51#include <sys/lock.h>
52#include <sys/mutex.h>
53#include <sys/sx.h>
54#include <sys/sysproto.h>
55
56#include <security/mac/mac_framework.h>
57

--- 450 unchanged lines hidden (view full) ---

508 }
509}
510
511static int
512sysctl_sysctl_debug(SYSCTL_HANDLER_ARGS)
513{
514 int error;
515
515 error = suser(req->td);
516 error = priv_check(req->td, PRIV_SYSCTL_DEBUG);
516 if (error)
517 return (error);
518 sysctl_sysctl_debug_dump_node(&sysctl__children, 0);
519 return (ENOENT);
520}
521
522SYSCTL_PROC(_sysctl, 0, debug, CTLTYPE_STRING|CTLFLAG_RD,
523 0, 0, sysctl_sysctl_debug, "-", "");

--- 724 unchanged lines hidden (view full) ---

1248 lvl = (oid->oid_kind & CTLMASK_SECURE) >> CTLSHIFT_SECURE;
1249 error = securelevel_gt(req->td->td_ucred, lvl);
1250 if (error)
1251 return (error);
1252 }
1253
1254 /* Is this sysctl writable by only privileged users? */
1255 if (req->newptr && !(oid->oid_kind & CTLFLAG_ANYBODY)) {
517 if (error)
518 return (error);
519 sysctl_sysctl_debug_dump_node(&sysctl__children, 0);
520 return (ENOENT);
521}
522
523SYSCTL_PROC(_sysctl, 0, debug, CTLTYPE_STRING|CTLFLAG_RD,
524 0, 0, sysctl_sysctl_debug, "-", "");

--- 724 unchanged lines hidden (view full) ---

1249 lvl = (oid->oid_kind & CTLMASK_SECURE) >> CTLSHIFT_SECURE;
1250 error = securelevel_gt(req->td->td_ucred, lvl);
1251 if (error)
1252 return (error);
1253 }
1254
1255 /* Is this sysctl writable by only privileged users? */
1256 if (req->newptr && !(oid->oid_kind & CTLFLAG_ANYBODY)) {
1256 int flags;
1257
1258 if (oid->oid_kind & CTLFLAG_PRISON)
1257 if (oid->oid_kind & CTLFLAG_PRISON)
1259 flags = SUSER_ALLOWJAIL;
1258 error = priv_check_cred(req->td->td_ucred,
1259 PRIV_SYSCTL_WRITEJAIL, SUSER_ALLOWJAIL);
1260 else
1260 else
1261 flags = 0;
1262 error = suser_cred(req->td->td_ucred, flags);
1261 error = priv_check(req->td, PRIV_SYSCTL_WRITE);
1263 if (error)
1264 return (error);
1265 }
1266
1267 if (!oid->oid_handler)
1268 return (EINVAL);
1269
1270 if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) {

--- 347 unchanged lines hidden ---
1262 if (error)
1263 return (error);
1264 }
1265
1266 if (!oid->oid_handler)
1267 return (EINVAL);
1268
1269 if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) {

--- 347 unchanged lines hidden ---