Print this page
Code review comments from jeffpc
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libc/inc/priv_private.h
+++ new/usr/src/lib/libc/inc/priv_private.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.
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
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 */
21 21
22 22 /*
23 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #ifndef _PRIV_PRIVATE_H
28 28 #define _PRIV_PRIVATE_H
29 29
30 +#pragma ident "%Z%%M% %I% %E% SMI"
31 +
30 32 #include <sys/types.h>
31 33 #include <sys/priv.h>
32 34 #include <limits.h>
33 35
34 36 /*
35 37 * Libc private privilege data.
36 38 */
37 39
38 40 #ifdef __cplusplus
39 41 extern "C" {
40 42 #endif
41 43
42 44 #define LOADPRIVDATA(d) d = __priv_getdata()
43 45 #define GETPRIVDATA() __priv_getdata()
44 46 #define LOCKPRIVDATA() { \
45 47 /* Data already allocated */ \
46 48 (void) lock_data(); \
47 49 (void) refresh_data(); \
48 50 }
49 51 #define UNLOCKPRIVDATA() unlock_data()
50 52 #define WITHPRIVLOCKED(t, b, x) { \
51 53 t __result; \
52 54 if (lock_data() != 0) \
53 55 return (b); \
54 56 __result = (x); \
55 57 if (__result == (b) && refresh_data()) \
56 58 __result = (x); \
57 59 unlock_data(); \
58 60 return (__result); \
59 61 }
60 62
61 63 /*
62 64 * Privilege mask macros.
63 65 */
64 66 #define __NBWRD (CHAR_BIT * sizeof (priv_chunk_t))
65 67 #define privmask(n) (1 << ((__NBWRD - 1) - ((n) % __NBWRD)))
66 68 #define privword(n) ((n)/__NBWRD)
67 69
68 70 /*
69 71 * Same as the functions, but for numeric privileges.
70 72 */
71 73 #define PRIV_ADDSET(a, p) ((priv_chunk_t *)(a))[privword(p)] |= \
72 74 privmask(p)
73 75 #define PRIV_DELSET(a, p) ((priv_chunk_t *)(a))[privword(p)] &= \
74 76 ~privmask(p)
75 77 #define PRIV_ISMEMBER(a, p) ((((priv_chunk_t *)(a))[privword(p)] & \
76 78 privmask(p)) != 0)
77 79
78 80 /*
79 81 * The structure is static except for the setsort, privnames and nprivs
80 82 * field. The pinfo structure initially has sufficient room and the kernel
81 83 * guarantees no offset changes so we can copy a new structure on top of it.
82 84 * The locking stratgegy is this: we lock it when we need to reference any
83 85 * of the volatile fields.
84 86 */
85 87 typedef struct priv_data {
86 88 size_t pd_setsize; /* In bytes */
87 89 int pd_nsets, pd_nprivs;
88 90 uint32_t pd_ucredsize;
89 91 char **pd_setnames;
90 92 char **pd_privnames;
91 93 int *pd_setsort;
92 94 priv_impl_info_t *pd_pinfo;
93 95 priv_set_t *pd_basicset;
94 96 priv_set_t *pd_zoneset;
95 97 } priv_data_t;
96 98
97 99 extern priv_data_t *__priv_getdata(void);
98 100 extern priv_data_t *__priv_parse_info(priv_impl_info_t *);
99 101 extern void __priv_free_info(priv_data_t *);
100 102 extern priv_data_t *privdata;
101 103
102 104 extern int lock_data(void);
103 105 extern boolean_t refresh_data(void);
104 106 extern void unlock_data(void);
105 107
106 108 extern boolean_t __priv_isemptyset(priv_data_t *, const priv_set_t *);
107 109 extern boolean_t __priv_isfullset(priv_data_t *, const priv_set_t *);
108 110 extern boolean_t __priv_issubset(priv_data_t *, const priv_set_t *,
109 111 const priv_set_t *);
110 112 extern const char *__priv_getbynum(const priv_data_t *, int);
111 113
112 114 extern int getprivinfo(priv_impl_info_t *, size_t);
113 115
114 116 extern priv_set_t *priv_basic(void);
115 117
116 118 #ifdef __cplusplus
117 119 }
118 120 #endif
119 121
120 122 #endif /* _PRIV_PRIVATE_H */
↓ open down ↓ |
81 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX