Chris PeBenito 31b7c0
#DESC Setfiles - SELinux filesystem labeling utilities
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Authors:  Russell Coker <russell@coker.com.au>
Chris PeBenito 31b7c0
# X-Debian-Packages: policycoreutils
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the setfiles_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# setfiles_exec_t is the type of the setfiles executable.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# needs auth_write attribute because it has relabelfrom/relabelto
Chris PeBenito 31b7c0
# access to shadow_t
Chris PeBenito 31b7c0
type setfiles_t, domain, privlog, privowner, auth_write, change_context, mlsfileread, mlsfilewrite, mlsfileupgrade, mlsfiledowngrade;
Chris PeBenito 31b7c0
type setfiles_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
role system_r types setfiles_t;
Chris PeBenito 31b7c0
role sysadm_r types setfiles_t;
Chris PeBenito 31b7c0
role secadm_r types setfiles_t;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`distro_redhat', `
Chris PeBenito 31b7c0
domain_auto_trans(initrc_t, setfiles_exec_t, setfiles_t)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
can_access_pty(hostname_t, initrc)
Chris PeBenito 31b7c0
allow setfiles_t { ttyfile ptyfile tty_device_t admin_tty_type devtty_t }:chr_file { read write ioctl };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow setfiles_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
domain_auto_trans(secadmin, setfiles_exec_t, setfiles_t)
Chris PeBenito 31b7c0
allow setfiles_t { userdomain privfd initrc_t init_t }:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
uses_shlib(setfiles_t)
Chris PeBenito 31b7c0
allow setfiles_t self:capability { dac_override dac_read_search fowner };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for upgrading glibc and other shared objects - without this the upgrade
Chris PeBenito 31b7c0
# scripts will put things in a state such that setfiles can not be run!
Chris PeBenito 31b7c0
allow setfiles_t lib_t:file { read execute };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Get security policy decisions.
Chris PeBenito 31b7c0
can_getsecurity(setfiles_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
r_dir_file(setfiles_t, { policy_src_t policy_config_t file_context_t selinux_config_t default_context_t })
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow setfiles_t file_type:dir r_dir_perms;
Chris PeBenito 31b7c0
allow setfiles_t { file_type unlabeled_t device_type }:dir_file_class_set { getattr relabelfrom };
Chris PeBenito 31b7c0
allow setfiles_t file_type:{ dir file lnk_file sock_file fifo_file } relabelto;
Chris PeBenito 31b7c0
allow setfiles_t unlabeled_t:dir read;
Chris PeBenito 31b7c0
allow setfiles_t { device_type device_t }:{ chr_file blk_file } { getattr relabelfrom relabelto };
Chris PeBenito 31b7c0
allow setfiles_t { ttyfile ptyfile }:chr_file getattr;
Chris PeBenito 31b7c0
# dontaudit access to ttyfile - we do not want setfiles to relabel our terminal
Chris PeBenito 31b7c0
dontaudit setfiles_t ttyfile:chr_file relabelfrom;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow setfiles_t fs_t:filesystem getattr;
Chris PeBenito 31b7c0
allow setfiles_t fs_type:dir r_dir_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
read_locale(setfiles_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow setfiles_t etc_runtime_t:file { getattr read };
Chris PeBenito 31b7c0
allow setfiles_t etc_t:file { getattr read };
Chris PeBenito 31b7c0
allow setfiles_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
dontaudit setfiles_t proc_t:lnk_file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for config files in a home directory
Chris PeBenito 31b7c0
allow setfiles_t home_type:file r_file_perms;
Chris PeBenito 31b7c0
dontaudit setfiles_t sysadm_tty_device_t:chr_file relabelfrom;