xref: /titanic_50/usr/src/uts/common/sys/policy.h (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_POLICY_H
28 #define	_SYS_POLICY_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* TSOL 8 */
31 
32 #include <sys/types.h>
33 #include <sys/cred.h>
34 #include <sys/vnode.h>
35 #include <sys/fs/snode.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #ifdef _KERNEL
42 
43 #ifndef _IN_PORT_T
44 #define	_IN_PORT_T
45 typedef uint16_t in_port_t;
46 #endif
47 
48 /*
49  * Policy routines; in case we check privileges in-line.
50  *
51  * priv_policy
52  *		privilege debugging
53  *		audits success & failure
54  *		returns 0 on success, error on failure
55  *
56  * priv_policy_choice
57  *		determines extend of operation
58  *		audit on success
59  * 		returns a boolean_t indicating success (B_TRUE) or failure.
60  *
61  * priv_policy_only
62  *		when auditing is in appropriate (interrupt context)
63  *		to determine context of operation
64  * 		returns a boolean_t indicating success (B_TRUE) or failure.
65  *
66  */
67 int priv_policy(const cred_t *, int, boolean_t, int, const char *);
68 boolean_t priv_policy_only(const cred_t *, int, boolean_t);
69 boolean_t priv_policy_choice(const cred_t *, int, boolean_t);
70 
71 struct kipc_perm;
72 struct vfs;
73 struct proc;
74 
75 int secpolicy_acct(const cred_t *);
76 int secpolicy_allow_setid(const cred_t *, uid_t, boolean_t);
77 int secpolicy_audit_config(const cred_t *);
78 int secpolicy_audit_getattr(const cred_t *);
79 int secpolicy_audit_modify(const cred_t *);
80 int secpolicy_blacklist(const cred_t *);
81 int secpolicy_chroot(const cred_t *);
82 int secpolicy_clock_highres(const cred_t *);
83 int secpolicy_console(const cred_t *);
84 int secpolicy_contract_observer(const cred_t *, struct contract *);
85 boolean_t secpolicy_contract_observer_choice(const cred_t *);
86 int secpolicy_contract_event(const cred_t *);
87 boolean_t secpolicy_contract_event_choice(const cred_t *);
88 int secpolicy_coreadm(const cred_t *);
89 int secpolicy_cpc_cpu(const cred_t *);
90 int secpolicy_dispadm(const cred_t *);
91 int secpolicy_excl_open(const cred_t *);
92 int secpolicy_fs_mount(cred_t *, vnode_t *, struct vfs *);
93 int secpolicy_fs_unmount(cred_t *, struct vfs *);
94 int secpolicy_fs_config(const cred_t *, const struct vfs *);
95 int secpolicy_fs_linkdir(const cred_t *, const struct vfs *);
96 int secpolicy_fs_minfree(const cred_t *, const struct vfs *);
97 int secpolicy_fs_quota(const cred_t *, const struct vfs *);
98 int secpolicy_ipc_access(const cred_t *, const struct kipc_perm *, mode_t);
99 int secpolicy_ipc_config(const cred_t *);
100 int secpolicy_ipc_owner(const cred_t *, const struct kipc_perm *);
101 int secpolicy_kmdb(const cred_t *);
102 int secpolicy_lock_memory(const cred_t *);
103 int secpolicy_modctl(const cred_t *, int);
104 int secpolicy_net(const cred_t *, int, boolean_t);
105 int secpolicy_net_config(const cred_t *, boolean_t);
106 int secpolicy_net_icmpaccess(const cred_t *);
107 int secpolicy_net_privaddr(const cred_t *, in_port_t);
108 int secpolicy_net_rawaccess(const cred_t *);
109 int secpolicy_newproc(const cred_t *);
110 int secpolicy_nfs(const cred_t *);
111 int secpolicy_pcfs_modify_bootpartition(const cred_t *);
112 int secpolicy_ponline(const cred_t *);
113 int secpolicy_pool(const cred_t *);
114 int secpolicy_power_mgmt(const cred_t *);
115 int secpolicy_proc_access(const cred_t *);
116 int secpolicy_proc_excl_open(const cred_t *);
117 int secpolicy_proc_owner(const cred_t *, const cred_t *, int);
118 int secpolicy_proc_zone(const cred_t *);
119 int secpolicy_pset(const cred_t *);
120 int secpolicy_rctlsys(const cred_t *, boolean_t);
121 int secpolicy_resource(const cred_t *);
122 int secpolicy_rpcmod_open(const cred_t *);
123 int secpolicy_rsm_access(const cred_t *, uid_t, mode_t);
124 int secpolicy_setpriority(const cred_t *);
125 int secpolicy_settime(const cred_t *);
126 int secpolicy_spec_open(const cred_t *, struct vnode *, int);
127 int secpolicy_sti(const cred_t *);
128 int secpolicy_swapctl(const cred_t *);
129 int secpolicy_sys_config(const cred_t *, boolean_t);
130 int secpolicy_zone_admin(const cred_t *, boolean_t);
131 int secpolicy_zone_config(const cred_t *);
132 int secpolicy_sys_devices(const cred_t *);
133 int secpolicy_systeminfo(const cred_t *);
134 int secpolicy_tasksys(const cred_t *);
135 int secpolicy_vnode_access(const cred_t *, vnode_t *, uid_t, mode_t);
136 int secpolicy_vnode_create_gid(const cred_t *);
137 int secpolicy_vnode_owner(const cred_t *, uid_t);
138 int secpolicy_vnode_remove(const cred_t *);
139 int secpolicy_vnode_setdac(const cred_t *, uid_t);
140 int secpolicy_vnode_setid_retain(const cred_t *, boolean_t);
141 int secpolicy_vnode_setids_setgids(const cred_t *, gid_t);
142 int secpolicy_vnode_stky_modify(const cred_t *);
143 
144 int secpolicy_basic_exec(const cred_t *);
145 int secpolicy_basic_fork(const cred_t *);
146 int secpolicy_basic_proc(const cred_t *);
147 int secpolicy_basic_procinfo(const cred_t *, struct proc *, struct proc *);
148 int secpolicy_basic_link(const cred_t *);
149 
150 int secpolicy_gart_access(const cred_t *);
151 int secpolicy_gart_map(const cred_t *);
152 /*
153  * This function to be called from xxfs_setattr().
154  * Must be called with the node's attributes read-write locked.
155  *
156  *		cred_t *		- acting credentials
157  *		struct vnode *		- vnode we're operating on
158  *		struct vattr *va	- new attributes, va_mask may be
159  *					  changed on return from a call
160  *		struct vattr *oldva	- old attributes, need include owner
161  *					  and mode only
162  *		int flags		- setattr flags
163  *		int iaccess(void *node, int mode, cred_t *cr)
164  *					- non-locking internal access function
165  *						mode be checked
166  *						w/ VREAD|VWRITE|VEXEC, not fs
167  *						internal mode encoding.
168  *
169  *		void *node		- internal node (inode, tmpnode) to
170  *					  pass as arg to iaccess
171  */
172 int secpolicy_vnode_setattr(cred_t *, struct vnode *, struct vattr *,
173     const struct vattr *, int, int (void *, int, cred_t *), void *);
174 
175 /*
176  * Test privilege. Audit success or failure, allow privilege debugging.
177  * Returns 0 for success, err for failure.
178  */
179 #define	PRIV_POLICY(cred, priv, all, err, reason) \
180 		priv_policy((cred), (priv), (all), (err), (reason))
181 
182 /*
183  * Test privilege. Audit success only, no privilege debugging.
184  * Returns 1 for success, and 0 for failure.
185  */
186 #define	PRIV_POLICY_CHOICE(cred, priv, all) \
187 		priv_policy_choice((cred), (priv), (all))
188 
189 /*
190  * Test privilege. No priv_debugging, no auditing.
191  * Returns 1 for success, and 0 for failure.
192  */
193 
194 #define	PRIV_POLICY_ONLY(cred, priv, all) \
195 		priv_policy_only((cred), (priv), (all))
196 
197 
198 #endif
199 
200 #ifdef	__cplusplus
201 }
202 #endif
203 
204 #endif	/* _SYS_POLICY_H */
205