|
Chris PeBenito |
ab58ad |
##############################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Global 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> and 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 |
##################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# can_setexec(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Authorize a domain to set its exec context
|
|
Chris PeBenito |
ab58ad |
# (via /proc/pid/attr/exec).
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`can_setexec',`
|
|
Chris PeBenito |
ab58ad |
allow $1 self:process setexec;
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_t:{ file lnk_file } read;
|
|
Chris PeBenito |
ab58ad |
allow $1 self:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 self:file { getattr read write };
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
##################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# can_getcon(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Authorize a domain to get its context
|
|
Chris PeBenito |
ab58ad |
# (via /proc/pid/attr/current).
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`can_getcon',`
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_t:{ file lnk_file } read;
|
|
Chris PeBenito |
ab58ad |
allow $1 self:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 self:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
allow $1 self:process getattr;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
##################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# can_setcon(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Authorize a domain to set its current context
|
|
Chris PeBenito |
ab58ad |
# (via /proc/pid/attr/current).
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`can_setcon',`
|
|
Chris PeBenito |
ab58ad |
allow $1 self:process setcurrent;
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_t:{ file lnk_file } read;
|
|
Chris PeBenito |
ab58ad |
allow $1 self:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 self:file { getattr read write };
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
##################################
|
|
Chris PeBenito |
ab58ad |
# read_sysctl(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Permissions for reading sysctl variables.
|
|
Chris PeBenito |
ab58ad |
# If the second parameter is full, allow
|
|
Chris PeBenito |
ab58ad |
# reading of any sysctl variables, else only
|
|
Chris PeBenito |
ab58ad |
# sysctl_kernel_t.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`read_sysctl', `
|
|
Chris PeBenito |
ab58ad |
# Read system variables in /sys.
|
|
Chris PeBenito |
ab58ad |
ifelse($2,`full', `
|
|
Chris PeBenito |
ab58ad |
allow $1 sysctl_type:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 sysctl_type:file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
', `
|
|
Chris PeBenito |
ab58ad |
allow $1 sysctl_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 sysctl_kernel_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 sysctl_kernel_t:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
')dnl read_sysctl
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
##################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# can_setfscreate(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Authorize a domain to set its fscreate context
|
|
Chris PeBenito |
ab58ad |
# (via /proc/pid/attr/fscreate).
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`can_setfscreate',`
|
|
Chris PeBenito |
ab58ad |
allow $1 self:process setfscreate;
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_t:{ file lnk_file } read;
|
|
Chris PeBenito |
ab58ad |
allow $1 self:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 self:file { getattr read write };
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# uses_shlib(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Permissions for using shared libraries.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`uses_shlib',`
|
|
Chris PeBenito |
ab58ad |
allow $1 { root_t usr_t lib_t etc_t }:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 lib_t:lnk_file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 ld_so_t:file rx_file_perms;
|
|
Chris PeBenito |
ab58ad |
#allow $1 ld_so_t:file execute_no_trans;
|
|
Chris PeBenito |
ab58ad |
allow $1 ld_so_t:lnk_file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 { texrel_shlib_t shlib_t }:file rx_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 { texrel_shlib_t shlib_t }:lnk_file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 texrel_shlib_t:file execmod;
|
|
Chris PeBenito |
ab58ad |
allow $1 ld_so_cache_t:file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 device_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1 null_device_t:chr_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# can_exec_any(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Permissions for executing a variety
|
|
Chris PeBenito |
ab58ad |
# of executable types.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`can_exec_any',`
|
|
Chris PeBenito |
ab58ad |
allow $1 { bin_t sbin_t lib_t etc_t }:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 { bin_t sbin_t etc_t }:lnk_file { getattr read };
|
|
Chris PeBenito |
ab58ad |
uses_shlib($1)
|
|
Chris PeBenito |
ab58ad |
can_exec($1, etc_t)
|
|
Chris PeBenito |
ab58ad |
can_exec($1, lib_t)
|
|
Chris PeBenito |
ab58ad |
can_exec($1, bin_t)
|
|
Chris PeBenito |
ab58ad |
can_exec($1, sbin_t)
|
|
Chris PeBenito |
ab58ad |
can_exec($1, exec_type)
|
|
Chris PeBenito |
ab58ad |
can_exec($1, ld_so_t)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# can_sysctl(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Permissions for modifying sysctl parameters.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`can_sysctl',`
|
|
Chris PeBenito |
ab58ad |
allow $1 sysctl_type:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 sysctl_type:file { setattr rw_file_perms };
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
##################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# read_locale(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Permissions for reading the locale data,
|
|
Chris PeBenito |
ab58ad |
# /etc/localtime and the files that it links to
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`read_locale', `
|
|
Chris PeBenito |
ab58ad |
allow $1 etc_t:lnk_file read;
|
|
Chris PeBenito |
ab58ad |
allow $1 lib_t:file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1, locale_t)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`can_access_pty', `
|
|
Chris PeBenito |
ab58ad |
allow $1 devpts_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 $2_devpts_t:chr_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
###################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# access_terminal(domain, typeprefix)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Permissions for accessing the terminal
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`access_terminal', `
|
|
Chris PeBenito |
ab58ad |
allow $1 $2_tty_device_t:chr_file { read write getattr ioctl };
|
|
Chris PeBenito |
ab58ad |
allow $1 devtty_t:chr_file { read write getattr ioctl };
|
|
Chris PeBenito |
ab58ad |
can_access_pty($1, $2)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# general_proc_read_access(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Grant read/search permissions to most of /proc, excluding
|
|
Chris PeBenito |
ab58ad |
# the /proc/PID directories and the /proc/kmsg and /proc/kcore files.
|
|
Chris PeBenito |
ab58ad |
# The general_domain_access macro grants access to the domain /proc/PID
|
|
Chris PeBenito |
ab58ad |
# directories, but not to other domains. Only permissions to stat
|
|
Chris PeBenito |
ab58ad |
# are granted for /proc/kmsg and /proc/kcore, since these files are more
|
|
Chris PeBenito |
ab58ad |
# sensitive.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`general_proc_read_access',`
|
|
Chris PeBenito |
ab58ad |
# Read system information files in /proc.
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1, proc_t)
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1, proc_net_t)
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_mdstat_t:file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Stat /proc/kmsg and /proc/kcore.
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_fs:file stat_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read system variables in /proc/sys.
|
|
Chris PeBenito |
ab58ad |
read_sysctl($1)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# base_file_read_access(domain)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Grant read/search permissions to a few system file types.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`base_file_read_access',`
|
|
Chris PeBenito |
ab58ad |
# Read /.
|
|
Chris PeBenito |
ab58ad |
allow $1 root_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 root_t:notdevfile_class_set r_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read /home.
|
|
Chris PeBenito |
ab58ad |
allow $1 home_root_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read /usr.
|
|
Chris PeBenito |
ab58ad |
allow $1 usr_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 usr_t:notdevfile_class_set r_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read bin and sbin directories.
|
|
Chris PeBenito |
ab58ad |
allow $1 bin_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 bin_t:notdevfile_class_set r_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 sbin_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 sbin_t:notdevfile_class_set r_file_perms;
|
|
Chris PeBenito |
ab58ad |
read_sysctl($1)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1, selinux_config_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
if (read_default_t) {
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Read default_t
|
|
Chris PeBenito |
ab58ad |
#.
|
|
Chris PeBenito |
ab58ad |
allow $1 default_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 default_t:notdevfile_class_set r_file_perms;
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#######################
|
|
Chris PeBenito |
ab58ad |
# daemon_core_rules(domain_prefix, attribs)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Define the core rules for a daemon, used by both daemon_base_domain() and
|
|
Chris PeBenito |
ab58ad |
# init_service_domain().
|
|
Chris PeBenito |
ab58ad |
# Attribs is the list of attributes which must start with "," if it is not empty
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Author: Russell Coker <russell@coker.com.au>
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`daemon_core_rules', `
|
|
Chris PeBenito |
ab58ad |
type $1_t, domain, privlog, daemon $2;
|
|
Chris PeBenito |
ab58ad |
type $1_exec_t, file_type, sysadmfile, exec_type;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t self:capability sys_tty_config;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
role system_r types $1_t;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Inherit and use descriptors from init.
|
|
Chris PeBenito |
ab58ad |
allow $1_t init_t:fd use;
|
|
Chris PeBenito |
ab58ad |
allow $1_t init_t:process sigchld;
|
|
Chris PeBenito |
ab58ad |
allow $1_t self:process { signal_perms fork };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
uses_shlib($1_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_t { self proc_t }:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1_t { self proc_t }:lnk_file { getattr read };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_t device_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
ifdef(`udev.te', `
|
|
Chris PeBenito |
ab58ad |
allow $1_t udev_tdb_t:file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
')dnl end if udev.te
|
|
Chris PeBenito |
ab58ad |
allow $1_t null_device_t:chr_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t console_device_t:chr_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t unpriv_userdomain:fd use;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1_t, sysfs_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_t autofs_t:dir { search getattr };
|
|
Chris PeBenito |
ab58ad |
ifdef(`targeted_policy', `
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t { tty_device_t devpts_t }:chr_file { read write };
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t root_t:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
')dnl end if targeted_policy
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
')dnl end macro daemon_core_rules
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#######################
|
|
Chris PeBenito |
ab58ad |
# init_service_domain(domain_prefix, attribs)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Define a domain for a program that is run from init
|
|
Chris PeBenito |
ab58ad |
# Attribs is the list of attributes which must start with "," if it is not empty
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Author: Russell Coker <russell@coker.com.au>
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`init_service_domain', `
|
|
Chris PeBenito |
ab58ad |
daemon_core_rules($1, `$2')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans(init_t, $1_exec_t, $1_t)
|
|
Chris PeBenito |
ab58ad |
')dnl
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#######################
|
|
Chris PeBenito |
ab58ad |
# daemon_base_domain(domain_prefix, attribs)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Define a daemon domain with a base set of type declarations
|
|
Chris PeBenito |
ab58ad |
# and permissions that are common to most daemons.
|
|
Chris PeBenito |
ab58ad |
# attribs is the list of attributes which must start with "," if it is not empty
|
|
Chris PeBenito |
ab58ad |
# nosysadm may be given as an optional third parameter, to specify that the
|
|
Chris PeBenito |
ab58ad |
# sysadmin should not transition to the domain when directly calling the executable
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Author: Russell Coker <russell@coker.com.au>
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`daemon_base_domain', `
|
|
Chris PeBenito |
ab58ad |
daemon_core_rules($1, `$2')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
rhgb_domain($1_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
read_sysctl($1_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
ifdef(`direct_sysadm_daemon', `
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t admin_tty_type:chr_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Allows user to define a tunable to disable domain transition
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
ifelse(index(`$2',`transitionbool'), -1, `', `
|
|
Chris PeBenito |
ab58ad |
bool $1_disable_trans false;
|
|
Chris PeBenito |
ab58ad |
if ($1_disable_trans) {
|
|
Chris PeBenito |
ab58ad |
can_exec(initrc_t, $1_exec_t)
|
|
Chris PeBenito |
ab58ad |
can_exec(sysadm_t, $1_exec_t)
|
|
Chris PeBenito |
ab58ad |
} else {
|
|
Chris PeBenito |
ab58ad |
') dnl transitionbool
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans(initrc_t, $1_exec_t, $1_t)
|
|
Chris PeBenito |
8967bf |
|
|
Chris PeBenito |
ab58ad |
allow initrc_t $1_t:process { noatsecure siginh rlimitinh };
|
|
Chris PeBenito |
ab58ad |
ifdef(`direct_sysadm_daemon', `
|
|
Chris PeBenito |
ab58ad |
ifelse(`$3', `nosysadm', `', `
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans(sysadm_t, $1_exec_t, $1_t)
|
|
Chris PeBenito |
ab58ad |
allow sysadm_t $1_t:process { noatsecure siginh rlimitinh };
|
|
Chris PeBenito |
ab58ad |
')dnl end nosysadm
|
|
Chris PeBenito |
8967bf |
')dnl end direct_sysadm_daemon
|
|
Chris PeBenito |
ab58ad |
ifelse(index(`$2', `transitionbool'), -1, `', `
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
') dnl end transitionbool
|
|
Chris PeBenito |
ab58ad |
ifdef(`direct_sysadm_daemon', `
|
|
Chris PeBenito |
ab58ad |
ifelse(`$3', `nosysadm', `', `
|
|
Chris PeBenito |
ab58ad |
role_transition sysadm_r $1_exec_t system_r;
|
|
Chris PeBenito |
ab58ad |
')dnl end nosysadm
|
|
Chris PeBenito |
ab58ad |
')dnl end direct_sysadm_daemon
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_t privfd:fd use;
|
|
Chris PeBenito |
ab58ad |
ifdef(`newrole.te', `allow $1_t newrole_t:process sigchld;')
|
|
Chris PeBenito |
ab58ad |
allow $1_t initrc_devpts_t:chr_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
')dnl
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# allow a domain to create its own files under /var/run and to create files
|
|
Chris PeBenito |
ab58ad |
# in directories that are created for it. $2 is an optional list of
|
|
Chris PeBenito |
ab58ad |
# classes to use; default is file.
|
|
Chris PeBenito |
ab58ad |
define(`var_run_domain', `
|
|
Chris PeBenito |
ab58ad |
type $1_var_run_t, file_type, sysadmfile, pidfile;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
ifelse(`$2', `', `
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans($1_t, var_run_t, $1_var_run_t, file)
|
|
Chris PeBenito |
ab58ad |
', `
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans($1_t, var_run_t, $1_var_run_t, $2)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
allow $1_t var_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_var_run_t:dir rw_dir_perms;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#######################
|
|
Chris PeBenito |
ab58ad |
# daemon_domain(domain_prefix, attribs)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# see daemon_base_domain for calling details
|
|
Chris PeBenito |
ab58ad |
# daemon_domain defines some additional privileges needed by many domains,
|
|
Chris PeBenito |
ab58ad |
# like pid files and locale support
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`daemon_domain', `
|
|
Chris PeBenito |
ab58ad |
ifdef(`targeted_policy', `
|
|
Chris PeBenito |
ab58ad |
daemon_base_domain($1, `$2, transitionbool', $3)
|
|
Chris PeBenito |
ab58ad |
', `
|
|
Chris PeBenito |
ab58ad |
daemon_base_domain($1, `$2', $3)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
# Create pid file.
|
|
Chris PeBenito |
ab58ad |
allow $1_t var_t:dir { getattr search };
|
|
Chris PeBenito |
ab58ad |
var_run_domain($1)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_t devtty_t:chr_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for daemons that look at /root on startup
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t sysadm_home_dir_t:dir search;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for df
|
|
Chris PeBenito |
ab58ad |
allow $1_t fs_type:filesystem getattr;
|
|
Chris PeBenito |
ab58ad |
allow $1_t removable_t:filesystem getattr;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
read_locale($1_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for localization
|
|
Chris PeBenito |
ab58ad |
allow $1_t lib_t:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
')dnl end daemon_domain macro
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`uses_authbind',
|
|
Chris PeBenito |
ab58ad |
`domain_auto_trans($1, authbind_exec_t, authbind_t)
|
|
Chris PeBenito |
ab58ad |
allow authbind_t $1:process sigchld;
|
|
Chris PeBenito |
ab58ad |
allow authbind_t $1:fd use;
|
|
Chris PeBenito |
ab58ad |
allow authbind_t $1:{ tcp_socket udp_socket } rw_socket_perms;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# define a sub-domain, $1_t is the parent domain, $2 is the name
|
|
Chris PeBenito |
ab58ad |
# of the sub-domain.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`daemon_sub_domain', `
|
|
Chris PeBenito |
ab58ad |
# $1 is the parent domain (or domains), $2_t is the child domain,
|
|
Chris PeBenito |
ab58ad |
# and $3 is any attributes to apply to the child
|
|
Chris PeBenito |
ab58ad |
type $2_t, domain, privlog, daemon $3;
|
|
Chris PeBenito |
ab58ad |
type $2_exec_t, file_type, sysadmfile, exec_type;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
role system_r types $2_t;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
ifelse(index(`$3',`transitionbool'), -1, `
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans($1, $2_exec_t, $2_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
', `
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
bool $2_disable_trans false;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
if (! $2_disable_trans) {
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans($1, $2_exec_t, $2_t)
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
');
|
|
Chris PeBenito |
ab58ad |
# Inherit and use descriptors from parent.
|
|
Chris PeBenito |
ab58ad |
allow $2_t $1:fd use;
|
|
Chris PeBenito |
ab58ad |
allow $2_t $1:process sigchld;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $2_t self:process signal_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
uses_shlib($2_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $2_t { self proc_t }:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $2_t { self proc_t }:lnk_file read;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $2_t device_t:dir getattr;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# grant access to /tmp
|
|
Chris PeBenito |
ab58ad |
# by default, only plain files and dirs may be stored there.
|
|
Chris PeBenito |
ab58ad |
# This can be overridden with a third parameter
|
|
Chris PeBenito |
ab58ad |
define(`tmp_domain', `
|
|
Chris PeBenito |
ab58ad |
type $1_tmp_t, file_type, sysadmfile, polymember, tmpfile $2;
|
|
Chris PeBenito |
ab58ad |
ifelse($3, `',
|
|
Chris PeBenito |
ab58ad |
`file_type_auto_trans($1_t, tmp_t, $1_tmp_t, `{ file dir }')',
|
|
Chris PeBenito |
ab58ad |
`file_type_auto_trans($1_t, tmp_t, $1_tmp_t, `$3')')
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# grant access to /tmp. Do not perform an automatic transition.
|
|
Chris PeBenito |
ab58ad |
define(`tmp_domain_notrans', `
|
|
Chris PeBenito |
ab58ad |
type $1_tmp_t, file_type, sysadmfile, polymember, tmpfile $2;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`tmpfs_domain', `
|
|
Chris PeBenito |
ab58ad |
ifdef(`$1_tmpfs_t_defined',`', `
|
|
Chris PeBenito |
ab58ad |
define(`$1_tmpfs_t_defined')
|
|
Chris PeBenito |
ab58ad |
type $1_tmpfs_t, file_type, sysadmfile, tmpfsfile;
|
|
Chris PeBenito |
ab58ad |
# Use this type when creating tmpfs/shm objects.
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans($1_t, tmpfs_t, $1_tmpfs_t)
|
|
Chris PeBenito |
ab58ad |
allow $1_tmpfs_t tmpfs_t:filesystem associate;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`var_lib_domain', `
|
|
Chris PeBenito |
ab58ad |
type $1_var_lib_t, file_type, sysadmfile;
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans($1_t, var_lib_t, $1_var_lib_t, file)
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_var_lib_t:dir rw_dir_perms;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`log_domain', `
|
|
Chris PeBenito |
ab58ad |
type $1_log_t, file_type, sysadmfile, logfile;
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans($1_t, var_log_t, $1_log_t, file)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`logdir_domain', `
|
|
Chris PeBenito |
ab58ad |
log_domain($1)
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_log_t:dir { setattr rw_dir_perms };
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`etc_domain', `
|
|
Chris PeBenito |
ab58ad |
type $1_etc_t, file_type, sysadmfile, usercanread;
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_etc_t:file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`etcdir_domain', `
|
|
Chris PeBenito |
ab58ad |
etc_domain($1)
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_etc_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_etc_t:lnk_file { getattr read };
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`append_log_domain', `
|
|
Chris PeBenito |
ab58ad |
type $1_log_t, file_type, sysadmfile, logfile;
|
|
Chris PeBenito |
ab58ad |
allow $1_t var_log_t:dir ra_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_log_t:file { create ra_file_perms };
|
|
Chris PeBenito |
ab58ad |
type_transition $1_t var_log_t:file $1_log_t;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`append_logdir_domain', `
|
|
Chris PeBenito |
ab58ad |
append_log_domain($1)
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_log_t:dir { setattr ra_dir_perms };
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`lock_domain', `
|
|
Chris PeBenito |
ab58ad |
type $1_lock_t, file_type, sysadmfile, lockfile;
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans($1_t, var_lock_t, $1_lock_t, file)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#######################
|
|
Chris PeBenito |
ab58ad |
# application_domain(domain_prefix)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Define a domain with a base set of type declarations
|
|
Chris PeBenito |
ab58ad |
# and permissions that are common to simple applications.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Author: Russell Coker <russell@coker.com.au>
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`application_domain', `
|
|
Chris PeBenito |
ab58ad |
type $1_t, domain, privlog $2;
|
|
Chris PeBenito |
ab58ad |
type $1_exec_t, file_type, sysadmfile, exec_type;
|
|
Chris PeBenito |
ab58ad |
role sysadm_r types $1_t;
|
|
Chris PeBenito |
ab58ad |
ifdef(`targeted_policy', `
|
|
Chris PeBenito |
ab58ad |
role system_r types $1_t;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans(sysadm_t, $1_exec_t, $1_t)
|
|
Chris PeBenito |
ab58ad |
uses_shlib($1_t)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`system_domain', `
|
|
Chris PeBenito |
ab58ad |
type $1_t, domain, privlog $2;
|
|
Chris PeBenito |
ab58ad |
type $1_exec_t, file_type, sysadmfile, exec_type;
|
|
Chris PeBenito |
ab58ad |
role system_r types $1_t;
|
|
Chris PeBenito |
ab58ad |
uses_shlib($1_t)
|
|
Chris PeBenito |
ab58ad |
allow $1_t etc_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Dontaudit macros to prevent flooding the log
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`dontaudit_getattr', `
|
|
Chris PeBenito |
ab58ad |
dontaudit $1 file_type - secure_file_type:dir_file_class_set getattr;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1 unlabeled_t:dir_file_class_set getattr;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1 { fs_type proc_fs dev_fs sysctl_type }:dir_file_class_set getattr;
|
|
Chris PeBenito |
ab58ad |
')dnl end dontaudit_getattr
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`dontaudit_search_dir', `
|
|
Chris PeBenito |
ab58ad |
dontaudit $1 file_type - secure_file_type:dir search;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1 unlabeled_t:dir search;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1 { fs_type proc_fs dev_fs sysctl_type }:dir search;
|
|
Chris PeBenito |
ab58ad |
')dnl end dontaudit_search_dir
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`dontaudit_read_dir', `
|
|
Chris PeBenito |
ab58ad |
dontaudit $1 file_type - secure_file_type:dir read;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1 unlabeled_t:dir read;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1 { fs_type proc_fs dev_fs sysctl_type }:dir read;
|
|
Chris PeBenito |
ab58ad |
')dnl end dontaudit_read_dir
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Define legacy_domain for legacy binaries (java)
|
|
Chris PeBenito |
ab58ad |
# "legacy" binary == lacks PT_GNU_STACK header, i.e. built with an old
|
|
Chris PeBenito |
ab58ad |
# toolchain. They cause the kernel to automatically start translating all
|
|
Chris PeBenito |
ab58ad |
# read protection requests to read|execute for backward compatibility on
|
|
Chris PeBenito |
ab58ad |
# x86. They will all need execmem and execmod, including execmod to
|
|
Chris PeBenito |
ab58ad |
# shlib_t and ld_so_t unlike non-legacy binaries.
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`legacy_domain', `
|
|
Chris PeBenito |
ab58ad |
allow $1_t self:process { execmem execstack };
|
|
Chris PeBenito |
ab58ad |
allow $1_t { texrel_shlib_t shlib_t }:file execmod;
|
|
Chris PeBenito |
ab58ad |
allow $1_t ld_so_t:file execmod;
|
|
Chris PeBenito |
ab58ad |
allow $1_t ld_so_cache_t:file execute;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Allow domain to perform polyinstantiation functions
|
|
Chris PeBenito |
ab58ad |
# polyinstantiater(domain)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`polyinstantiater', `
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
ifdef(`support_polyinstantiation', `
|
|
Chris PeBenito |
ab58ad |
# Need to give access to /selinux/member
|
|
Chris PeBenito |
ab58ad |
allow $1 security_t:security compute_member;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Need to give access to the directories to be polyinstantiated
|
|
Chris PeBenito |
ab58ad |
allow $1 polydir:dir { getattr mounton add_name create setattr write search };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Need to give access to the polyinstantiated subdirectories
|
|
Chris PeBenito |
ab58ad |
allow $1 polymember:dir {getattr search };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Need to give access to parent directories where original
|
|
Chris PeBenito |
ab58ad |
# is remounted for polyinstantiation aware programs (like gdm)
|
|
Chris PeBenito |
ab58ad |
allow $1 polyparent:dir { getattr mounton };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Need to give permission to create directories where applicable
|
|
Chris PeBenito |
ab58ad |
allow $1 polymember: dir { create setattr };
|
|
Chris PeBenito |
ab58ad |
allow $1 polydir: dir { write add_name };
|
|
Chris PeBenito |
ab58ad |
allow $1 self:process setfscreate;
|
|
Chris PeBenito |
ab58ad |
allow $1 polyparent:dir { write add_name };
|
|
Chris PeBenito |
ab58ad |
# Default type for mountpoints
|
|
Chris PeBenito |
ab58ad |
allow $1 poly_t:dir { create mounton };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Need sys_admin capability for mounting
|
|
Chris PeBenito |
ab58ad |
allow $1 self:capability sys_admin;
|
|
Chris PeBenito |
ab58ad |
')dnl end else support_polyinstantiation
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
')dnl end polyinstantiater
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Domain that is allow to read anonymous data off the network
|
|
Chris PeBenito |
ab58ad |
# without providing authentication.
|
|
Chris PeBenito |
ab58ad |
# Also define boolean to allow anonymous writing
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`anonymous_domain', `
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1_t, { public_content_t public_content_rw_t } )
|
|
Chris PeBenito |
ab58ad |
bool allow_$1_anon_write false;
|
|
Chris PeBenito |
ab58ad |
if (allow_$1_anon_write) {
|
|
Chris PeBenito |
ab58ad |
create_dir_file($1_t,public_content_rw_t)
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Define a domain that can do anything, so that it is
|
|
Chris PeBenito |
ab58ad |
# effectively unconfined by the SELinux policy. This
|
|
Chris PeBenito |
ab58ad |
# means that it is only restricted by the normal Linux
|
|
Chris PeBenito |
ab58ad |
# protections. Note that you may need to add further rules
|
|
Chris PeBenito |
ab58ad |
# to allow other domains to interact with this domain as expected,
|
|
Chris PeBenito |
ab58ad |
# since this macro only allows the specified domain to act upon
|
|
Chris PeBenito |
ab58ad |
# all other domains and types, not vice versa.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`unconfined_domain', `
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
typeattribute $1 unrestricted;
|
|
Chris PeBenito |
ab58ad |
typeattribute $1 privuser;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Mount/unmount any filesystem.
|
|
Chris PeBenito |
ab58ad |
allow $1 fs_type:filesystem *;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Mount/unmount any filesystem with the context= option.
|
|
Chris PeBenito |
ab58ad |
allow $1 file_type:filesystem *;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Create/access any file in a labeled filesystem;
|
|
Chris PeBenito |
ab58ad |
allow $1 file_type:{ file chr_file } ~execmod;
|
|
Chris PeBenito |
ab58ad |
allow $1 file_type:{ dir lnk_file sock_file fifo_file blk_file } *;
|
|
Chris PeBenito |
ab58ad |
allow $1 sysctl_t:{ dir file } *;
|
|
Chris PeBenito |
ab58ad |
allow $1 device_type:devfile_class_set *;
|
|
Chris PeBenito |
ab58ad |
allow $1 mtrr_device_t:file *;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Create/access other files. fs_type is to pick up various
|
|
Chris PeBenito |
ab58ad |
# pseudo filesystem types that are applied to both the filesystem
|
|
Chris PeBenito |
ab58ad |
# and its files.
|
|
Chris PeBenito |
ab58ad |
allow $1 { unlabeled_t fs_type }:dir_file_class_set *;
|
|
Chris PeBenito |
ab58ad |
allow $1 proc_fs:{ dir file } *;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# For /proc/pid
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1,domain)
|
|
Chris PeBenito |
ab58ad |
# Write access is for setting attributes under /proc/self/attr.
|
|
Chris PeBenito |
ab58ad |
allow $1 self:file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read and write sysctls.
|
|
Chris PeBenito |
ab58ad |
can_sysctl($1)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Access the network.
|
|
Chris PeBenito |
ab58ad |
allow $1 node_type:node *;
|
|
Chris PeBenito |
ab58ad |
allow $1 netif_type:netif *;
|
|
Chris PeBenito |
ab58ad |
allow $1 port_type:{ tcp_socket udp_socket } { send_msg recv_msg };
|
|
Chris PeBenito |
ab58ad |
allow $1 port_type:tcp_socket name_connect;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Bind to any network address.
|
|
Chris PeBenito |
ab58ad |
allow $1 port_type:{ rawip_socket tcp_socket udp_socket } name_bind;
|
|
Chris PeBenito |
ab58ad |
allow $1 node_type:{ tcp_socket udp_socket rawip_socket } node_bind;
|
|
Chris PeBenito |
ab58ad |
allow $1 file_type:{ unix_stream_socket unix_dgram_socket } name_bind;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Use/sendto/connectto sockets created by any domain.
|
|
Chris PeBenito |
ab58ad |
allow $1 domain:{ socket_class_set socket key_socket } *;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Use descriptors and pipes created by any domain.
|
|
Chris PeBenito |
ab58ad |
allow $1 domain:fd use;
|
|
Chris PeBenito |
ab58ad |
allow $1 domain:fifo_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Act upon any other process.
|
|
Chris PeBenito |
ab58ad |
allow $1 domain:process ~{ transition dyntransition execmem };
|
|
Chris PeBenito |
ab58ad |
# Transition to myself, to make get_ordered_context_list happy.
|
|
Chris PeBenito |
ab58ad |
allow $1 self:process transition;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
if (allow_execmem) {
|
|
Chris PeBenito |
ab58ad |
# Allow making anonymous memory executable, e.g.
|
|
Chris PeBenito |
ab58ad |
# for runtime-code generation or executable stack.
|
|
Chris PeBenito |
ab58ad |
allow $1 self:process execmem;
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
if (allow_execmem && allow_execstack) {
|
|
Chris PeBenito |
ab58ad |
# Allow making the stack executable via mprotect.
|
|
Chris PeBenito |
ab58ad |
allow $1 self:process execstack;
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
if (allow_execmod) {
|
|
Chris PeBenito |
ab58ad |
# Allow text relocations on system shared libraries, e.g. libGL.
|
|
Chris PeBenito |
ab58ad |
ifdef(`targeted_policy', `
|
|
Chris PeBenito |
ab58ad |
allow $1 file_type:file execmod;
|
|
Chris PeBenito |
ab58ad |
', `
|
|
Chris PeBenito |
ab58ad |
allow $1 texrel_shlib_t:file execmod;
|
|
Chris PeBenito |
ab58ad |
allow $1 home_type:file execmod;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Create/access any System V IPC objects.
|
|
Chris PeBenito |
ab58ad |
allow $1 domain:{ sem msgq shm } *;
|
|
Chris PeBenito |
ab58ad |
allow $1 domain:msg { send receive };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Access the security API.
|
|
Chris PeBenito |
8967bf |
if (!secure_mode_policyload) {
|
|
Chris PeBenito |
ab58ad |
allow $1 security_t:security *;
|
|
Chris PeBenito |
ab58ad |
auditallow $1 security_t:security { load_policy setenforce setbool };
|
|
Chris PeBenito |
8967bf |
}dnl end if !secure_mode_policyload
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Perform certain system operations that lacked individual capabilities.
|
|
Chris PeBenito |
ab58ad |
allow $1 kernel_t:system *;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Use any Linux capability.
|
|
Chris PeBenito |
ab58ad |
allow $1 self:capability *;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Set user information and skip authentication.
|
|
Chris PeBenito |
ab58ad |
allow $1 self:passwd *;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Communicate via dbusd.
|
|
Chris PeBenito |
ab58ad |
allow $1 self:dbus *;
|
|
Chris PeBenito |
ab58ad |
ifdef(`dbusd.te', `
|
|
Chris PeBenito |
ab58ad |
allow $1 system_dbusd_t:dbus *;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Get info via nscd.
|
|
Chris PeBenito |
ab58ad |
allow $1 self:nscd *;
|
|
Chris PeBenito |
ab58ad |
ifdef(`nscd.te', `
|
|
Chris PeBenito |
ab58ad |
allow $1 nscd_t:nscd *;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
')dnl end unconfined_domain
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`access_removable_media', `
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
can_exec($1, { removable_t noexattrfile } )
|
|
Chris PeBenito |
ab58ad |
if (user_rw_noexattrfile) {
|
|
Chris PeBenito |
ab58ad |
create_dir_file($1, noexattrfile)
|
|
Chris PeBenito |
ab58ad |
create_dir_file($1, removable_t)
|
|
Chris PeBenito |
ab58ad |
# Write floppies
|
|
Chris PeBenito |
ab58ad |
allow $1 removable_device_t:blk_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1 usbtty_device_t:chr_file write;
|
|
Chris PeBenito |
ab58ad |
} else {
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1, noexattrfile)
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1, removable_t)
|
|
Chris PeBenito |
ab58ad |
allow $1 removable_device_t:blk_file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
allow $1 removable_t:filesystem getattr;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`authentication_domain', `
|
|
Chris PeBenito |
ab58ad |
can_ypbind($1)
|
|
Chris PeBenito |
ab58ad |
can_kerberos($1)
|
|
Chris PeBenito |
ab58ad |
can_ldap($1)
|
|
Chris PeBenito |
ab58ad |
can_resolve($1)
|
|
Chris PeBenito |
ab58ad |
can_winbind($1)
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1, cert_t)
|
|
Chris PeBenito |
ab58ad |
allow $1 { random_device_t urandom_device_t }:chr_file { getattr read };
|
|
Chris PeBenito |
ab58ad |
allow $1 self:capability { audit_write audit_control };
|
|
Chris PeBenito |
ab58ad |
dontaudit $1 shadow_t:file { getattr read };
|
|
Chris PeBenito |
8967bf |
allow $1 sbin_t:dir search;
|
|
Chris PeBenito |
8967bf |
allow $1 self:netlink_audit_socket { create_netlink_socket_perms nlmsg_relay };
|
|
Chris PeBenito |
ab58ad |
')
|