Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/priv.h
+++ new/usr/src/uts/common/sys/priv.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23 + *
22 24 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23 25 */
24 26
25 27 #ifndef _SYS_PRIV_H
26 28 #define _SYS_PRIV_H
27 29
28 30 #include <sys/types.h>
29 31 #include <sys/cred.h>
30 32 #include <sys/priv_names.h>
31 33
32 34 #ifdef __cplusplus
33 35 extern "C" {
34 36 #endif
35 37
36 38 typedef uint32_t priv_chunk_t;
37 39 typedef struct priv_set priv_set_t;
38 40
39 41 #ifdef _KERNEL
40 42
41 43 /*
42 44 * Kernel type definitions.
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
43 45 */
44 46 typedef int priv_ptype_t;
45 47 typedef int priv_t;
46 48
47 49 #else /* _KERNEL */
48 50
49 51 /*
50 52 * Userland type definitions.
51 53 */
52 54
53 -#ifdef __STDC__
54 55 typedef const char *priv_ptype_t;
55 56 typedef const char *priv_t;
56 -#else
57 -typedef char *priv_ptype_t;
58 -typedef char *priv_t;
59 -#endif
60 57
61 58 #endif /* _KERNEL */
62 59
63 60 /*
64 61 * priv_op_t indicates a privilege operation type
65 62 */
66 63 typedef enum priv_op {
67 64 PRIV_ON,
68 65 PRIV_OFF,
69 66 PRIV_SET
70 67 } priv_op_t;
71 68
72 69 /*
73 70 * Privilege system call subcodes.
74 71 */
75 72
76 73 #define PRIVSYS_SETPPRIV 0
77 74 #define PRIVSYS_GETPPRIV 1
78 75 #define PRIVSYS_GETIMPLINFO 2
79 76 #define PRIVSYS_SETPFLAGS 3
80 77 #define PRIVSYS_GETPFLAGS 4
81 78 #define PRIVSYS_ISSETUGID 5
82 79 #define PRIVSYS_KLPD_REG 6
83 80 #define PRIVSYS_KLPD_UNREG 7
84 81 #define PRIVSYS_PFEXEC_REG 8
85 82 #define PRIVSYS_PFEXEC_UNREG 9
86 83
87 84
88 85 /*
89 86 * Maximum length of a user defined privilege name.
90 87 */
91 88 #define PRIVNAME_MAX 32
92 89
93 90 /*
94 91 * Privilege interface functions for those parts of the kernel that
95 92 * know nothing of the privilege internals.
96 93 *
97 94 * A privilege implementation can have a varying number of sets; sets
98 95 * consist of a number of priv_chunk_t's and the size is expressed as such.
99 96 * The privileges can be represented as
100 97 *
101 98 * priv_chunk_t privs[info.priv_nsets][info.priv_setsize]
102 99 * ... priv_infosize of extra information ...
103 100 *
104 101 * Extra data contained in the privilege information consists of chunks
105 102 * of data with specified size and type all headed by a priv_info_t header
106 103 * which defines both the type of information as well as the size of the
107 104 * information. ((char*)&info)+info->priv_info_size should be rounded up
108 105 * to point to the next piece of information.
109 106 */
110 107
111 108 typedef struct priv_impl_info {
112 109 uint32_t priv_headersize; /* sizeof (priv_impl_info) */
113 110 uint32_t priv_flags; /* additional flags */
114 111 uint32_t priv_nsets; /* number of priv sets */
115 112 uint32_t priv_setsize; /* size in priv_chunk_t */
116 113 uint32_t priv_max; /* highest actual valid priv */
117 114 uint32_t priv_infosize; /* Per proc. additional info */
118 115 uint32_t priv_globalinfosize; /* Per system info */
119 116 } priv_impl_info_t;
120 117
121 118 #define PRIV_IMPL_INFO_SIZE(p) \
122 119 ((p)->priv_headersize + (p)->priv_globalinfosize)
123 120
124 121 #define PRIV_PRPRIV_INFO_OFFSET(p) \
125 122 (sizeof (*(p)) + \
126 123 ((p)->pr_nsets * (p)->pr_setsize - 1) * sizeof (priv_chunk_t))
127 124
128 125 #define PRIV_PRPRIV_SIZE(p) \
129 126 (PRIV_PRPRIV_INFO_OFFSET(p) + (p)->pr_infosize)
130 127
131 128 /*
132 129 * Per credential flags.
133 130 */
134 131 #define PRIV_DEBUG 0x0001 /* User debugging */
135 132 #define PRIV_AWARE 0x0002 /* Is privilege aware */
136 133 #define PRIV_AWARE_INHERIT 0x0004 /* Inherit awareness */
137 134 #define __PROC_PROTECT 0x0008 /* Private */
138 135 #define NET_MAC_AWARE 0x0010 /* Is MAC aware */
139 136 #define NET_MAC_AWARE_INHERIT 0x0020 /* Inherit MAC aware */
140 137 #define PRIV_AWARE_RESET 0x0040 /* Reset on setuid() */
141 138 #define PRIV_XPOLICY 0x0080 /* Extended policy */
142 139 #define PRIV_PFEXEC 0x0100 /* As if pfexec'ed */
143 140
144 141 /* user-settable flags: */
145 142 #define PRIV_USER (PRIV_DEBUG | NET_MAC_AWARE | NET_MAC_AWARE_INHERIT |\
146 143 PRIV_XPOLICY | PRIV_AWARE_RESET | PRIV_PFEXEC)
147 144
148 145 /*
149 146 * Header of the privilege info data structure; multiple structures can
150 147 * follow the privilege sets and priv_impl_info structures.
151 148 */
152 149 typedef struct priv_info {
153 150 uint32_t priv_info_type;
154 151 uint32_t priv_info_size;
155 152 } priv_info_t;
156 153
157 154 typedef struct priv_info_uint {
158 155 priv_info_t info;
159 156 uint_t val;
160 157 } priv_info_uint_t;
161 158
162 159 /*
163 160 * Global privilege set information item; the actual size of the array is
164 161 * {priv_setsize}.
165 162 */
166 163 typedef struct priv_info_set {
167 164 priv_info_t info;
168 165 priv_chunk_t set[1];
169 166 } priv_info_set_t;
170 167
171 168 /*
172 169 * names[1] is a place holder which can contain multiple NUL terminated,
173 170 * non-empty strings.
174 171 */
175 172
176 173 typedef struct priv_info_names {
177 174 priv_info_t info;
178 175 int cnt; /* number of strings */
179 176 char names[1]; /* "string1\0string2\0 ..stringN\0" */
180 177 } priv_info_names_t;
181 178
182 179 /*
183 180 * Privilege information types.
184 181 */
185 182 #define PRIV_INFO_SETNAMES 0x0001
186 183 #define PRIV_INFO_PRIVNAMES 0x0002
187 184 #define PRIV_INFO_BASICPRIVS 0x0003
188 185 #define PRIV_INFO_FLAGS 0x0004
189 186
190 187 /*
191 188 * Special "privileges" used to indicate special conditions in privilege
192 189 * debugging/tracing code.
193 190 */
194 191 #define PRIV_ALL (-1) /* All privileges required */
195 192 #define PRIV_MULTIPLE (-2) /* More than one */
196 193 #define PRIV_NONE (-3) /* No value */
197 194 #define PRIV_ALLZONE (-4) /* All privileges in zone */
198 195 #define PRIV_GLOBAL (-5) /* Must be in global zone */
199 196
200 197 #ifdef _KERNEL
201 198
202 199 #define PRIV_ALLOC 0x1
203 200
204 201 extern int priv_debug;
205 202 extern int priv_basic_test;
206 203
207 204 struct proc;
208 205 struct prpriv;
209 206 struct cred;
210 207
211 208 extern int priv_prgetprivsize(struct prpriv *);
212 209 extern void cred2prpriv(const struct cred *, struct prpriv *);
213 210 extern int priv_pr_spriv(struct proc *, struct prpriv *, const struct cred *);
214 211
215 212 extern priv_impl_info_t *priv_hold_implinfo(void);
216 213 extern void priv_release_implinfo(void);
217 214 extern size_t priv_get_implinfo_size(void);
218 215 extern const priv_set_t *priv_getset(const struct cred *, int);
219 216 extern void priv_getinfo(const struct cred *, void *);
220 217 extern int priv_getbyname(const char *, uint_t);
221 218 extern int priv_getsetbyname(const char *, int);
222 219 extern const char *priv_getbynum(int);
223 220 extern const char *priv_getsetbynum(int);
224 221
225 222 extern void priv_emptyset(priv_set_t *);
226 223 extern void priv_fillset(priv_set_t *);
227 224 extern void priv_addset(priv_set_t *, int);
228 225 extern void priv_delset(priv_set_t *, int);
229 226 extern boolean_t priv_ismember(const priv_set_t *, int);
230 227 extern boolean_t priv_isemptyset(const priv_set_t *);
231 228 extern boolean_t priv_isfullset(const priv_set_t *);
232 229 extern boolean_t priv_isequalset(const priv_set_t *, const priv_set_t *);
233 230 extern boolean_t priv_issubset(const priv_set_t *, const priv_set_t *);
234 231 extern int priv_proc_cred_perm(const struct cred *, struct proc *,
235 232 struct cred **, int);
236 233 extern void priv_intersect(const priv_set_t *, priv_set_t *);
237 234 extern void priv_union(const priv_set_t *, priv_set_t *);
238 235 extern void priv_inverse(priv_set_t *);
239 236
240 237 extern void priv_set_PA(cred_t *);
241 238 extern void priv_adjust_PA(cred_t *);
242 239 extern void priv_reset_PA(cred_t *, boolean_t);
243 240 extern boolean_t priv_can_clear_PA(const cred_t *);
244 241
245 242 extern int setpflags(uint_t, uint_t, cred_t *);
246 243 extern uint_t getpflags(uint_t, const cred_t *);
247 244
248 245 #endif /* _KERNEL */
249 246
250 247 #ifdef __cplusplus
251 248 }
252 249 #endif
253 250
254 251 #endif /* _SYS_PRIV_H */
↓ open down ↓ |
185 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX