Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Macros for all user login domains.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito a1fcff
# role_tty_type_change(starting_role, ending_role)
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
# change from role $1_r to $2_r and relabel tty appropriately
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
Chris PeBenito a1fcff
undefine(`role_tty_type_change')
Chris PeBenito a1fcff
define(`role_tty_type_change', `
Chris PeBenito a1fcff
allow $1_r $2_r;
Chris PeBenito a1fcff
type_change $2_t $1_devpts_t:chr_file $2_devpts_t;
Chris PeBenito a1fcff
type_change $2_t $1_tty_device_t:chr_file $2_tty_device_t;
Chris PeBenito a1fcff
# avoid annoying messages on terminal hangup
Chris PeBenito a1fcff
dontaudit $1_t { $2_devpts_t $2_tty_device_t }:chr_file ioctl;
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
# reach_sysadm(user)
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
# Reach sysadm_t via programs like userhelper/sudo/su
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
Chris PeBenito a1fcff
undefine(`reach_sysadm')
Chris PeBenito a1fcff
define(`reach_sysadm', `
Chris PeBenito a1fcff
ifdef(`userhelper.te', `userhelper_domain($1)')
Chris PeBenito a1fcff
ifdef(`sudo.te', `sudo_domain($1)')
Chris PeBenito a1fcff
ifdef(`su.te', `
Chris PeBenito a1fcff
su_domain($1)
Chris PeBenito a1fcff
# When an ordinary user domain runs su, su may try to
Chris PeBenito a1fcff
# update the /root/.Xauthority file, and the user shell may
Chris PeBenito a1fcff
# try to update the shell history. This is not allowed, but 
Chris PeBenito a1fcff
# we dont need to audit it.
Chris PeBenito a1fcff
dontaudit $1_su_t { sysadm_home_dir_t staff_home_dir_t }:dir search;
Chris PeBenito a1fcff
dontaudit $1_su_t { sysadm_home_t staff_home_t }:dir rw_dir_perms;
Chris PeBenito a1fcff
dontaudit $1_su_t { sysadm_home_t staff_home_t }:file create_file_perms;
Chris PeBenito a1fcff
') dnl ifdef su.te
Chris PeBenito a1fcff
ifdef(`xauth.te', `
Chris PeBenito a1fcff
file_type_auto_trans($1_xauth_t, sysadm_home_dir_t, sysadm_xauth_home_t,file)
Chris PeBenito a1fcff
ifdef(`userhelper.te', `
Chris PeBenito a1fcff
file_type_auto_trans($1_userhelper_t, sysadm_home_dir_t, sysadm_xauth_home_t,file)
Chris PeBenito a1fcff
') dnl userhelper.te 
Chris PeBenito a1fcff
') dnl xauth.te 
Chris PeBenito a1fcff
') dnl reach_sysadm
Chris PeBenito a1fcff
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
# priv_user(user)
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
# Privileged user domain
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
Chris PeBenito a1fcff
undefine(`priv_user')
Chris PeBenito a1fcff
define(`priv_user', `
Chris PeBenito a1fcff
# Reach sysadm_t
Chris PeBenito a1fcff
reach_sysadm($1)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
# Read file_contexts for rpm and get security decisions. 
Chris PeBenito a1fcff
r_dir_file($1_t, file_context_t)
Chris PeBenito a1fcff
can_getsecurity($1_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
# Signal and see information about unprivileged user domains.
Chris PeBenito a1fcff
allow $1_t unpriv_userdomain:process signal_perms;
Chris PeBenito a1fcff
can_ps($1_t, unpriv_userdomain)
Chris PeBenito a1fcff
allow $1_t { ttyfile ptyfile tty_device_t }:chr_file getattr;
Chris PeBenito a1fcff
Chris PeBenito a1fcff
# Read /root files if boolean is enabled.
Chris PeBenito a1fcff
if (staff_read_sysadm_file) {
Chris PeBenito a1fcff
allow $1_t sysadm_home_dir_t:dir { getattr search };
Chris PeBenito a1fcff
allow $1_t sysadm_home_t:file { getattr read };
Chris PeBenito a1fcff
}
Chris PeBenito a1fcff
Chris PeBenito a1fcff
') dnl priv_user
Chris PeBenito a1fcff
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# user_domain(domain_prefix)
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Define derived types and rules for an ordinary user domain.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# The type declaration and role authorization for the domain must be
Chris PeBenito 0fbfa5
# provided separately.  Likewise, domain transitions into this domain
Chris PeBenito 0fbfa5
# must be specified separately.  
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# user_domain() is also called by the admin_domain() macro
Chris PeBenito 0fbfa5
undefine(`user_domain')
Chris PeBenito 0fbfa5
define(`user_domain', `
Chris PeBenito 0fbfa5
# Use capabilities
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Type for home directory.
Chris PeBenito a1fcff
type $1_home_dir_t, file_type, sysadmfile, home_dir_type, home_type, user_home_dir_type, polydir;
Chris PeBenito a1fcff
type $1_home_t, file_type, sysadmfile, home_type, user_home_type, $1_file_type, polymember;
Chris PeBenito 0fbfa5
Chris PeBenito a1fcff
# Transition manually for { lnk sock fifo }. The rest is in content macros.
Chris PeBenito a1fcff
tmp_domain_notrans($1, `, user_tmpfile, $1_file_type')
Chris PeBenito a1fcff
file_type_auto_trans($1_t, tmp_t, $1_tmp_t, { lnk_file sock_file fifo_file })
Chris PeBenito a1fcff
allow $1_t $1_tmp_t:{ dir file } { relabelto relabelfrom };
Chris PeBenito 0fbfa5
Chris PeBenito a1fcff
ifdef(`support_polyinstantiation', `
Chris PeBenito a1fcff
type_member $1_t tmp_t:dir $1_tmp_t;
Chris PeBenito a1fcff
type_member $1_t $1_home_dir_t:dir $1_home_t;
Chris PeBenito a1fcff
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
base_user_domain($1)
Chris PeBenito a1fcff
ifdef(`mls_policy', `', `
Chris PeBenito a1fcff
access_removable_media($1_t)
Chris PeBenito a1fcff
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# do not allow privhome access to sysadm_home_dir_t
Chris PeBenito 0fbfa5
file_type_auto_trans(privhome, $1_home_dir_t, $1_home_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_t boot_t:dir { getattr search };
Chris PeBenito 0fbfa5
dontaudit $1_t boot_t:lnk_file read;
Chris PeBenito 0fbfa5
dontaudit $1_t boot_t:file read;
Chris PeBenito 0fbfa5
allow $1_t system_map_t:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Instantiate derived domains for a number of programs.
Chris PeBenito 0fbfa5
# These derived domains encode both information about the calling
Chris PeBenito 0fbfa5
# user domain and the program, and allow us to maintain separation
Chris PeBenito 0fbfa5
# between different instances of the program being run by different
Chris PeBenito 0fbfa5
# user domains.
Chris PeBenito a1fcff
ifelse($1, sysadm, `',`
Chris PeBenito a1fcff
ifdef(`apache.te', `apache_user_domain($1)')
Chris PeBenito 77f6e2
ifdef(`i18n_input.te', `i18n_input_domain($1)')
Chris PeBenito a1fcff
')
Chris PeBenito 0fbfa5
ifdef(`slocate.te', `locate_domain($1)')
Chris PeBenito 0fbfa5
ifdef(`lockdev.te', `lockdev_domain($1)')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
can_kerberos($1_t)
Chris PeBenito 0fbfa5
# allow port_t name binding for UDP because it is not very usable otherwise
Chris PeBenito 0fbfa5
allow $1_t port_t:udp_socket name_bind;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Need the following rule to allow users to run vpnc
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
ifdef(`xserver.te', `
Chris PeBenito 0fbfa5
allow $1_t xserver_port_t:tcp_socket name_bind;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Allow users to run TCP servers (bind to ports and accept connection from
Chris PeBenito 0fbfa5
# the same domain and outside users)  disabling this forces FTP passive mode
Chris PeBenito 0fbfa5
# and may change other protocols
Chris PeBenito 0fbfa5
if (user_tcp_server) {
Chris PeBenito 0fbfa5
allow $1_t port_t:tcp_socket name_bind;
Chris PeBenito 0fbfa5
}
Chris PeBenito 0fbfa5
# port access is audited even if dac would not have allowed it, so dontaudit it here
Chris PeBenito 0fbfa5
dontaudit $1_t reserved_port_type:tcp_socket name_bind;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Allow system log read
Chris PeBenito 0fbfa5
if (user_dmesg) {
Chris PeBenito 0fbfa5
allow $1_t kernel_t:system syslog_read;
Chris PeBenito 0fbfa5
} else {
Chris PeBenito 0fbfa5
# else do not log it
Chris PeBenito 0fbfa5
dontaudit $1_t kernel_t:system syslog_read;
Chris PeBenito 0fbfa5
}
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Allow read access to utmp.
Chris PeBenito 0fbfa5
allow $1_t initrc_var_run_t:file { getattr read lock };
Chris PeBenito 0fbfa5
# The library functions always try to open read-write first,
Chris PeBenito 0fbfa5
# then fall back to read-only if it fails. 
Chris PeBenito 0fbfa5
# Do not audit write denials to utmp to avoid the noise.
Chris PeBenito 0fbfa5
dontaudit $1_t initrc_var_run_t:file write;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# do not audit read on disk devices
Chris PeBenito 0fbfa5
dontaudit $1_t { removable_device_t fixed_disk_device_t }:blk_file read;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifdef(`xdm.te', `
Chris PeBenito 0fbfa5
allow xdm_t $1_home_t:lnk_file read;
Chris PeBenito 0fbfa5
allow xdm_t $1_home_t:dir search;
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Changing this to dontaudit should cause the .xsession-errors file to be written to /tmp
Chris PeBenito 0fbfa5
# 
Chris PeBenito 0fbfa5
dontaudit xdm_t $1_home_t:file rw_file_perms;
Chris PeBenito 0fbfa5
')dnl end ifdef xdm.te
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifdef(`ftpd.te', `
Chris PeBenito 0fbfa5
if (ftp_home_dir) {
Chris PeBenito 0fbfa5
file_type_auto_trans(ftpd_t, $1_home_dir_t, $1_home_t)
Chris PeBenito 0fbfa5
}
Chris PeBenito 0fbfa5
')dnl end ifdef ftpd
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
')dnl end user_domain macro
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
###########################################################################
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Domains for ordinary users.
Chris PeBenito 0fbfa5
#
Chris PeBenito a1fcff
undefine(`limited_user_role')
Chris PeBenito a1fcff
define(`limited_user_role', `
Chris PeBenito 0fbfa5
# user_t/$1_t is an unprivileged users domain.
Chris PeBenito a1fcff
type $1_t, domain, userdomain, unpriv_userdomain, nscd_client_domain, privfd;
Chris PeBenito a1fcff
Chris PeBenito a1fcff
#Type for tty devices.
Chris PeBenito a1fcff
type $1_tty_device_t, sysadmfile, ttyfile, user_tty_type, dev_fs;
Chris PeBenito a1fcff
# Type and access for pty devices.
Chris PeBenito a1fcff
can_create_pty($1, `, userpty_type, user_tty_type')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
# Access ttys.
Chris PeBenito a1fcff
allow $1_t privfd:fd use;
Chris PeBenito a1fcff
allow $1_t $1_tty_device_t:chr_file { setattr rw_file_perms };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Grant read/search permissions to some of /proc.
Chris PeBenito 0fbfa5
r_dir_file($1_t, proc_t)
Chris PeBenito 0fbfa5
r_dir_file($1_t, proc_net_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
base_file_read_access($1_t)
Chris PeBenito 0fbfa5
Chris PeBenito a1fcff
# Execute from the system shared libraries.
Chris PeBenito a1fcff
uses_shlib($1_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
# Read /etc.
Chris PeBenito a1fcff
r_dir_file($1_t, etc_t)
Chris PeBenito a1fcff
allow $1_t etc_runtime_t:file r_file_perms;
Chris PeBenito a1fcff
allow $1_t etc_runtime_t:lnk_file { getattr read };
Chris PeBenito a1fcff
Chris PeBenito a1fcff
allow $1_t self:process { fork sigchld setpgid signal_perms };
Chris PeBenito a1fcff
Chris PeBenito a1fcff
# read localization information
Chris PeBenito a1fcff
read_locale($1_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
read_sysctl($1_t)
Chris PeBenito a1fcff
can_exec($1_t, { bin_t sbin_t shell_exec_t ls_exec_t })
Chris PeBenito a1fcff
Chris PeBenito a1fcff
allow $1_t self:dir search;
Chris PeBenito a1fcff
allow $1_t self:file { getattr read };
Chris PeBenito a1fcff
allow secadm_t self:fifo_file rw_file_perms;
Chris PeBenito a1fcff
Chris PeBenito a1fcff
allow $1_t self:lnk_file read;
Chris PeBenito a1fcff
allow $1_t self:unix_stream_socket create_socket_perms;
Chris PeBenito a1fcff
allow $1_t urandom_device_t:chr_file { getattr read };
Chris PeBenito a1fcff
dontaudit $1_t { var_spool_t var_log_t }:dir search;
Chris PeBenito a1fcff
Chris PeBenito a1fcff
# Read /dev directories and any symbolic links.
Chris PeBenito a1fcff
allow $1_t device_t:dir r_dir_perms;
Chris PeBenito a1fcff
allow $1_t device_t:lnk_file { getattr read };
Chris PeBenito a1fcff
allow $1_t devtty_t:chr_file { read write };
Chris PeBenito a1fcff
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
undefine(`full_user_role')
Chris PeBenito a1fcff
define(`full_user_role', `
Chris PeBenito a1fcff
Chris PeBenito a1fcff
limited_user_role($1)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
typeattribute  $1_t web_client_domain;
Chris PeBenito a1fcff
Chris PeBenito a1fcff
attribute $1_file_type;
Chris PeBenito a1fcff
Chris PeBenito a1fcff
ifdef(`useradd.te', `
Chris PeBenito a1fcff
# Useradd relabels /etc/skel files so needs these privs 
Chris PeBenito a1fcff
allow useradd_t $1_file_type:dir create_dir_perms;
Chris PeBenito a1fcff
allow useradd_t $1_file_type:notdevfile_class_set create_file_perms;
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito 0fbfa5
can_exec($1_t, usr_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Read directories and files with the readable_t type.
Chris PeBenito 0fbfa5
# This type is a general type for "world"-readable files.
Chris PeBenito 0fbfa5
allow $1_t readable_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow $1_t readable_t:notdevfile_class_set r_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Stat lost+found.
Chris PeBenito 0fbfa5
allow $1_t lost_found_t:dir getattr;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Read /var, /var/spool, /var/run.
Chris PeBenito a1fcff
r_dir_file($1_t, var_t)
Chris PeBenito a1fcff
# what about pipes and sockets under /var/spool?
Chris PeBenito a1fcff
r_dir_file($1_t, var_spool_t)
Chris PeBenito a1fcff
r_dir_file($1_t, var_run_t)
Chris PeBenito 0fbfa5
allow $1_t var_lib_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow $1_t var_lib_t:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for running depmod as part of the kernel packaging process
Chris PeBenito 0fbfa5
allow $1_t modules_conf_t:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Read man directories and files.
Chris PeBenito a1fcff
r_dir_file($1_t, man_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Allow users to rw usb devices
Chris PeBenito 0fbfa5
if (user_rw_usb) {
Chris PeBenito 0fbfa5
rw_dir_create_file($1_t,usbdevfs_t)
Chris PeBenito 0fbfa5
} else {
Chris PeBenito 0fbfa5
r_dir_file($1_t,usbdevfs_t)
Chris PeBenito 0fbfa5
}
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
r_dir_file($1_t,sysfs_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Do not audit write denials to /etc/ld.so.cache.
Chris PeBenito 0fbfa5
dontaudit $1_t ld_so_cache_t:file write;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# $1_t is also granted permissions specific to user domains.
Chris PeBenito 0fbfa5
user_domain($1)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
dontaudit $1_t sysadm_home_t:file { read append };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifdef(`syslogd.te', `
Chris PeBenito 0fbfa5
# Some programs that are left in $1_t will try to connect
Chris PeBenito 0fbfa5
# to syslogd, but we do not want to let them generate log messages.
Chris PeBenito 0fbfa5
# Do not audit.
Chris PeBenito 0fbfa5
dontaudit $1_t devlog_t:sock_file { read write };
Chris PeBenito 0fbfa5
dontaudit $1_t syslogd_t:unix_dgram_socket sendto;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Stop warnings about access to /dev/console
Chris PeBenito 0fbfa5
dontaudit $1_t init_t:fd use;
Chris PeBenito 0fbfa5
dontaudit $1_t initrc_t:fd use;
Chris PeBenito 0fbfa5
allow $1_t initrc_t:fifo_file write;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Rules used to associate a homedir as a mountpoint
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
allow $1_home_t self:filesystem associate;
Chris PeBenito 0fbfa5
allow $1_file_type $1_home_t:filesystem associate;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
undefine(`in_user_role')
Chris PeBenito 0fbfa5
define(`in_user_role', `
Chris PeBenito 0fbfa5
role user_r types $1;
Chris PeBenito 0fbfa5
role staff_r types $1;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5