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. 23*24d819e6SJerry Jelinek * Copyright 2013, Joyent, Inc. All rights reserved. 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 #include <sys/types.h> 307c478bd9Sstevel@tonic-gate #include <sys/cred.h> 317c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 327c478bd9Sstevel@tonic-gate #include <sys/fs/snode.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef _KERNEL 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifndef _IN_PORT_T 417c478bd9Sstevel@tonic-gate #define _IN_PORT_T 427c478bd9Sstevel@tonic-gate typedef uint16_t in_port_t; 437c478bd9Sstevel@tonic-gate #endif 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * Policy routines; in case we check privileges in-line. 477c478bd9Sstevel@tonic-gate * 487c478bd9Sstevel@tonic-gate * priv_policy 497c478bd9Sstevel@tonic-gate * privilege debugging 507c478bd9Sstevel@tonic-gate * audits success & failure 517c478bd9Sstevel@tonic-gate * returns 0 on success, error on failure 527c478bd9Sstevel@tonic-gate * 537c478bd9Sstevel@tonic-gate * priv_policy_choice 547c478bd9Sstevel@tonic-gate * determines extend of operation 557c478bd9Sstevel@tonic-gate * audit on success 567c478bd9Sstevel@tonic-gate * returns a boolean_t indicating success (B_TRUE) or failure. 577c478bd9Sstevel@tonic-gate * 587c478bd9Sstevel@tonic-gate * priv_policy_only 597c478bd9Sstevel@tonic-gate * when auditing is in appropriate (interrupt context) 607c478bd9Sstevel@tonic-gate * to determine context of operation 617c478bd9Sstevel@tonic-gate * returns a boolean_t indicating success (B_TRUE) or failure. 627c478bd9Sstevel@tonic-gate * 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate int priv_policy(const cred_t *, int, boolean_t, int, const char *); 657c478bd9Sstevel@tonic-gate boolean_t priv_policy_only(const cred_t *, int, boolean_t); 667c478bd9Sstevel@tonic-gate boolean_t priv_policy_choice(const cred_t *, int, boolean_t); 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate struct kipc_perm; 697c478bd9Sstevel@tonic-gate struct vfs; 707c478bd9Sstevel@tonic-gate struct proc; 71ddf7fe95Scasper struct priv_set; 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate int secpolicy_acct(const cred_t *); 74ddf7fe95Scasper int secpolicy_require_privs(const cred_t *, const struct priv_set *); 757c478bd9Sstevel@tonic-gate int secpolicy_allow_setid(const cred_t *, uid_t, boolean_t); 767c478bd9Sstevel@tonic-gate int secpolicy_audit_config(const cred_t *); 77134a1f4eSCasper H.S. Dik int secpolicy_audit_getattr(const cred_t *, boolean_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 *); 837b209c2cSacruz int secpolicy_contract_identity(const cred_t *); 847c478bd9Sstevel@tonic-gate int secpolicy_contract_observer(const cred_t *, struct contract *); 857c478bd9Sstevel@tonic-gate boolean_t secpolicy_contract_observer_choice(const cred_t *); 867c478bd9Sstevel@tonic-gate int secpolicy_contract_event(const cred_t *); 877c478bd9Sstevel@tonic-gate boolean_t secpolicy_contract_event_choice(const cred_t *); 887c478bd9Sstevel@tonic-gate int secpolicy_coreadm(const cred_t *); 897c478bd9Sstevel@tonic-gate int secpolicy_cpc_cpu(const cred_t *); 907c478bd9Sstevel@tonic-gate int secpolicy_dispadm(const cred_t *); 917aec1d6eScindi int secpolicy_error_inject(const cred_t *); 927c478bd9Sstevel@tonic-gate int secpolicy_excl_open(const cred_t *); 930fbb751dSJohn Levon int secpolicy_fs_allowed_mount(const char *); 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 *); 970fbb751dSJohn Levon int secpolicy_fs_mount(cred_t *, vnode_t *, struct vfs *); 987c478bd9Sstevel@tonic-gate int secpolicy_fs_quota(const cred_t *, const struct vfs *); 990fbb751dSJohn Levon int secpolicy_fs_unmount(cred_t *, struct vfs *); 100f48205beScasper int secpolicy_idmap(const cred_t *); 101f4b3ec61Sdh155122 int secpolicy_ip(const cred_t *, int, boolean_t); 102f4b3ec61Sdh155122 int secpolicy_ip_config(const cred_t *, boolean_t); 103eae72b5bSSebastien Roy int secpolicy_dl_config(const cred_t *); 1042b24ab6bSSebastien Roy int secpolicy_iptun_config(const cred_t *); 1057c478bd9Sstevel@tonic-gate int secpolicy_ipc_access(const cred_t *, const struct kipc_perm *, mode_t); 1067c478bd9Sstevel@tonic-gate int secpolicy_ipc_config(const cred_t *); 1077c478bd9Sstevel@tonic-gate int secpolicy_ipc_owner(const cred_t *, const struct kipc_perm *); 1087c478bd9Sstevel@tonic-gate int secpolicy_kmdb(const cred_t *); 1097c478bd9Sstevel@tonic-gate int secpolicy_lock_memory(const cred_t *); 1107c478bd9Sstevel@tonic-gate int secpolicy_modctl(const cred_t *, int); 1117c478bd9Sstevel@tonic-gate int secpolicy_net(const cred_t *, int, boolean_t); 11245916cd2Sjpk int secpolicy_net_bindmlp(const cred_t *); 1137c478bd9Sstevel@tonic-gate int secpolicy_net_config(const cred_t *, boolean_t); 1147c478bd9Sstevel@tonic-gate int secpolicy_net_icmpaccess(const cred_t *); 11545916cd2Sjpk int secpolicy_net_mac_aware(const cred_t *); 1165d3b8cb7SBill Sommerfeld int secpolicy_net_mac_implicit(const cred_t *); 1170a0e9771SDarren Reed int secpolicy_net_observability(const cred_t *); 118ddf7fe95Scasper int secpolicy_net_privaddr(const cred_t *, in_port_t, int proto); 1197c478bd9Sstevel@tonic-gate int secpolicy_net_rawaccess(const cred_t *); 12045916cd2Sjpk boolean_t secpolicy_net_reply_equal(const cred_t *); 1217c478bd9Sstevel@tonic-gate int secpolicy_newproc(const cred_t *); 1227c478bd9Sstevel@tonic-gate int secpolicy_nfs(const cred_t *); 123bbf58fc5S int secpolicy_pbind(const cred_t *); 1247c478bd9Sstevel@tonic-gate int secpolicy_pcfs_modify_bootpartition(const cred_t *); 125134a1f4eSCasper H.S. Dik int secpolicy_pfexec_register(const cred_t *); 1267c478bd9Sstevel@tonic-gate int secpolicy_ponline(const cred_t *); 1277c478bd9Sstevel@tonic-gate int secpolicy_pool(const cred_t *); 1287c478bd9Sstevel@tonic-gate int secpolicy_power_mgmt(const cred_t *); 129f53eecf5SJames Carlson int secpolicy_ppp_config(const cred_t *); 1307c478bd9Sstevel@tonic-gate int secpolicy_proc_access(const cred_t *); 1317c478bd9Sstevel@tonic-gate int secpolicy_proc_excl_open(const cred_t *); 1327c478bd9Sstevel@tonic-gate int secpolicy_proc_owner(const cred_t *, const cred_t *, int); 1337c478bd9Sstevel@tonic-gate int secpolicy_proc_zone(const cred_t *); 1347c478bd9Sstevel@tonic-gate int secpolicy_pset(const cred_t *); 1357c478bd9Sstevel@tonic-gate int secpolicy_rctlsys(const cred_t *, boolean_t); 1367c478bd9Sstevel@tonic-gate int secpolicy_resource(const cred_t *); 1371c7cef2bSStan Studzinski int secpolicy_resource_anon_mem(const cred_t *); 1387c478bd9Sstevel@tonic-gate int secpolicy_rpcmod_open(const cred_t *); 1397c478bd9Sstevel@tonic-gate int secpolicy_rsm_access(const cred_t *, uid_t, mode_t); 140*24d819e6SJerry Jelinek int secpolicy_raisepriority(const cred_t *); 1417c478bd9Sstevel@tonic-gate int secpolicy_setpriority(const cred_t *); 1427c478bd9Sstevel@tonic-gate int secpolicy_settime(const cred_t *); 143da6c28aaSamw int secpolicy_smb(const cred_t *); 1444bff34e3Sthurlow int secpolicy_smbfs_login(const cred_t *, uid_t); 1457c478bd9Sstevel@tonic-gate int secpolicy_spec_open(const cred_t *, struct vnode *, int); 1467c478bd9Sstevel@tonic-gate int secpolicy_sti(const cred_t *); 1477c478bd9Sstevel@tonic-gate int secpolicy_swapctl(const cred_t *); 1487c478bd9Sstevel@tonic-gate int secpolicy_sys_config(const cred_t *, boolean_t); 1497c478bd9Sstevel@tonic-gate int secpolicy_zone_admin(const cred_t *, boolean_t); 1507c478bd9Sstevel@tonic-gate int secpolicy_zone_config(const cred_t *); 1517c478bd9Sstevel@tonic-gate int secpolicy_sys_devices(const cred_t *); 1527c478bd9Sstevel@tonic-gate int secpolicy_systeminfo(const cred_t *); 1537c478bd9Sstevel@tonic-gate int secpolicy_tasksys(const cred_t *); 1547c478bd9Sstevel@tonic-gate int secpolicy_vnode_access(const cred_t *, vnode_t *, uid_t, mode_t); 155134a1f4eSCasper H.S. Dik int secpolicy_vnode_access2(const cred_t *, vnode_t *, uid_t, mode_t, mode_t); 156134a1f4eSCasper H.S. Dik int secpolicy_vnode_any_access(const cred_t *, vnode_t *, uid_t); 157e02bc683SMark Shellenbaum int secpolicy_vnode_chown(const cred_t *, uid_t); 1587c478bd9Sstevel@tonic-gate int secpolicy_vnode_create_gid(const cred_t *); 1597c478bd9Sstevel@tonic-gate int secpolicy_vnode_owner(const cred_t *, uid_t); 1607c478bd9Sstevel@tonic-gate int secpolicy_vnode_remove(const cred_t *); 1617c478bd9Sstevel@tonic-gate int secpolicy_vnode_setdac(const cred_t *, uid_t); 1627c478bd9Sstevel@tonic-gate int secpolicy_vnode_setid_retain(const cred_t *, boolean_t); 1637c478bd9Sstevel@tonic-gate int secpolicy_vnode_setids_setgids(const cred_t *, gid_t); 1647c478bd9Sstevel@tonic-gate int secpolicy_vnode_stky_modify(const cred_t *); 165911106dfSjm199354 int secpolicy_vscan(const cred_t *); 166ea8dc4b6Seschrock int secpolicy_zinject(const cred_t *); 167fa9e4066Sahrens int secpolicy_zfs(const cred_t *); 1682449e17fSsherrym int secpolicy_ucode_update(const cred_t *); 169e6bdcbd5Sdh155122 int secpolicy_sadopen(const cred_t *); 17013f9f30eSmarks void secpolicy_setid_clear(vattr_t *, cred_t *); 171ecd6cf80Smarks void secpolicy_fs_mount_clearopts(cred_t *, struct vfs *); 172f92daba9Smarks int secpolicy_setid_setsticky_clear(vnode_t *, vattr_t *, 173f92daba9Smarks const vattr_t *, cred_t *); 174da6c28aaSamw int secpolicy_xvattr(xvattr_t *, uid_t, cred_t *, vtype_t); 175b26a64aeSjohnlev int secpolicy_xvm_control(const cred_t *); 1767c478bd9Sstevel@tonic-gate 177ddf7fe95Scasper int secpolicy_basic_exec(const cred_t *, vnode_t *); 1787c478bd9Sstevel@tonic-gate int secpolicy_basic_fork(const cred_t *); 179ddf7fe95Scasper int secpolicy_basic_link(const cred_t *); 180134a1f4eSCasper H.S. Dik int secpolicy_basic_file_read(const cred_t *, vnode_t *, const char *); 181134a1f4eSCasper H.S. Dik int secpolicy_basic_file_write(const cred_t *, vnode_t *, const char *); 182634e26ecSCasper H.S. Dik int secpolicy_basic_net_access(const cred_t *); 1837c478bd9Sstevel@tonic-gate int secpolicy_basic_proc(const cred_t *); 1847c478bd9Sstevel@tonic-gate int secpolicy_basic_procinfo(const cred_t *, struct proc *, struct proc *); 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate int secpolicy_gart_access(const cred_t *); 1877c478bd9Sstevel@tonic-gate int secpolicy_gart_map(const cred_t *); 1887c478bd9Sstevel@tonic-gate /* 1897c478bd9Sstevel@tonic-gate * This function to be called from xxfs_setattr(). 1907c478bd9Sstevel@tonic-gate * Must be called with the node's attributes read-write locked. 1917c478bd9Sstevel@tonic-gate * 1927c478bd9Sstevel@tonic-gate * cred_t * - acting credentials 1937c478bd9Sstevel@tonic-gate * struct vnode * - vnode we're operating on 1947c478bd9Sstevel@tonic-gate * struct vattr *va - new attributes, va_mask may be 1957c478bd9Sstevel@tonic-gate * changed on return from a call 1967c478bd9Sstevel@tonic-gate * struct vattr *oldva - old attributes, need include owner 1977c478bd9Sstevel@tonic-gate * and mode only 1987c478bd9Sstevel@tonic-gate * int flags - setattr flags 1997c478bd9Sstevel@tonic-gate * int iaccess(void *node, int mode, cred_t *cr) 2007c478bd9Sstevel@tonic-gate * - non-locking internal access function 2017c478bd9Sstevel@tonic-gate * mode be checked 2027c478bd9Sstevel@tonic-gate * w/ VREAD|VWRITE|VEXEC, not fs 2037c478bd9Sstevel@tonic-gate * internal mode encoding. 2047c478bd9Sstevel@tonic-gate * 2057c478bd9Sstevel@tonic-gate * void *node - internal node (inode, tmpnode) to 2067c478bd9Sstevel@tonic-gate * pass as arg to iaccess 2077c478bd9Sstevel@tonic-gate */ 2087c478bd9Sstevel@tonic-gate int secpolicy_vnode_setattr(cred_t *, struct vnode *, struct vattr *, 2097c478bd9Sstevel@tonic-gate const struct vattr *, int, int (void *, int, cred_t *), void *); 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate /* 2127c478bd9Sstevel@tonic-gate * Test privilege. Audit success or failure, allow privilege debugging. 2137c478bd9Sstevel@tonic-gate * Returns 0 for success, err for failure. 2147c478bd9Sstevel@tonic-gate */ 2157c478bd9Sstevel@tonic-gate #define PRIV_POLICY(cred, priv, all, err, reason) \ 2167c478bd9Sstevel@tonic-gate priv_policy((cred), (priv), (all), (err), (reason)) 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate /* 2197c478bd9Sstevel@tonic-gate * Test privilege. Audit success only, no privilege debugging. 2207c478bd9Sstevel@tonic-gate * Returns 1 for success, and 0 for failure. 2217c478bd9Sstevel@tonic-gate */ 2227c478bd9Sstevel@tonic-gate #define PRIV_POLICY_CHOICE(cred, priv, all) \ 2237c478bd9Sstevel@tonic-gate priv_policy_choice((cred), (priv), (all)) 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate /* 2267c478bd9Sstevel@tonic-gate * Test privilege. No priv_debugging, no auditing. 2277c478bd9Sstevel@tonic-gate * Returns 1 for success, and 0 for failure. 2287c478bd9Sstevel@tonic-gate */ 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate #define PRIV_POLICY_ONLY(cred, priv, all) \ 2317c478bd9Sstevel@tonic-gate priv_policy_only((cred), (priv), (all)) 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate #endif 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2377c478bd9Sstevel@tonic-gate } 2387c478bd9Sstevel@tonic-gate #endif 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate #endif /* _SYS_POLICY_H */ 241