17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5ea8dc4b6Seschrock * Common Development and Distribution License (the "License"). 6ea8dc4b6Seschrock * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*4bff34e3Sthurlow * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_POLICY_H 277c478bd9Sstevel@tonic-gate #define _SYS_POLICY_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* TSOL 8 */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/types.h> 327c478bd9Sstevel@tonic-gate #include <sys/cred.h> 337c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 347c478bd9Sstevel@tonic-gate #include <sys/fs/snode.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 377c478bd9Sstevel@tonic-gate extern "C" { 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef _KERNEL 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #ifndef _IN_PORT_T 437c478bd9Sstevel@tonic-gate #define _IN_PORT_T 447c478bd9Sstevel@tonic-gate typedef uint16_t in_port_t; 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * Policy routines; in case we check privileges in-line. 497c478bd9Sstevel@tonic-gate * 507c478bd9Sstevel@tonic-gate * priv_policy 517c478bd9Sstevel@tonic-gate * privilege debugging 527c478bd9Sstevel@tonic-gate * audits success & failure 537c478bd9Sstevel@tonic-gate * returns 0 on success, error on failure 547c478bd9Sstevel@tonic-gate * 557c478bd9Sstevel@tonic-gate * priv_policy_choice 567c478bd9Sstevel@tonic-gate * determines extend of operation 577c478bd9Sstevel@tonic-gate * audit on success 587c478bd9Sstevel@tonic-gate * returns a boolean_t indicating success (B_TRUE) or failure. 597c478bd9Sstevel@tonic-gate * 607c478bd9Sstevel@tonic-gate * priv_policy_only 617c478bd9Sstevel@tonic-gate * when auditing is in appropriate (interrupt context) 627c478bd9Sstevel@tonic-gate * to determine context of operation 637c478bd9Sstevel@tonic-gate * returns a boolean_t indicating success (B_TRUE) or failure. 647c478bd9Sstevel@tonic-gate * 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate int priv_policy(const cred_t *, int, boolean_t, int, const char *); 677c478bd9Sstevel@tonic-gate boolean_t priv_policy_only(const cred_t *, int, boolean_t); 687c478bd9Sstevel@tonic-gate boolean_t priv_policy_choice(const cred_t *, int, boolean_t); 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate struct kipc_perm; 717c478bd9Sstevel@tonic-gate struct vfs; 727c478bd9Sstevel@tonic-gate struct proc; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate int secpolicy_acct(const cred_t *); 757c478bd9Sstevel@tonic-gate int secpolicy_allow_setid(const cred_t *, uid_t, boolean_t); 767c478bd9Sstevel@tonic-gate int secpolicy_audit_config(const cred_t *); 777c478bd9Sstevel@tonic-gate int secpolicy_audit_getattr(const cred_t *); 787c478bd9Sstevel@tonic-gate int secpolicy_audit_modify(const cred_t *); 797c478bd9Sstevel@tonic-gate int secpolicy_blacklist(const cred_t *); 807c478bd9Sstevel@tonic-gate int secpolicy_chroot(const cred_t *); 817c478bd9Sstevel@tonic-gate int secpolicy_clock_highres(const cred_t *); 827c478bd9Sstevel@tonic-gate int secpolicy_console(const cred_t *); 837c478bd9Sstevel@tonic-gate int secpolicy_contract_observer(const cred_t *, struct contract *); 847c478bd9Sstevel@tonic-gate boolean_t secpolicy_contract_observer_choice(const cred_t *); 857c478bd9Sstevel@tonic-gate int secpolicy_contract_event(const cred_t *); 867c478bd9Sstevel@tonic-gate boolean_t secpolicy_contract_event_choice(const cred_t *); 877c478bd9Sstevel@tonic-gate int secpolicy_coreadm(const cred_t *); 887c478bd9Sstevel@tonic-gate int secpolicy_cpc_cpu(const cred_t *); 897c478bd9Sstevel@tonic-gate int secpolicy_dispadm(const cred_t *); 907aec1d6eScindi int secpolicy_error_inject(const cred_t *); 917c478bd9Sstevel@tonic-gate int secpolicy_excl_open(const cred_t *); 927c478bd9Sstevel@tonic-gate int secpolicy_fs_mount(cred_t *, vnode_t *, struct vfs *); 937c478bd9Sstevel@tonic-gate int secpolicy_fs_unmount(cred_t *, struct vfs *); 947c478bd9Sstevel@tonic-gate int secpolicy_fs_config(const cred_t *, const struct vfs *); 957c478bd9Sstevel@tonic-gate int secpolicy_fs_linkdir(const cred_t *, const struct vfs *); 967c478bd9Sstevel@tonic-gate int secpolicy_fs_minfree(const cred_t *, const struct vfs *); 977c478bd9Sstevel@tonic-gate int secpolicy_fs_quota(const cred_t *, const struct vfs *); 98f48205beScasper int secpolicy_idmap(const cred_t *); 99f4b3ec61Sdh int secpolicy_ip(const cred_t *, int, boolean_t); 100f4b3ec61Sdh int secpolicy_ip_config(const cred_t *, boolean_t); 1017c478bd9Sstevel@tonic-gate int secpolicy_ipc_access(const cred_t *, const struct kipc_perm *, mode_t); 1027c478bd9Sstevel@tonic-gate int secpolicy_ipc_config(const cred_t *); 1037c478bd9Sstevel@tonic-gate int secpolicy_ipc_owner(const cred_t *, const struct kipc_perm *); 1047c478bd9Sstevel@tonic-gate int secpolicy_kmdb(const cred_t *); 1057c478bd9Sstevel@tonic-gate int secpolicy_lock_memory(const cred_t *); 1067c478bd9Sstevel@tonic-gate int secpolicy_modctl(const cred_t *, int); 1077c478bd9Sstevel@tonic-gate int secpolicy_net(const cred_t *, int, boolean_t); 10845916cd2Sjpk int secpolicy_net_bindmlp(const cred_t *); 1097c478bd9Sstevel@tonic-gate int secpolicy_net_config(const cred_t *, boolean_t); 1107c478bd9Sstevel@tonic-gate int secpolicy_net_icmpaccess(const cred_t *); 11145916cd2Sjpk int secpolicy_net_mac_aware(const cred_t *); 1127c478bd9Sstevel@tonic-gate int secpolicy_net_privaddr(const cred_t *, in_port_t); 1137c478bd9Sstevel@tonic-gate int secpolicy_net_rawaccess(const cred_t *); 11445916cd2Sjpk boolean_t secpolicy_net_reply_equal(const cred_t *); 1157c478bd9Sstevel@tonic-gate int secpolicy_newproc(const cred_t *); 1167c478bd9Sstevel@tonic-gate int secpolicy_nfs(const cred_t *); 1177c478bd9Sstevel@tonic-gate int secpolicy_pcfs_modify_bootpartition(const cred_t *); 1187c478bd9Sstevel@tonic-gate int secpolicy_ponline(const cred_t *); 1197c478bd9Sstevel@tonic-gate int secpolicy_pool(const cred_t *); 1207c478bd9Sstevel@tonic-gate int secpolicy_power_mgmt(const cred_t *); 1217c478bd9Sstevel@tonic-gate int secpolicy_proc_access(const cred_t *); 1227c478bd9Sstevel@tonic-gate int secpolicy_proc_excl_open(const cred_t *); 1237c478bd9Sstevel@tonic-gate int secpolicy_proc_owner(const cred_t *, const cred_t *, int); 1247c478bd9Sstevel@tonic-gate int secpolicy_proc_zone(const cred_t *); 1257c478bd9Sstevel@tonic-gate int secpolicy_pset(const cred_t *); 1267c478bd9Sstevel@tonic-gate int secpolicy_rctlsys(const cred_t *, boolean_t); 1277c478bd9Sstevel@tonic-gate int secpolicy_resource(const cred_t *); 1287c478bd9Sstevel@tonic-gate int secpolicy_rpcmod_open(const cred_t *); 1297c478bd9Sstevel@tonic-gate int secpolicy_rsm_access(const cred_t *, uid_t, mode_t); 1307c478bd9Sstevel@tonic-gate int secpolicy_setpriority(const cred_t *); 1317c478bd9Sstevel@tonic-gate int secpolicy_settime(const cred_t *); 132da6c28aaSamw int secpolicy_smb(const cred_t *); 133*4bff34e3Sthurlow int secpolicy_smbfs_login(const cred_t *, uid_t); 1347c478bd9Sstevel@tonic-gate int secpolicy_spec_open(const cred_t *, struct vnode *, int); 1357c478bd9Sstevel@tonic-gate int secpolicy_sti(const cred_t *); 1367c478bd9Sstevel@tonic-gate int secpolicy_swapctl(const cred_t *); 1377c478bd9Sstevel@tonic-gate int secpolicy_sys_config(const cred_t *, boolean_t); 1387c478bd9Sstevel@tonic-gate int secpolicy_zone_admin(const cred_t *, boolean_t); 1397c478bd9Sstevel@tonic-gate int secpolicy_zone_config(const cred_t *); 1407c478bd9Sstevel@tonic-gate int secpolicy_sys_devices(const cred_t *); 1417c478bd9Sstevel@tonic-gate int secpolicy_systeminfo(const cred_t *); 1427c478bd9Sstevel@tonic-gate int secpolicy_tasksys(const cred_t *); 1437c478bd9Sstevel@tonic-gate int secpolicy_vnode_access(const cred_t *, vnode_t *, uid_t, mode_t); 1447c478bd9Sstevel@tonic-gate int secpolicy_vnode_create_gid(const cred_t *); 1457c478bd9Sstevel@tonic-gate int secpolicy_vnode_owner(const cred_t *, uid_t); 1467c478bd9Sstevel@tonic-gate int secpolicy_vnode_remove(const cred_t *); 1477c478bd9Sstevel@tonic-gate int secpolicy_vnode_setdac(const cred_t *, uid_t); 1487c478bd9Sstevel@tonic-gate int secpolicy_vnode_setid_retain(const cred_t *, boolean_t); 1497c478bd9Sstevel@tonic-gate int secpolicy_vnode_setids_setgids(const cred_t *, gid_t); 1507c478bd9Sstevel@tonic-gate int secpolicy_vnode_stky_modify(const cred_t *); 151911106dfSjm int secpolicy_vscan(const cred_t *); 152ea8dc4b6Seschrock int secpolicy_zinject(const cred_t *); 153fa9e4066Sahrens int secpolicy_zfs(const cred_t *); 1542449e17fSsherrym int secpolicy_ucode_update(const cred_t *); 155e6bdcbd5Sdh int secpolicy_sadopen(const cred_t *); 15613f9f30eSmarks void secpolicy_setid_clear(vattr_t *, cred_t *); 157ecd6cf80Smarks void secpolicy_fs_mount_clearopts(cred_t *, struct vfs *); 158f92daba9Smarks int secpolicy_setid_setsticky_clear(vnode_t *, vattr_t *, 159f92daba9Smarks const vattr_t *, cred_t *); 160da6c28aaSamw int secpolicy_xvattr(xvattr_t *, uid_t, cred_t *, vtype_t); 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate int secpolicy_basic_exec(const cred_t *); 1637c478bd9Sstevel@tonic-gate int secpolicy_basic_fork(const cred_t *); 1647c478bd9Sstevel@tonic-gate int secpolicy_basic_proc(const cred_t *); 1657c478bd9Sstevel@tonic-gate int secpolicy_basic_procinfo(const cred_t *, struct proc *, struct proc *); 1667c478bd9Sstevel@tonic-gate int secpolicy_basic_link(const cred_t *); 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate int secpolicy_gart_access(const cred_t *); 1697c478bd9Sstevel@tonic-gate int secpolicy_gart_map(const cred_t *); 1707c478bd9Sstevel@tonic-gate /* 1717c478bd9Sstevel@tonic-gate * This function to be called from xxfs_setattr(). 1727c478bd9Sstevel@tonic-gate * Must be called with the node's attributes read-write locked. 1737c478bd9Sstevel@tonic-gate * 1747c478bd9Sstevel@tonic-gate * cred_t * - acting credentials 1757c478bd9Sstevel@tonic-gate * struct vnode * - vnode we're operating on 1767c478bd9Sstevel@tonic-gate * struct vattr *va - new attributes, va_mask may be 1777c478bd9Sstevel@tonic-gate * changed on return from a call 1787c478bd9Sstevel@tonic-gate * struct vattr *oldva - old attributes, need include owner 1797c478bd9Sstevel@tonic-gate * and mode only 1807c478bd9Sstevel@tonic-gate * int flags - setattr flags 1817c478bd9Sstevel@tonic-gate * int iaccess(void *node, int mode, cred_t *cr) 1827c478bd9Sstevel@tonic-gate * - non-locking internal access function 1837c478bd9Sstevel@tonic-gate * mode be checked 1847c478bd9Sstevel@tonic-gate * w/ VREAD|VWRITE|VEXEC, not fs 1857c478bd9Sstevel@tonic-gate * internal mode encoding. 1867c478bd9Sstevel@tonic-gate * 1877c478bd9Sstevel@tonic-gate * void *node - internal node (inode, tmpnode) to 1887c478bd9Sstevel@tonic-gate * pass as arg to iaccess 1897c478bd9Sstevel@tonic-gate */ 1907c478bd9Sstevel@tonic-gate int secpolicy_vnode_setattr(cred_t *, struct vnode *, struct vattr *, 1917c478bd9Sstevel@tonic-gate const struct vattr *, int, int (void *, int, cred_t *), void *); 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate /* 1947c478bd9Sstevel@tonic-gate * Test privilege. Audit success or failure, allow privilege debugging. 1957c478bd9Sstevel@tonic-gate * Returns 0 for success, err for failure. 1967c478bd9Sstevel@tonic-gate */ 1977c478bd9Sstevel@tonic-gate #define PRIV_POLICY(cred, priv, all, err, reason) \ 1987c478bd9Sstevel@tonic-gate priv_policy((cred), (priv), (all), (err), (reason)) 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* 2017c478bd9Sstevel@tonic-gate * Test privilege. Audit success only, no privilege debugging. 2027c478bd9Sstevel@tonic-gate * Returns 1 for success, and 0 for failure. 2037c478bd9Sstevel@tonic-gate */ 2047c478bd9Sstevel@tonic-gate #define PRIV_POLICY_CHOICE(cred, priv, all) \ 2057c478bd9Sstevel@tonic-gate priv_policy_choice((cred), (priv), (all)) 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate /* 2087c478bd9Sstevel@tonic-gate * Test privilege. No priv_debugging, no auditing. 2097c478bd9Sstevel@tonic-gate * Returns 1 for success, and 0 for failure. 2107c478bd9Sstevel@tonic-gate */ 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate #define PRIV_POLICY_ONLY(cred, priv, all) \ 2137c478bd9Sstevel@tonic-gate priv_policy_only((cred), (priv), (all)) 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate #endif 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2197c478bd9Sstevel@tonic-gate } 2207c478bd9Sstevel@tonic-gate #endif 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate #endif /* _SYS_POLICY_H */ 223