Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Move clockctl policy exception back to the subsystem.
details: https://anonhg.NetBSD.org/src/rev/578c2e573e9b
branches: trunk
changeset: 747845:578c2e573e9b
user: elad <elad%NetBSD.org@localhost>
date: Sat Oct 03 02:01:12 2009 +0000
description:
Move clockctl policy exception back to the subsystem.
diffstat:
sys/dev/clockctl.c | 36 ++++++++++++++++++++++++++++++++----
sys/secmodel/suser/secmodel_suser.c | 18 +++---------------
2 files changed, 35 insertions(+), 19 deletions(-)
diffs (107 lines):
diff -r d48b0dac31d8 -r 578c2e573e9b sys/dev/clockctl.c
--- a/sys/dev/clockctl.c Sat Oct 03 01:52:14 2009 +0000
+++ b/sys/dev/clockctl.c Sat Oct 03 02:01:12 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: clockctl.c,v 1.27 2009/02/22 13:06:59 nakayama Exp $ */
+/* $NetBSD: clockctl.c,v 1.28 2009/10/03 02:01:12 elad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.27 2009/02/22 13:06:59 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.28 2009/10/03 02:01:12 elad Exp $");
#include "opt_ntp.h"
#include "opt_compat_netbsd.h"
@@ -47,6 +47,7 @@
#ifdef NTP
#include <sys/timex.h>
#endif /* NTP */
+#include <sys/kauth.h>
#include <sys/clockctl.h>
#ifdef COMPAT_50
@@ -64,12 +65,39 @@
nostop, notty, nopoll, nommap, nokqfilter, D_OTHER,
};
+static kauth_listener_t clockctl_listener;
+
+static int
+clockctl_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie,
+ void *arg0, void *arg1, void *arg2, void *arg3)
+{
+ int result;
+ enum kauth_system_req req;
+ bool device_context;
+
+ result = KAUTH_RESULT_DEFER;
+ req = (enum kauth_system_req)arg0;
+
+ if ((action != KAUTH_SYSTEM_TIME) ||
+ (req != KAUTH_REQ_SYSTEM_TIME_SYSTEM))
+ return result;
+
+ device_context = (bool)arg3;
+
+ /* Device is controlled by permissions, so allow. */
+ if (device_context)
+ result = KAUTH_RESULT_ALLOW;
+
+ return result;
+}
+
/*ARGSUSED*/
void
clockctlattach(int num)
{
- /* Nothing to set up before open is called */
- return;
+
+ clockctl_listener = kauth_listen_scope(KAUTH_SCOPE_SYSTEM,
+ clockctl_listener_cb, NULL);
}
int
diff -r d48b0dac31d8 -r 578c2e573e9b sys/secmodel/suser/secmodel_suser.c
--- a/sys/secmodel/suser/secmodel_suser.c Sat Oct 03 01:52:14 2009 +0000
+++ b/sys/secmodel/suser/secmodel_suser.c Sat Oct 03 02:01:12 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_suser.c,v 1.21 2009/10/03 01:52:14 elad Exp $ */
+/* $NetBSD: secmodel_suser.c,v 1.22 2009/10/03 02:01:12 elad Exp $ */
/*-
* Copyright (c) 2006 Elad Efrat <elad%NetBSD.org@localhost>
* All rights reserved.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.21 2009/10/03 01:52:14 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.22 2009/10/03 02:01:12 elad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -410,19 +410,7 @@
case KAUTH_REQ_SYSTEM_TIME_ADJTIME:
case KAUTH_REQ_SYSTEM_TIME_NTPADJTIME:
case KAUTH_REQ_SYSTEM_TIME_TIMECOUNTERS:
- if (isroot)
- result = KAUTH_RESULT_ALLOW;
- break;
-
- case KAUTH_REQ_SYSTEM_TIME_SYSTEM: {
- bool device_context = (bool)arg3;
-
- if (device_context || isroot)
- result = KAUTH_RESULT_ALLOW;
-
- break;
- }
-
+ case KAUTH_REQ_SYSTEM_TIME_SYSTEM:
case KAUTH_REQ_SYSTEM_TIME_RTCOFFSET:
if (isroot)
result = KAUTH_RESULT_ALLOW;
Home |
Main Index |
Thread Index |
Old Index