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