Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Macros for all user login domains.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
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 0fbfa5
type $1_home_dir_t, file_type, sysadmfile, home_dir_type, home_type, user_home_dir_type;
Chris PeBenito 0fbfa5
type $1_home_t, file_type, sysadmfile, home_type, user_home_type, $1_file_type;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
tmp_domain($1, `, user_tmpfile, $1_file_type', `{ file lnk_file dir sock_file fifo_file }')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Type and access for pty devices.
Chris PeBenito 0fbfa5
can_create_pty($1, `, userpty_type, user_tty_type')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#Type for tty devices.
Chris PeBenito 0fbfa5
type $1_tty_device_t, sysadmfile, ttyfile, user_tty_type, dev_fs;
Chris PeBenito 0fbfa5
 
Chris PeBenito 0fbfa5
base_user_domain($1)
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 0fbfa5
ifdef(`apache.te', `apache_domain($1)')
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 0fbfa5
undefine(`full_user_role')
Chris PeBenito 0fbfa5
define(`full_user_role', `
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# user_t/$1_t is an unprivileged users domain.
Chris PeBenito 0fbfa5
type $1_t, domain, userdomain, unpriv_userdomain, web_client_domain, nscd_client_domain, privfd;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
attribute $1_file_type;
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 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 0fbfa5
allow $1_t var_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow $1_t var_t:notdevfile_class_set r_file_perms;
Chris PeBenito 0fbfa5
allow $1_t var_spool_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow $1_t var_spool_t:notdevfile_class_set r_file_perms;
Chris PeBenito 0fbfa5
allow $1_t var_run_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow $1_t var_run_t:{ file lnk_file } r_file_perms;
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
read_sysctl($1_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Read /etc.
Chris PeBenito 0fbfa5
allow $1_t etc_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow $1_t etc_t:notdevfile_class_set r_file_perms;
Chris PeBenito 0fbfa5
allow $1_t etc_runtime_t:{ file lnk_file } r_file_perms;
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 0fbfa5
allow $1_t man_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow $1_t man_t:notdevfile_class_set r_file_perms;
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
# Read /dev directories and any symbolic links.
Chris PeBenito 0fbfa5
allow $1_t device_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow $1_t device_t:lnk_file r_file_perms;
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
# Execute from the system shared libraries.
Chris PeBenito 0fbfa5
uses_shlib($1_t);
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
ifdef(`user_can_mount', `
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
#  Allow users to mount file systems like floppies and cdrom
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
mount_domain($1, $1_mount, `, fs_domain')
Chris PeBenito 0fbfa5
r_dir_file($1_t, mnt_t)
Chris PeBenito 0fbfa5
allow $1_mount_t device_t:lnk_file read;
Chris PeBenito 0fbfa5
allow $1_mount_t removable_device_t:blk_file read;
Chris PeBenito 0fbfa5
allow $1_mount_t iso9660_t:filesystem relabelfrom;
Chris PeBenito 0fbfa5
allow $1_mount_t removable_t:filesystem { mount relabelto };
Chris PeBenito 0fbfa5
allow $1_mount_t removable_t:dir mounton;
Chris PeBenito 0fbfa5
ifdef(`xdm.te', `
Chris PeBenito 0fbfa5
allow $1_mount_t xdm_t:fd use;
Chris PeBenito 0fbfa5
allow $1_mount_t xdm_t:fifo_file { read write };
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
')
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