xref: /onnv-gate/usr/src/uts/common/sys/policy.h (revision 5331:3047ad28a67b)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51544Seschrock  * Common Development and Distribution License (the "License").
61544Seschrock  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
223448Sdh155122  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_POLICY_H
270Sstevel@tonic-gate #define	_SYS_POLICY_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* TSOL 8 */
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/types.h>
320Sstevel@tonic-gate #include <sys/cred.h>
330Sstevel@tonic-gate #include <sys/vnode.h>
340Sstevel@tonic-gate #include <sys/fs/snode.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #ifdef	__cplusplus
370Sstevel@tonic-gate extern "C" {
380Sstevel@tonic-gate #endif
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #ifdef _KERNEL
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #ifndef _IN_PORT_T
430Sstevel@tonic-gate #define	_IN_PORT_T
440Sstevel@tonic-gate typedef uint16_t in_port_t;
450Sstevel@tonic-gate #endif
460Sstevel@tonic-gate 
470Sstevel@tonic-gate /*
480Sstevel@tonic-gate  * Policy routines; in case we check privileges in-line.
490Sstevel@tonic-gate  *
500Sstevel@tonic-gate  * priv_policy
510Sstevel@tonic-gate  *		privilege debugging
520Sstevel@tonic-gate  *		audits success & failure
530Sstevel@tonic-gate  *		returns 0 on success, error on failure
540Sstevel@tonic-gate  *
550Sstevel@tonic-gate  * priv_policy_choice
560Sstevel@tonic-gate  *		determines extend of operation
570Sstevel@tonic-gate  *		audit on success
580Sstevel@tonic-gate  * 		returns a boolean_t indicating success (B_TRUE) or failure.
590Sstevel@tonic-gate  *
600Sstevel@tonic-gate  * priv_policy_only
610Sstevel@tonic-gate  *		when auditing is in appropriate (interrupt context)
620Sstevel@tonic-gate  *		to determine context of operation
630Sstevel@tonic-gate  * 		returns a boolean_t indicating success (B_TRUE) or failure.
640Sstevel@tonic-gate  *
650Sstevel@tonic-gate  */
660Sstevel@tonic-gate int priv_policy(const cred_t *, int, boolean_t, int, const char *);
670Sstevel@tonic-gate boolean_t priv_policy_only(const cred_t *, int, boolean_t);
680Sstevel@tonic-gate boolean_t priv_policy_choice(const cred_t *, int, boolean_t);
690Sstevel@tonic-gate 
700Sstevel@tonic-gate struct kipc_perm;
710Sstevel@tonic-gate struct vfs;
720Sstevel@tonic-gate struct proc;
730Sstevel@tonic-gate 
740Sstevel@tonic-gate int secpolicy_acct(const cred_t *);
750Sstevel@tonic-gate int secpolicy_allow_setid(const cred_t *, uid_t, boolean_t);
760Sstevel@tonic-gate int secpolicy_audit_config(const cred_t *);
770Sstevel@tonic-gate int secpolicy_audit_getattr(const cred_t *);
780Sstevel@tonic-gate int secpolicy_audit_modify(const cred_t *);
790Sstevel@tonic-gate int secpolicy_blacklist(const cred_t *);
800Sstevel@tonic-gate int secpolicy_chroot(const cred_t *);
810Sstevel@tonic-gate int secpolicy_clock_highres(const cred_t *);
820Sstevel@tonic-gate int secpolicy_console(const cred_t *);
830Sstevel@tonic-gate int secpolicy_contract_observer(const cred_t *, struct contract *);
840Sstevel@tonic-gate boolean_t secpolicy_contract_observer_choice(const cred_t *);
850Sstevel@tonic-gate int secpolicy_contract_event(const cred_t *);
860Sstevel@tonic-gate boolean_t secpolicy_contract_event_choice(const cred_t *);
870Sstevel@tonic-gate int secpolicy_coreadm(const cred_t *);
880Sstevel@tonic-gate int secpolicy_cpc_cpu(const cred_t *);
890Sstevel@tonic-gate int secpolicy_dispadm(const cred_t *);
901414Scindi int secpolicy_error_inject(const cred_t *);
910Sstevel@tonic-gate int secpolicy_excl_open(const cred_t *);
920Sstevel@tonic-gate int secpolicy_fs_mount(cred_t *, vnode_t *, struct vfs *);
930Sstevel@tonic-gate int secpolicy_fs_unmount(cred_t *, struct vfs *);
940Sstevel@tonic-gate int secpolicy_fs_config(const cred_t *, const struct vfs *);
950Sstevel@tonic-gate int secpolicy_fs_linkdir(const cred_t *, const struct vfs *);
960Sstevel@tonic-gate int secpolicy_fs_minfree(const cred_t *, const struct vfs *);
970Sstevel@tonic-gate int secpolicy_fs_quota(const cred_t *, const struct vfs *);
984321Scasper int secpolicy_idmap(const cred_t *);
993448Sdh155122 int secpolicy_ip(const cred_t *, int, boolean_t);
1003448Sdh155122 int secpolicy_ip_config(const cred_t *, boolean_t);
1010Sstevel@tonic-gate int secpolicy_ipc_access(const cred_t *, const struct kipc_perm *, mode_t);
1020Sstevel@tonic-gate int secpolicy_ipc_config(const cred_t *);
1030Sstevel@tonic-gate int secpolicy_ipc_owner(const cred_t *, const struct kipc_perm *);
1040Sstevel@tonic-gate int secpolicy_kmdb(const cred_t *);
1050Sstevel@tonic-gate int secpolicy_lock_memory(const cred_t *);
1060Sstevel@tonic-gate int secpolicy_modctl(const cred_t *, int);
1070Sstevel@tonic-gate int secpolicy_net(const cred_t *, int, boolean_t);
1081676Sjpk int secpolicy_net_bindmlp(const cred_t *);
1090Sstevel@tonic-gate int secpolicy_net_config(const cred_t *, boolean_t);
1100Sstevel@tonic-gate int secpolicy_net_icmpaccess(const cred_t *);
1111676Sjpk int secpolicy_net_mac_aware(const cred_t *);
1120Sstevel@tonic-gate int secpolicy_net_privaddr(const cred_t *, in_port_t);
1130Sstevel@tonic-gate int secpolicy_net_rawaccess(const cred_t *);
1141676Sjpk boolean_t secpolicy_net_reply_equal(const cred_t *);
1150Sstevel@tonic-gate int secpolicy_newproc(const cred_t *);
1160Sstevel@tonic-gate int secpolicy_nfs(const cred_t *);
1170Sstevel@tonic-gate int secpolicy_pcfs_modify_bootpartition(const cred_t *);
1180Sstevel@tonic-gate int secpolicy_ponline(const cred_t *);
1190Sstevel@tonic-gate int secpolicy_pool(const cred_t *);
1200Sstevel@tonic-gate int secpolicy_power_mgmt(const cred_t *);
1210Sstevel@tonic-gate int secpolicy_proc_access(const cred_t *);
1220Sstevel@tonic-gate int secpolicy_proc_excl_open(const cred_t *);
1230Sstevel@tonic-gate int secpolicy_proc_owner(const cred_t *, const cred_t *, int);
1240Sstevel@tonic-gate int secpolicy_proc_zone(const cred_t *);
1250Sstevel@tonic-gate int secpolicy_pset(const cred_t *);
1260Sstevel@tonic-gate int secpolicy_rctlsys(const cred_t *, boolean_t);
1270Sstevel@tonic-gate int secpolicy_resource(const cred_t *);
1280Sstevel@tonic-gate int secpolicy_rpcmod_open(const cred_t *);
1290Sstevel@tonic-gate int secpolicy_rsm_access(const cred_t *, uid_t, mode_t);
1300Sstevel@tonic-gate int secpolicy_setpriority(const cred_t *);
1310Sstevel@tonic-gate int secpolicy_settime(const cred_t *);
132*5331Samw int secpolicy_smb(const cred_t *);
1330Sstevel@tonic-gate int secpolicy_spec_open(const cred_t *, struct vnode *, int);
1340Sstevel@tonic-gate int secpolicy_sti(const cred_t *);
1350Sstevel@tonic-gate int secpolicy_swapctl(const cred_t *);
1360Sstevel@tonic-gate int secpolicy_sys_config(const cred_t *, boolean_t);
1370Sstevel@tonic-gate int secpolicy_zone_admin(const cred_t *, boolean_t);
1380Sstevel@tonic-gate int secpolicy_zone_config(const cred_t *);
1390Sstevel@tonic-gate int secpolicy_sys_devices(const cred_t *);
1400Sstevel@tonic-gate int secpolicy_systeminfo(const cred_t *);
1410Sstevel@tonic-gate int secpolicy_tasksys(const cred_t *);
1420Sstevel@tonic-gate int secpolicy_vnode_access(const cred_t *, vnode_t *, uid_t, mode_t);
1430Sstevel@tonic-gate int secpolicy_vnode_create_gid(const cred_t *);
1440Sstevel@tonic-gate int secpolicy_vnode_owner(const cred_t *, uid_t);
1450Sstevel@tonic-gate int secpolicy_vnode_remove(const cred_t *);
1460Sstevel@tonic-gate int secpolicy_vnode_setdac(const cred_t *, uid_t);
1470Sstevel@tonic-gate int secpolicy_vnode_setid_retain(const cred_t *, boolean_t);
1480Sstevel@tonic-gate int secpolicy_vnode_setids_setgids(const cred_t *, gid_t);
1490Sstevel@tonic-gate int secpolicy_vnode_stky_modify(const cred_t *);
1501544Seschrock int secpolicy_zinject(const cred_t *);
151789Sahrens int secpolicy_zfs(const cred_t *);
1524581Ssherrym int secpolicy_ucode_update(const cred_t *);
1534962Sdh155122 int secpolicy_sadopen(const cred_t *);
1541115Smarks void secpolicy_setid_clear(vattr_t *, cred_t *);
1554543Smarks void secpolicy_fs_mount_clearopts(cred_t *, struct vfs *);
1562796Smarks int secpolicy_setid_setsticky_clear(vnode_t *, vattr_t *,
1572796Smarks     const vattr_t *, cred_t *);
158*5331Samw int secpolicy_xvattr(xvattr_t *, uid_t, cred_t *, vtype_t);
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate int secpolicy_basic_exec(const cred_t *);
1610Sstevel@tonic-gate int secpolicy_basic_fork(const cred_t *);
1620Sstevel@tonic-gate int secpolicy_basic_proc(const cred_t *);
1630Sstevel@tonic-gate int secpolicy_basic_procinfo(const cred_t *, struct proc *, struct proc *);
1640Sstevel@tonic-gate int secpolicy_basic_link(const cred_t *);
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate int secpolicy_gart_access(const cred_t *);
1670Sstevel@tonic-gate int secpolicy_gart_map(const cred_t *);
1680Sstevel@tonic-gate /*
1690Sstevel@tonic-gate  * This function to be called from xxfs_setattr().
1700Sstevel@tonic-gate  * Must be called with the node's attributes read-write locked.
1710Sstevel@tonic-gate  *
1720Sstevel@tonic-gate  *		cred_t *		- acting credentials
1730Sstevel@tonic-gate  *		struct vnode *		- vnode we're operating on
1740Sstevel@tonic-gate  *		struct vattr *va	- new attributes, va_mask may be
1750Sstevel@tonic-gate  *					  changed on return from a call
1760Sstevel@tonic-gate  *		struct vattr *oldva	- old attributes, need include owner
1770Sstevel@tonic-gate  *					  and mode only
1780Sstevel@tonic-gate  *		int flags		- setattr flags
1790Sstevel@tonic-gate  *		int iaccess(void *node, int mode, cred_t *cr)
1800Sstevel@tonic-gate  *					- non-locking internal access function
1810Sstevel@tonic-gate  *						mode be checked
1820Sstevel@tonic-gate  *						w/ VREAD|VWRITE|VEXEC, not fs
1830Sstevel@tonic-gate  *						internal mode encoding.
1840Sstevel@tonic-gate  *
1850Sstevel@tonic-gate  *		void *node		- internal node (inode, tmpnode) to
1860Sstevel@tonic-gate  *					  pass as arg to iaccess
1870Sstevel@tonic-gate  */
1880Sstevel@tonic-gate int secpolicy_vnode_setattr(cred_t *, struct vnode *, struct vattr *,
1890Sstevel@tonic-gate     const struct vattr *, int, int (void *, int, cred_t *), void *);
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate /*
1920Sstevel@tonic-gate  * Test privilege. Audit success or failure, allow privilege debugging.
1930Sstevel@tonic-gate  * Returns 0 for success, err for failure.
1940Sstevel@tonic-gate  */
1950Sstevel@tonic-gate #define	PRIV_POLICY(cred, priv, all, err, reason) \
1960Sstevel@tonic-gate 		priv_policy((cred), (priv), (all), (err), (reason))
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate /*
1990Sstevel@tonic-gate  * Test privilege. Audit success only, no privilege debugging.
2000Sstevel@tonic-gate  * Returns 1 for success, and 0 for failure.
2010Sstevel@tonic-gate  */
2020Sstevel@tonic-gate #define	PRIV_POLICY_CHOICE(cred, priv, all) \
2030Sstevel@tonic-gate 		priv_policy_choice((cred), (priv), (all))
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate /*
2060Sstevel@tonic-gate  * Test privilege. No priv_debugging, no auditing.
2070Sstevel@tonic-gate  * Returns 1 for success, and 0 for failure.
2080Sstevel@tonic-gate  */
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate #define	PRIV_POLICY_ONLY(cred, priv, all) \
2110Sstevel@tonic-gate 		priv_policy_only((cred), (priv), (all))
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate #endif
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate #ifdef	__cplusplus
2170Sstevel@tonic-gate }
2180Sstevel@tonic-gate #endif
2190Sstevel@tonic-gate 
2200Sstevel@tonic-gate #endif	/* _SYS_POLICY_H */
221