Chris PeBenito ab58ad
Chris PeBenito ab58ad
##############################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# core macros for the type enforcement (TE) configuration.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil>, Timothy Fraser  
Chris PeBenito ab58ad
#           Howard Holm (NSA) <hdholm@epoch.ncsc.mil>
Chris PeBenito ab58ad
#           Russell Coker <russell@coker.com.au>
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Macros for groups of classes and 
Chris PeBenito ab58ad
# groups of permissions.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# All directory and file classes
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`dir_file_class_set', `{ dir file lnk_file sock_file fifo_file chr_file blk_file }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# All non-directory file classes.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`file_class_set', `{ file lnk_file sock_file fifo_file chr_file blk_file }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Non-device file classes.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`notdevfile_class_set', `{ file lnk_file sock_file fifo_file }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Device file classes.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`devfile_class_set', `{ chr_file blk_file }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# All socket classes.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`socket_class_set', `{ tcp_socket udp_socket rawip_socket netlink_socket packet_socket unix_stream_socket unix_dgram_socket netlink_route_socket netlink_firewall_socket netlink_tcpdiag_socket netlink_nflog_socket netlink_xfrm_socket netlink_selinux_socket netlink_audit_socket netlink_ip6fw_socket netlink_dnrt_socket netlink_kobject_uevent_socket }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Datagram socket classes.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`dgram_socket_class_set', `{ udp_socket unix_dgram_socket }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Stream socket classes.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`stream_socket_class_set', `{ tcp_socket unix_stream_socket }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Unprivileged socket classes (exclude rawip, netlink, packet).
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`unpriv_socket_class_set', `{ tcp_socket udp_socket unix_stream_socket unix_dgram_socket }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Permissions for getting file attributes.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`stat_file_perms', `{ getattr }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Permissions for executing files.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`x_file_perms', `{ getattr execute }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Permissions for reading files and their attributes.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`r_file_perms', `{ read getattr lock ioctl }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Permissions for reading and executing files.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`rx_file_perms', `{ read getattr lock execute ioctl }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Permissions for reading and writing files and their attributes.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`rw_file_perms', `{ ioctl read getattr lock write append }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Permissions for reading and appending to files.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`ra_file_perms', `{ ioctl read getattr lock append }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for linking, unlinking and renaming files.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`link_file_perms', `{ getattr link unlink rename }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating lnk_files.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`create_lnk_perms', `{ create read getattr setattr link unlink rename }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating and using files.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`create_file_perms', `{ create ioctl read getattr lock write setattr append link unlink rename }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Permissions for reading directories and their attributes.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`r_dir_perms', `{ read getattr lock search ioctl }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Permissions for reading and writing directories and their attributes.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`rw_dir_perms', `{ read getattr lock search ioctl add_name remove_name write }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Permissions for reading and adding names to directories.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`ra_dir_perms', `{ read getattr lock search ioctl add_name write }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating and using directories.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`create_dir_perms', `{ create read getattr lock setattr ioctl link unlink rename search add_name remove_name reparent write rmdir }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions to mount and unmount file systems.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`mount_fs_perms', `{ mount remount unmount getattr }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for using sockets.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`rw_socket_perms', `{ ioctl read getattr write setattr append bind connect getopt setopt shutdown }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating and using sockets.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`create_socket_perms', `{ create rw_socket_perms }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for using stream sockets.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`rw_stream_socket_perms', `{ rw_socket_perms listen accept }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating and using stream sockets.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`create_stream_socket_perms', `{ create_socket_perms listen accept }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating and using sockets.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`connected_socket_perms', `{ create ioctl read getattr write setattr append bind getopt setopt shutdown }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating and using sockets.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`connected_stream_socket_perms', `{ connected_socket_perms listen accept }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating and using netlink sockets.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`create_netlink_socket_perms', `{ create_socket_perms nlmsg_read nlmsg_write }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for using netlink sockets for operations that modify state.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`rw_netlink_socket_perms', `{ create_socket_perms nlmsg_read nlmsg_write }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for using netlink sockets for operations that observe state.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`r_netlink_socket_perms', `{ create_socket_perms nlmsg_read }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for sending all signals.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`signal_perms', `{ sigchld sigkill sigstop signull signal }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for sending and receiving network packets.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`packet_perms', `{ tcp_recv tcp_send udp_recv udp_send rawip_recv rawip_send }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for using System V IPC
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`r_sem_perms', `{ associate getattr read unix_read }')
Chris PeBenito ab58ad
define(`rw_sem_perms', `{ associate getattr read write unix_read unix_write }')
Chris PeBenito ab58ad
define(`create_sem_perms', `{ associate getattr setattr create destroy read write unix_read unix_write }')
Chris PeBenito ab58ad
define(`r_msgq_perms', `{ associate getattr read unix_read }')
Chris PeBenito ab58ad
define(`rw_msgq_perms', `{ associate getattr read write enqueue unix_read unix_write }')
Chris PeBenito ab58ad
define(`create_msgq_perms', `{ associate getattr setattr create destroy read write enqueue unix_read unix_write }')
Chris PeBenito ab58ad
define(`r_shm_perms', `{ associate getattr read unix_read }')
Chris PeBenito ab58ad
define(`rw_shm_perms', `{ associate getattr read write lock unix_read unix_write }')
Chris PeBenito ab58ad
define(`create_shm_perms', `{ associate getattr setattr create destroy read write lock unix_read unix_write }')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Macros for type transition rules and
Chris PeBenito ab58ad
# access vector rules.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Simple combinations for reading and writing both
Chris PeBenito ab58ad
# directories and files.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
define(`r_dir_file', `
Chris PeBenito ab58ad
allow $1 $2:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1 $2:file r_file_perms;
Chris PeBenito ab58ad
allow $1 $2:lnk_file { getattr read };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`rw_dir_file', `
Chris PeBenito ab58ad
allow $1 $2:dir rw_dir_perms;
Chris PeBenito ab58ad
allow $1 $2:file rw_file_perms;
Chris PeBenito ab58ad
allow $1 $2:lnk_file { getattr read };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`ra_dir_file', `
Chris PeBenito ab58ad
allow $1 $2:dir ra_dir_perms;
Chris PeBenito ab58ad
allow $1 $2:file ra_file_perms;
Chris PeBenito ab58ad
allow $1 $2:lnk_file { getattr read };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`ra_dir_create_file', `
Chris PeBenito ab58ad
allow $1 $2:dir ra_dir_perms;
Chris PeBenito ab58ad
allow $1 $2:file { create ra_file_perms };
Chris PeBenito ab58ad
allow $1 $2:lnk_file { create read getattr };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`rw_dir_create_file', `
Chris PeBenito ab58ad
allow $1 $2:dir rw_dir_perms;
Chris PeBenito ab58ad
allow $1 $2:file create_file_perms;
Chris PeBenito ab58ad
allow $1 $2:lnk_file create_lnk_perms;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`create_dir_file', `
Chris PeBenito ab58ad
allow $1 $2:dir create_dir_perms;
Chris PeBenito ab58ad
allow $1 $2:file create_file_perms;
Chris PeBenito ab58ad
allow $1 $2:lnk_file create_lnk_perms;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`create_dir_notdevfile', `
Chris PeBenito ab58ad
allow $1 $2:dir create_dir_perms;
Chris PeBenito ab58ad
allow $1 $2:{ file sock_file fifo_file } create_file_perms;
Chris PeBenito ab58ad
allow $1 $2:lnk_file create_lnk_perms;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`create_append_log_file', `
Chris PeBenito ab58ad
allow $1 $2:dir { read getattr search add_name write };
Chris PeBenito ab58ad
allow $1 $2:file { create ioctl getattr setattr append link };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
##################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_ps(domain1, domain2)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authorize domain1 to see /proc entries for domain2 (see it in ps output)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_ps',`
Chris PeBenito ab58ad
allow $1 $2:dir { search getattr read };
Chris PeBenito ab58ad
allow $1 $2:{ file lnk_file } { read getattr };
Chris PeBenito ab58ad
allow $1 $2:process getattr;
Chris PeBenito ab58ad
# We need to suppress this denial because procps tries to access
Chris PeBenito ab58ad
# /proc/pid/environ and this now triggers a ptrace check in recent kernels
Chris PeBenito ab58ad
# (2.4 and 2.6).  Might want to change procps to not do this, or only if
Chris PeBenito ab58ad
# running in a privileged domain.
Chris PeBenito ab58ad
dontaudit $1 $2:process ptrace;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
##################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_getsecurity(domain)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authorize a domain to get security policy decisions.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_getsecurity',`
Chris PeBenito ab58ad
# Get the selinuxfs mount point via /proc/self/mounts.
Chris PeBenito ab58ad
allow $1 proc_t:dir search;
Chris PeBenito ab58ad
allow $1 proc_t:{ file lnk_file } { getattr read };
Chris PeBenito ab58ad
allow $1 self:dir search;
Chris PeBenito ab58ad
allow $1 self:file { getattr read };
Chris PeBenito ab58ad
# Access selinuxfs.
Chris PeBenito ab58ad
allow $1 security_t:dir { read search getattr };
Chris PeBenito ab58ad
allow $1 security_t:file { getattr read write };
Chris PeBenito ab58ad
allow $1 security_t:security { check_context compute_av compute_create compute_relabel compute_user };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
##################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_setenforce(domain)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authorize a domain to set the enforcing flag.
Chris PeBenito ab58ad
# Due to its sensitivity, always audit this permission.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_setenforce',`
Chris PeBenito ab58ad
# Get the selinuxfs mount point via /proc/self/mounts.
Chris PeBenito ab58ad
allow $1 proc_t:dir search;
Chris PeBenito ab58ad
allow $1 proc_t:lnk_file read;
Chris PeBenito ab58ad
allow $1 self:dir search;
Chris PeBenito ab58ad
allow $1 self:file { getattr read };
Chris PeBenito ab58ad
# Access selinuxfs.
Chris PeBenito ab58ad
allow $1 security_t:dir { read search getattr };
Chris PeBenito ab58ad
allow $1 security_t:file { getattr read write };
Chris PeBenito 8967bf
if (!secure_mode_policyload) {
Chris PeBenito ab58ad
allow $1 security_t:security setenforce;
Chris PeBenito ab58ad
auditallow $1 security_t:security setenforce;
Chris PeBenito 8967bf
}dnl end if !secure_mode_policyload
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
##################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_setbool(domain)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authorize a domain to set a policy boolean.
Chris PeBenito ab58ad
# Due to its sensitivity, always audit this permission.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_setbool',`
Chris PeBenito ab58ad
# Get the selinuxfs mount point via /proc/self/mounts.
Chris PeBenito ab58ad
allow $1 proc_t:dir search;
Chris PeBenito ab58ad
allow $1 proc_t:lnk_file read;
Chris PeBenito ab58ad
allow $1 self:dir search;
Chris PeBenito ab58ad
allow $1 self:file { getattr read };
Chris PeBenito ab58ad
# Access selinuxfs.
Chris PeBenito ab58ad
allow $1 security_t:dir { read search getattr };
Chris PeBenito ab58ad
allow $1 security_t:file { getattr read write };
Chris PeBenito 8967bf
if (!secure_mode_policyload) {
Chris PeBenito ab58ad
allow $1 security_t:security setbool;
Chris PeBenito ab58ad
auditallow $1 security_t:security setbool;
Chris PeBenito 8967bf
}dnl end if !secure_mode_policyload
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
##################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_setsecparam(domain)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authorize a domain to set security parameters.
Chris PeBenito ab58ad
# Due to its sensitivity, always audit this permission.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_setsecparam',`
Chris PeBenito ab58ad
# Get the selinuxfs mount point via /proc/self/mounts.
Chris PeBenito ab58ad
allow $1 proc_t:dir search;
Chris PeBenito ab58ad
allow $1 proc_t:lnk_file read;
Chris PeBenito ab58ad
allow $1 self:dir search;
Chris PeBenito ab58ad
allow $1 self:file { getattr read };
Chris PeBenito ab58ad
# Access selinuxfs.
Chris PeBenito ab58ad
allow $1 security_t:dir { read search getattr };
Chris PeBenito ab58ad
allow $1 security_t:file { getattr read write };
Chris PeBenito ab58ad
allow $1 security_t:security setsecparam;
Chris PeBenito ab58ad
auditallow $1 security_t:security setsecparam;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
##################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_loadpol(domain)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authorize a domain to load a policy configuration.
Chris PeBenito ab58ad
# Due to its sensitivity, always audit this permission.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_loadpol',`
Chris PeBenito ab58ad
# Get the selinuxfs mount point via /proc/self/mounts.
Chris PeBenito ab58ad
allow $1 proc_t:dir search;
Chris PeBenito ab58ad
allow $1 proc_t:lnk_file read;
Chris PeBenito ab58ad
allow $1 proc_t:file { getattr read };
Chris PeBenito ab58ad
allow $1 self:dir search;
Chris PeBenito ab58ad
allow $1 self:file { getattr read };
Chris PeBenito ab58ad
# Access selinuxfs.
Chris PeBenito ab58ad
allow $1 security_t:dir { read search getattr };
Chris PeBenito ab58ad
allow $1 security_t:file { getattr read write };
Chris PeBenito 8967bf
if (!secure_mode_policyload) {
Chris PeBenito ab58ad
allow $1 security_t:security load_policy;
Chris PeBenito ab58ad
auditallow $1 security_t:security load_policy;
Chris PeBenito 8967bf
}dnl end if !secure_mode_policyload
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# domain_trans(parent_domain, program_type, child_domain)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for transitioning to a new domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`domain_trans',`
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Allow the process to transition to the new domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow $1 $3:process transition;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Do not audit when glibc secure mode is enabled upon the transition.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
dontaudit $1 $3:process noatsecure;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Do not audit when signal-related state is cleared upon the transition.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
dontaudit $1 $3:process siginh;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Do not audit when resource limits are reset upon the transition.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
dontaudit $1 $3:process rlimitinh;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Allow the process to execute the program.
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
allow $1 $2:file { read x_file_perms };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Allow the process to reap the new domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow $3 $1:process sigchld;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Allow the new domain to inherit and use file 
Chris PeBenito ab58ad
# descriptions from the creating process and vice versa.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow $3 $1:fd use;
Chris PeBenito ab58ad
allow $1 $3:fd use;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Allow the new domain to write back to the old domain via a pipe.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow $3 $1:fifo_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Allow the new domain to read and execute the program.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow $3 $2:file rx_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Allow the new domain to be entered via the program.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow $3 $2:file entrypoint;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# domain_auto_trans(parent_domain, program_type, child_domain)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define a default domain transition and allow it.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`domain_auto_trans',`
Chris PeBenito ab58ad
domain_trans($1,$2,$3)
Chris PeBenito ab58ad
type_transition $1 $2:process $3;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_ptrace(domain, domain)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for running ptrace (strace or gdb) on another domain
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_ptrace',`
Chris PeBenito ab58ad
allow $1 $2:process ptrace;
Chris PeBenito ab58ad
allow $2 $1:process sigchld;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_exec(domain, type)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for executing programs with
Chris PeBenito ab58ad
# a specified type without changing domains.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_exec',`
Chris PeBenito ab58ad
allow $1 $2:file { rx_file_perms execute_no_trans };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# this is an internal macro used by can_create
Chris PeBenito ab58ad
define(`can_create_internal', `
Chris PeBenito ab58ad
ifelse(`$3', `dir', `
Chris PeBenito ab58ad
allow $1 $2:$3 create_dir_perms;
Chris PeBenito ab58ad
', `$3', `lnk_file', `
Chris PeBenito ab58ad
allow $1 $2:$3 create_lnk_perms;
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
allow $1 $2:$3 create_file_perms;
Chris PeBenito ab58ad
')dnl end if dir
Chris PeBenito ab58ad
')dnl end can_create_internal
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_create(domain, file_type, object_class)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating files of the specified type and class
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_create', `
Chris PeBenito ab58ad
ifelse(regexp($3, `\w'), -1, `', `
Chris PeBenito ab58ad
can_create_internal($1, $2, regexp($3, `\(\w+\)', `\1'))
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_create($1, $2, regexp($3, `\w+\(.*\)', `\1'))
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# file_type_trans(domain, dir_type, file_type)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for transitioning to a new file type.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`file_type_trans',`
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Allow the process to modify the directory.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow $1 $2:dir rw_dir_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Allow the process to create the file.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
ifelse(`$4', `', `
Chris PeBenito ab58ad
can_create($1, $3, `{ file lnk_file sock_file fifo_file dir }')
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
can_create($1, $3, $4)
Chris PeBenito ab58ad
')dnl end if param 4 specified
Chris PeBenito ab58ad
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# file_type_auto_trans(creator_domain, parent_directory_type, file_type, object_class)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# the object class will default to notdevfile_class_set if not specified as
Chris PeBenito ab58ad
# the fourth parameter
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define a default file type transition and allow it.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`file_type_auto_trans',`
Chris PeBenito ab58ad
ifelse(`$4', `', `
Chris PeBenito ab58ad
file_type_trans($1,$2,$3)
Chris PeBenito ab58ad
type_transition $1 $2:dir $3;
Chris PeBenito ab58ad
type_transition $1 $2:notdevfile_class_set $3;
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
file_type_trans($1,$2,$3,$4)
Chris PeBenito ab58ad
type_transition $1 $2:$4 $3;
Chris PeBenito ab58ad
')dnl end ifelse
Chris PeBenito ab58ad
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_unix_connect(client, server)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for establishing a Unix stream connection.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_unix_connect',`
Chris PeBenito ab58ad
allow $1 $2:unix_stream_socket connectto;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_unix_send(sender, receiver)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for sending Unix datagrams.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_unix_send',`
Chris PeBenito ab58ad
allow $1 $2:unix_dgram_socket sendto;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_tcp_connect(client, server)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for establishing a TCP connection.
Chris PeBenito ab58ad
# Irrelevant until we have labeled networking.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_tcp_connect',`
Chris PeBenito ab58ad
#allow $1 $2:tcp_socket { connectto recvfrom };
Chris PeBenito ab58ad
#allow $2 $1:tcp_socket { acceptfrom recvfrom };
Chris PeBenito ab58ad
#allow $2 kernel_t:tcp_socket recvfrom;
Chris PeBenito ab58ad
#allow $1 kernel_t:tcp_socket recvfrom;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_udp_send(sender, receiver)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for sending/receiving UDP datagrams.
Chris PeBenito ab58ad
# Irrelevant until we have labeled networking.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_udp_send',`
Chris PeBenito ab58ad
#allow $1 $2:udp_socket sendto;
Chris PeBenito ab58ad
#allow $2 $1:udp_socket recvfrom;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
##################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# base_pty_perms(domain_prefix)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Base permissions used for can_create_pty() and can_create_other_pty()
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`base_pty_perms', `
Chris PeBenito ab58ad
# Access the pty master multiplexer.
Chris PeBenito ab58ad
allow $1_t ptmx_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_t devpts_t:filesystem getattr;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# allow searching /dev/pts
Chris PeBenito ab58ad
allow $1_t devpts_t:dir { getattr read search };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# ignore old BSD pty devices
Chris PeBenito ab58ad
dontaudit $1_t bsdpty_device_t:chr_file { getattr read write };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
##################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# pty_slave_label(domain_prefix, attributes)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# give access to a slave pty but do not allow creating new ptys
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`pty_slave_label', `
Chris PeBenito ab58ad
type $1_devpts_t, file_type, sysadmfile, ptyfile $2;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow the pty to be associated with the file system.
Chris PeBenito ab58ad
allow $1_devpts_t devpts_t:filesystem associate;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Label pty files with a derived type.
Chris PeBenito ab58ad
type_transition $1_t devpts_t:chr_file $1_devpts_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# allow searching /dev/pts
Chris PeBenito ab58ad
allow $1_t devpts_t:dir { getattr read search };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read and write my pty files.
Chris PeBenito ab58ad
allow $1_t $1_devpts_t:chr_file { setattr rw_file_perms };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
##################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_create_pty(domain_prefix, attributes)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating ptys.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_create_pty',`
Chris PeBenito ab58ad
base_pty_perms($1)
Chris PeBenito ab58ad
pty_slave_label($1, `$2')
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
##################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_create_other_pty(domain_prefix,other_domain)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Permissions for creating ptys for another domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_create_other_pty',`
Chris PeBenito ab58ad
base_pty_perms($1)
Chris PeBenito ab58ad
# Label pty files with a derived type.
Chris PeBenito ab58ad
type_transition $1_t devpts_t:chr_file $2_devpts_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read and write pty files.
Chris PeBenito ab58ad
allow $1_t $2_devpts_t:chr_file { setattr rw_file_perms };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# general_domain_access(domain)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Grant permissions within the domain.
Chris PeBenito ab58ad
# This includes permissions to processes, /proc/PID files,
Chris PeBenito ab58ad
# file descriptors, pipes, Unix sockets, and System V IPC objects
Chris PeBenito ab58ad
# labeled with the domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`general_domain_access',`
Chris PeBenito ab58ad
# Access other processes in the same domain.
Chris PeBenito ab58ad
# Omits ptrace, setcurrent, setexec, setfscreate, setrlimit, execmem, execstack and execheap.
Chris PeBenito ab58ad
# These must be granted separately if desired.
Chris PeBenito ab58ad
allow $1 self:process ~{ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap};
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access /proc/PID files for processes in the same domain.
Chris PeBenito ab58ad
allow $1 self:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1 self:notdevfile_class_set r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access file descriptions, pipes, and sockets
Chris PeBenito ab58ad
# created by processes in the same domain.
Chris PeBenito ab58ad
allow $1 self:fd *;
Chris PeBenito ab58ad
allow $1 self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
allow $1 self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow $1 self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow the domain to communicate with other processes in the same domain.
Chris PeBenito ab58ad
allow $1 self:unix_dgram_socket sendto;
Chris PeBenito ab58ad
allow $1 self:unix_stream_socket connectto;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access System V IPC objects created by processes in the same domain.
Chris PeBenito ab58ad
allow $1 self:sem  create_sem_perms;
Chris PeBenito ab58ad
allow $1 self:msg  { send receive };
Chris PeBenito ab58ad
allow $1 self:msgq create_msgq_perms;
Chris PeBenito ab58ad
allow $1 self:shm  create_shm_perms;
Chris PeBenito ab58ad
allow $1 unpriv_userdomain:fd use;
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Every app is asking for ypbind so I am adding this here, 
Chris PeBenito ab58ad
# eventually this should become can_nsswitch
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
can_ypbind($1)
Chris PeBenito ab58ad
allow $1 autofs_t:dir { search getattr };
Chris PeBenito ab58ad
')dnl end general_domain_access