secmodel_bsd44.c revision 1.10.20.1 1 1.10.20.1 matt /* $NetBSD: secmodel_bsd44.c,v 1.10.20.1 2008/01/09 01:58:02 matt Exp $ */
2 1.1 elad /*-
3 1.1 elad * Copyright (c) 2006 Elad Efrat <elad (at) NetBSD.org>
4 1.1 elad * All rights reserved.
5 1.1 elad *
6 1.1 elad * Redistribution and use in source and binary forms, with or without
7 1.1 elad * modification, are permitted provided that the following conditions
8 1.1 elad * are met:
9 1.1 elad * 1. Redistributions of source code must retain the above copyright
10 1.1 elad * notice, this list of conditions and the following disclaimer.
11 1.1 elad * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 elad * notice, this list of conditions and the following disclaimer in the
13 1.1 elad * documentation and/or other materials provided with the distribution.
14 1.8 elad * 3. The name of the author may not be used to endorse or promote products
15 1.1 elad * derived from this software without specific prior written permission.
16 1.1 elad *
17 1.1 elad * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 1.1 elad * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 1.1 elad * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 1.1 elad * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 1.1 elad * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 1.1 elad * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 1.1 elad * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 1.1 elad * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 1.1 elad * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 1.1 elad * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 1.1 elad */
28 1.1 elad
29 1.2 elad #include <sys/cdefs.h>
30 1.10.20.1 matt __KERNEL_RCSID(0, "$NetBSD: secmodel_bsd44.c,v 1.10.20.1 2008/01/09 01:58:02 matt Exp $");
31 1.2 elad
32 1.1 elad #include <sys/types.h>
33 1.1 elad #include <sys/param.h>
34 1.1 elad #include <sys/kauth.h>
35 1.1 elad
36 1.1 elad #include <sys/sysctl.h>
37 1.1 elad
38 1.1 elad #include <secmodel/secmodel.h>
39 1.1 elad
40 1.1 elad #include <secmodel/bsd44/bsd44.h>
41 1.1 elad #include <secmodel/bsd44/suser.h>
42 1.10.20.1 matt #include <secmodel/securelevel/securelevel.h>
43 1.1 elad
44 1.1 elad SYSCTL_SETUP(sysctl_security_bsd44_setup,
45 1.1 elad "sysctl security bsd44 setup")
46 1.1 elad {
47 1.1 elad const struct sysctlnode *rnode;
48 1.1 elad
49 1.1 elad sysctl_createv(clog, 0, NULL, &rnode,
50 1.1 elad CTLFLAG_PERMANENT,
51 1.1 elad CTLTYPE_NODE, "security", NULL,
52 1.1 elad NULL, 0, NULL, 0,
53 1.3 elad CTL_SECURITY, CTL_EOL);
54 1.1 elad
55 1.4 elad sysctl_createv(clog, 0, &rnode, NULL,
56 1.4 elad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
57 1.4 elad CTLTYPE_INT, "curtain", NULL,
58 1.4 elad NULL, 0, &secmodel_bsd44_curtain, 0,
59 1.4 elad CTL_CREATE, CTL_EOL);
60 1.4 elad
61 1.1 elad sysctl_createv(clog, 0, &rnode, &rnode,
62 1.1 elad CTLFLAG_PERMANENT,
63 1.1 elad CTLTYPE_NODE, "models", NULL,
64 1.1 elad NULL, 0, NULL, 0,
65 1.1 elad CTL_CREATE, CTL_EOL);
66 1.1 elad
67 1.1 elad sysctl_createv(clog, 0, &rnode, &rnode,
68 1.1 elad CTLFLAG_PERMANENT,
69 1.1 elad CTLTYPE_NODE, "bsd44",
70 1.1 elad SYSCTL_DESCR("Traditional NetBSD Security model, " \
71 1.1 elad "derived from 4.4BSD"),
72 1.1 elad NULL, 0, NULL, 0,
73 1.1 elad CTL_CREATE, CTL_EOL);
74 1.1 elad
75 1.1 elad sysctl_createv(clog, 0, &rnode, NULL,
76 1.1 elad CTLFLAG_PERMANENT,
77 1.1 elad CTLTYPE_STRING, "name", NULL,
78 1.1 elad NULL, 0, __UNCONST("Traditional NetBSD (4.4BSD)"), 0,
79 1.1 elad CTL_CREATE, CTL_EOL);
80 1.1 elad
81 1.1 elad sysctl_createv(clog, 0, &rnode, NULL,
82 1.1 elad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
83 1.1 elad CTLTYPE_INT, "securelevel",
84 1.1 elad SYSCTL_DESCR("System security level"),
85 1.10.20.1 matt secmodel_securelevel_sysctl, 0, NULL, 0,
86 1.1 elad CTL_CREATE, CTL_EOL);
87 1.1 elad
88 1.1 elad sysctl_createv(clog, 0, &rnode, NULL,
89 1.1 elad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
90 1.1 elad CTLTYPE_INT, "curtain",
91 1.1 elad SYSCTL_DESCR("Curtain information about objects to "
92 1.1 elad "users not owning them."),
93 1.1 elad NULL, 0, &secmodel_bsd44_curtain, 0,
94 1.1 elad CTL_CREATE, CTL_EOL);
95 1.1 elad }
96 1.1 elad
97 1.1 elad void
98 1.9 elad secmodel_bsd44_start(void)
99 1.1 elad {
100 1.1 elad secmodel_bsd44_init();
101 1.1 elad
102 1.1 elad secmodel_bsd44_suser_start();
103 1.10.20.1 matt secmodel_securelevel_start();
104 1.10 elad
105 1.10 elad secmodel_register();
106 1.1 elad }
107 1.9 elad
108 1.9 elad #if defined(_LKM)
109 1.9 elad void
110 1.9 elad secmodel_bsd44_stop(void)
111 1.9 elad {
112 1.9 elad secmodel_bsd44_suser_stop();
113 1.10.20.1 matt secmodel_securelevel_stop();
114 1.10 elad
115 1.10 elad secmodel_deregister();
116 1.9 elad }
117 1.9 elad #endif /* _LKM */
118 1.9 elad
119 1.9 elad #if !defined(_LKM)
120 1.9 elad void
121 1.9 elad secmodel_start(void)
122 1.9 elad {
123 1.9 elad secmodel_bsd44_start();
124 1.9 elad }
125 1.7 elad #endif /* !_LKM */
126 1.9 elad
127 1.9 elad
128