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 /* 22134a1f4eSCasper H.S. Dik * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _SYS_POLICY_H 267c478bd9Sstevel@tonic-gate #define _SYS_POLICY_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/types.h> 297c478bd9Sstevel@tonic-gate #include <sys/cred.h> 307c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 317c478bd9Sstevel@tonic-gate #include <sys/fs/snode.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef _KERNEL 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifndef _IN_PORT_T 407c478bd9Sstevel@tonic-gate #define _IN_PORT_T 417c478bd9Sstevel@tonic-gate typedef uint16_t in_port_t; 427c478bd9Sstevel@tonic-gate #endif 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * Policy routines; in case we check privileges in-line. 467c478bd9Sstevel@tonic-gate * 477c478bd9Sstevel@tonic-gate * priv_policy 487c478bd9Sstevel@tonic-gate * privilege debugging 497c478bd9Sstevel@tonic-gate * audits success & failure 507c478bd9Sstevel@tonic-gate * returns 0 on success, error on failure 517c478bd9Sstevel@tonic-gate * 527c478bd9Sstevel@tonic-gate * priv_policy_choice 537c478bd9Sstevel@tonic-gate * determines extend of operation 547c478bd9Sstevel@tonic-gate * audit on success 557c478bd9Sstevel@tonic-gate * returns a boolean_t indicating success (B_TRUE) or failure. 567c478bd9Sstevel@tonic-gate * 577c478bd9Sstevel@tonic-gate * priv_policy_only 587c478bd9Sstevel@tonic-gate * when auditing is in appropriate (interrupt context) 597c478bd9Sstevel@tonic-gate * to determine context of operation 607c478bd9Sstevel@tonic-gate * returns a boolean_t indicating success (B_TRUE) or failure. 617c478bd9Sstevel@tonic-gate * 627c478bd9Sstevel@tonic-gate */ 637c478bd9Sstevel@tonic-gate int priv_policy(const cred_t *, int, boolean_t, int, const char *); 647c478bd9Sstevel@tonic-gate boolean_t priv_policy_only(const cred_t *, int, boolean_t); 657c478bd9Sstevel@tonic-gate boolean_t priv_policy_choice(const cred_t *, int, boolean_t); 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate struct kipc_perm; 687c478bd9Sstevel@tonic-gate struct vfs; 697c478bd9Sstevel@tonic-gate struct proc; 70ddf7fe95Scasper struct priv_set; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate int secpolicy_acct(const cred_t *); 73ddf7fe95Scasper int secpolicy_require_privs(const cred_t *, const struct priv_set *); 747c478bd9Sstevel@tonic-gate int secpolicy_allow_setid(const cred_t *, uid_t, boolean_t); 757c478bd9Sstevel@tonic-gate int secpolicy_audit_config(const cred_t *); 76134a1f4eSCasper H.S. Dik int secpolicy_audit_getattr(const cred_t *, boolean_t); 777c478bd9Sstevel@tonic-gate int secpolicy_audit_modify(const cred_t *); 787c478bd9Sstevel@tonic-gate int secpolicy_blacklist(const cred_t *); 797c478bd9Sstevel@tonic-gate int secpolicy_chroot(const cred_t *); 807c478bd9Sstevel@tonic-gate int secpolicy_clock_highres(const cred_t *); 817c478bd9Sstevel@tonic-gate int secpolicy_console(const cred_t *); 827b209c2cSacruz int secpolicy_contract_identity(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); 101eae72b5bSSebastien Roy int secpolicy_dl_config(const cred_t *); 1022b24ab6bSSebastien Roy int secpolicy_iptun_config(const cred_t *); 1037c478bd9Sstevel@tonic-gate int secpolicy_ipc_access(const cred_t *, const struct kipc_perm *, mode_t); 1047c478bd9Sstevel@tonic-gate int secpolicy_ipc_config(const cred_t *); 1057c478bd9Sstevel@tonic-gate int secpolicy_ipc_owner(const cred_t *, const struct kipc_perm *); 1067c478bd9Sstevel@tonic-gate int secpolicy_kmdb(const cred_t *); 1077c478bd9Sstevel@tonic-gate int secpolicy_lock_memory(const cred_t *); 1087c478bd9Sstevel@tonic-gate int secpolicy_modctl(const cred_t *, int); 1097c478bd9Sstevel@tonic-gate int secpolicy_net(const cred_t *, int, boolean_t); 11045916cd2Sjpk int secpolicy_net_bindmlp(const cred_t *); 1117c478bd9Sstevel@tonic-gate int secpolicy_net_config(const cred_t *, boolean_t); 1127c478bd9Sstevel@tonic-gate int secpolicy_net_icmpaccess(const cred_t *); 11345916cd2Sjpk int secpolicy_net_mac_aware(const cred_t *); 1145d3b8cb7SBill Sommerfeld int secpolicy_net_mac_implicit(const cred_t *); 1150a0e9771SDarren Reed int secpolicy_net_observability(const cred_t *); 116ddf7fe95Scasper int secpolicy_net_privaddr(const cred_t *, in_port_t, int proto); 1177c478bd9Sstevel@tonic-gate int secpolicy_net_rawaccess(const cred_t *); 11845916cd2Sjpk boolean_t secpolicy_net_reply_equal(const cred_t *); 1197c478bd9Sstevel@tonic-gate int secpolicy_newproc(const cred_t *); 1207c478bd9Sstevel@tonic-gate int secpolicy_nfs(const cred_t *); 121*bbf58fc5S int secpolicy_pbind(const cred_t *); 1227c478bd9Sstevel@tonic-gate int secpolicy_pcfs_modify_bootpartition(const cred_t *); 123134a1f4eSCasper H.S. Dik int secpolicy_pfexec_register(const cred_t *); 1247c478bd9Sstevel@tonic-gate int secpolicy_ponline(const cred_t *); 1257c478bd9Sstevel@tonic-gate int secpolicy_pool(const cred_t *); 1267c478bd9Sstevel@tonic-gate int secpolicy_power_mgmt(const cred_t *); 127f53eecf5SJames Carlson int secpolicy_ppp_config(const cred_t *); 1287c478bd9Sstevel@tonic-gate int secpolicy_proc_access(const cred_t *); 1297c478bd9Sstevel@tonic-gate int secpolicy_proc_excl_open(const cred_t *); 1307c478bd9Sstevel@tonic-gate int secpolicy_proc_owner(const cred_t *, const cred_t *, int); 1317c478bd9Sstevel@tonic-gate int secpolicy_proc_zone(const cred_t *); 1327c478bd9Sstevel@tonic-gate int secpolicy_pset(const cred_t *); 1337c478bd9Sstevel@tonic-gate int secpolicy_rctlsys(const cred_t *, boolean_t); 1347c478bd9Sstevel@tonic-gate int secpolicy_resource(const cred_t *); 1351c7cef2bSStan Studzinski int secpolicy_resource_anon_mem(const cred_t *); 1367c478bd9Sstevel@tonic-gate int secpolicy_rpcmod_open(const cred_t *); 1377c478bd9Sstevel@tonic-gate int secpolicy_rsm_access(const cred_t *, uid_t, mode_t); 1387c478bd9Sstevel@tonic-gate int secpolicy_setpriority(const cred_t *); 1397c478bd9Sstevel@tonic-gate int secpolicy_settime(const cred_t *); 140da6c28aaSamw int secpolicy_smb(const cred_t *); 1414bff34e3Sthurlow int secpolicy_smbfs_login(const cred_t *, uid_t); 1427c478bd9Sstevel@tonic-gate int secpolicy_spec_open(const cred_t *, struct vnode *, int); 1437c478bd9Sstevel@tonic-gate int secpolicy_sti(const cred_t *); 1447c478bd9Sstevel@tonic-gate int secpolicy_swapctl(const cred_t *); 1457c478bd9Sstevel@tonic-gate int secpolicy_sys_config(const cred_t *, boolean_t); 1467c478bd9Sstevel@tonic-gate int secpolicy_zone_admin(const cred_t *, boolean_t); 1477c478bd9Sstevel@tonic-gate int secpolicy_zone_config(const cred_t *); 1487c478bd9Sstevel@tonic-gate int secpolicy_sys_devices(const cred_t *); 1497c478bd9Sstevel@tonic-gate int secpolicy_systeminfo(const cred_t *); 1507c478bd9Sstevel@tonic-gate int secpolicy_tasksys(const cred_t *); 1517c478bd9Sstevel@tonic-gate int secpolicy_vnode_access(const cred_t *, vnode_t *, uid_t, mode_t); 152134a1f4eSCasper H.S. Dik int secpolicy_vnode_access2(const cred_t *, vnode_t *, uid_t, mode_t, mode_t); 153134a1f4eSCasper H.S. Dik int secpolicy_vnode_any_access(const cred_t *, vnode_t *, uid_t); 154e02bc683SMark Shellenbaum int secpolicy_vnode_chown(const cred_t *, uid_t); 1557c478bd9Sstevel@tonic-gate int secpolicy_vnode_create_gid(const cred_t *); 1567c478bd9Sstevel@tonic-gate int secpolicy_vnode_owner(const cred_t *, uid_t); 1577c478bd9Sstevel@tonic-gate int secpolicy_vnode_remove(const cred_t *); 1587c478bd9Sstevel@tonic-gate int secpolicy_vnode_setdac(const cred_t *, uid_t); 1597c478bd9Sstevel@tonic-gate int secpolicy_vnode_setid_retain(const cred_t *, boolean_t); 1607c478bd9Sstevel@tonic-gate int secpolicy_vnode_setids_setgids(const cred_t *, gid_t); 1617c478bd9Sstevel@tonic-gate int secpolicy_vnode_stky_modify(const cred_t *); 162911106dfSjm int secpolicy_vscan(const cred_t *); 163ea8dc4b6Seschrock int secpolicy_zinject(const cred_t *); 164fa9e4066Sahrens int secpolicy_zfs(const cred_t *); 1652449e17fSsherrym int secpolicy_ucode_update(const cred_t *); 166e6bdcbd5Sdh int secpolicy_sadopen(const cred_t *); 16713f9f30eSmarks void secpolicy_setid_clear(vattr_t *, cred_t *); 168ecd6cf80Smarks void secpolicy_fs_mount_clearopts(cred_t *, struct vfs *); 169f92daba9Smarks int secpolicy_setid_setsticky_clear(vnode_t *, vattr_t *, 170f92daba9Smarks const vattr_t *, cred_t *); 171da6c28aaSamw int secpolicy_xvattr(xvattr_t *, uid_t, cred_t *, vtype_t); 172b26a64aeSjohnlev int secpolicy_xvm_control(const cred_t *); 1737c478bd9Sstevel@tonic-gate 174ddf7fe95Scasper int secpolicy_basic_exec(const cred_t *, vnode_t *); 1757c478bd9Sstevel@tonic-gate int secpolicy_basic_fork(const cred_t *); 176ddf7fe95Scasper int secpolicy_basic_link(const cred_t *); 177134a1f4eSCasper H.S. Dik int secpolicy_basic_file_read(const cred_t *, vnode_t *, const char *); 178134a1f4eSCasper H.S. Dik int secpolicy_basic_file_write(const cred_t *, vnode_t *, const char *); 179634e26ecSCasper H.S. Dik int secpolicy_basic_net_access(const cred_t *); 1807c478bd9Sstevel@tonic-gate int secpolicy_basic_proc(const cred_t *); 1817c478bd9Sstevel@tonic-gate int secpolicy_basic_procinfo(const cred_t *, struct proc *, struct proc *); 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate int secpolicy_gart_access(const cred_t *); 1847c478bd9Sstevel@tonic-gate int secpolicy_gart_map(const cred_t *); 1857c478bd9Sstevel@tonic-gate /* 1867c478bd9Sstevel@tonic-gate * This function to be called from xxfs_setattr(). 1877c478bd9Sstevel@tonic-gate * Must be called with the node's attributes read-write locked. 1887c478bd9Sstevel@tonic-gate * 1897c478bd9Sstevel@tonic-gate * cred_t * - acting credentials 1907c478bd9Sstevel@tonic-gate * struct vnode * - vnode we're operating on 1917c478bd9Sstevel@tonic-gate * struct vattr *va - new attributes, va_mask may be 1927c478bd9Sstevel@tonic-gate * changed on return from a call 1937c478bd9Sstevel@tonic-gate * struct vattr *oldva - old attributes, need include owner 1947c478bd9Sstevel@tonic-gate * and mode only 1957c478bd9Sstevel@tonic-gate * int flags - setattr flags 1967c478bd9Sstevel@tonic-gate * int iaccess(void *node, int mode, cred_t *cr) 1977c478bd9Sstevel@tonic-gate * - non-locking internal access function 1987c478bd9Sstevel@tonic-gate * mode be checked 1997c478bd9Sstevel@tonic-gate * w/ VREAD|VWRITE|VEXEC, not fs 2007c478bd9Sstevel@tonic-gate * internal mode encoding. 2017c478bd9Sstevel@tonic-gate * 2027c478bd9Sstevel@tonic-gate * void *node - internal node (inode, tmpnode) to 2037c478bd9Sstevel@tonic-gate * pass as arg to iaccess 2047c478bd9Sstevel@tonic-gate */ 2057c478bd9Sstevel@tonic-gate int secpolicy_vnode_setattr(cred_t *, struct vnode *, struct vattr *, 2067c478bd9Sstevel@tonic-gate const struct vattr *, int, int (void *, int, cred_t *), void *); 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate /* 2097c478bd9Sstevel@tonic-gate * Test privilege. Audit success or failure, allow privilege debugging. 2107c478bd9Sstevel@tonic-gate * Returns 0 for success, err for failure. 2117c478bd9Sstevel@tonic-gate */ 2127c478bd9Sstevel@tonic-gate #define PRIV_POLICY(cred, priv, all, err, reason) \ 2137c478bd9Sstevel@tonic-gate priv_policy((cred), (priv), (all), (err), (reason)) 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate /* 2167c478bd9Sstevel@tonic-gate * Test privilege. Audit success only, no privilege debugging. 2177c478bd9Sstevel@tonic-gate * Returns 1 for success, and 0 for failure. 2187c478bd9Sstevel@tonic-gate */ 2197c478bd9Sstevel@tonic-gate #define PRIV_POLICY_CHOICE(cred, priv, all) \ 2207c478bd9Sstevel@tonic-gate priv_policy_choice((cred), (priv), (all)) 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate /* 2237c478bd9Sstevel@tonic-gate * Test privilege. No priv_debugging, no auditing. 2247c478bd9Sstevel@tonic-gate * Returns 1 for success, and 0 for failure. 2257c478bd9Sstevel@tonic-gate */ 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate #define PRIV_POLICY_ONLY(cred, priv, all) \ 2287c478bd9Sstevel@tonic-gate priv_policy_only((cred), (priv), (all)) 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate #endif 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2347c478bd9Sstevel@tonic-gate } 2357c478bd9Sstevel@tonic-gate #endif 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate #endif /* _SYS_POLICY_H */ 238