Chris PeBenito ab58ad
#DESC Init - Process initialization
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser  
Chris PeBenito ab58ad
# X-Debian-Packages: sysvinit
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the init_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# init_t is the domain of the init process.
Chris PeBenito ab58ad
# init_exec_t is the type of the init program.
Chris PeBenito ab58ad
# initctl_t is the type of the named pipe created 
Chris PeBenito ab58ad
# by init during initialization.  This pipe is used
Chris PeBenito ab58ad
# to communicate with init.
Chris PeBenito ab58ad
#
Chris PeBenito 8967bf
type init_t, domain, privlog, sysctl_kernel_writer, nscd_client_domain, mlsrangetrans, mlsfileread, mlsfilewrite, mlsprocwrite;
Chris PeBenito ab58ad
role system_r types init_t;
Chris PeBenito ab58ad
uses_shlib(init_t);
Chris PeBenito ab58ad
type init_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito ab58ad
type initctl_t, file_type, sysadmfile, dev_fs, mlstrustedobject;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for init to determine whether SE Linux is active so it can know whether to
Chris PeBenito ab58ad
# activate it
Chris PeBenito ab58ad
allow init_t security_t:dir search;
Chris PeBenito ab58ad
allow init_t security_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for mount points
Chris PeBenito ab58ad
allow init_t file_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use capabilities.
Chris PeBenito ab58ad
allow init_t self:capability ~sys_module;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Run /etc/rc.sysinit, /etc/rc, /etc/rc.local in the initrc_t domain.
Chris PeBenito ab58ad
domain_auto_trans(init_t, initrc_exec_t, initrc_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Run the shell in the sysadm_t domain for single-user mode.
Chris PeBenito ab58ad
domain_auto_trans(init_t, shell_exec_t, sysadm_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Run /sbin/update in the init_t domain.
Chris PeBenito ab58ad
can_exec(init_t, sbin_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Run init.
Chris PeBenito ab58ad
can_exec(init_t, init_exec_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Run chroot from initrd scripts.
Chris PeBenito ab58ad
ifdef(`chroot.te', `
Chris PeBenito ab58ad
can_exec(init_t, chroot_exec_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Create /dev/initctl.
Chris PeBenito ab58ad
file_type_auto_trans(init_t, device_t, initctl_t, fifo_file)
Chris PeBenito ab58ad
ifdef(`distro_redhat', `
Chris PeBenito ab58ad
file_type_auto_trans(init_t, tmpfs_t, initctl_t, fifo_file)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Create ioctl.save.
Chris PeBenito ab58ad
file_type_auto_trans(init_t, etc_t, etc_runtime_t, file)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Update /etc/ld.so.cache
Chris PeBenito ab58ad
allow init_t ld_so_cache_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow access to log files
Chris PeBenito ab58ad
allow init_t var_t:dir search;
Chris PeBenito ab58ad
allow init_t var_log_t:dir search;
Chris PeBenito ab58ad
allow init_t var_log_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
read_locale(init_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Create unix sockets
Chris PeBenito ab58ad
allow init_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow init_t self:unix_stream_socket create_socket_perms;
Chris PeBenito ab58ad
allow init_t self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Permissions required for system startup
Chris PeBenito ab58ad
allow init_t { bin_t sbin_t }:dir r_dir_perms;
Chris PeBenito ab58ad
allow init_t { bin_t sbin_t }:{ file lnk_file } { read getattr lock ioctl };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# allow init to fork
Chris PeBenito ab58ad
allow init_t self:process { fork sigchld };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Modify utmp.
Chris PeBenito ab58ad
allow init_t var_run_t:file rw_file_perms;
Chris PeBenito ab58ad
allow init_t initrc_var_run_t:file { setattr rw_file_perms };
Chris PeBenito ab58ad
can_unix_connect(init_t, initrc_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# For /var/run/shutdown.pid.
Chris PeBenito ab58ad
var_run_domain(init)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Shutdown permissions
Chris PeBenito ab58ad
r_dir_file(init_t, proc_t)
Chris PeBenito ab58ad
r_dir_file(init_t, self)
Chris PeBenito ab58ad
allow init_t devpts_t:dir r_dir_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Modify wtmp.
Chris PeBenito ab58ad
allow init_t wtmp_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Kill all processes.
Chris PeBenito ab58ad
allow init_t domain:process signal_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow all processes to send SIGCHLD to init.
Chris PeBenito ab58ad
allow domain init_t:process { sigchld signull };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# If you load a new policy that removes active domains, processes can
Chris PeBenito ab58ad
# get stuck if you do not allow unlabeled processes to signal init
Chris PeBenito ab58ad
# If you load an incompatible policy, you should probably reboot,
Chris PeBenito ab58ad
# since you may have compromised system security.
Chris PeBenito ab58ad
allow unlabeled_t init_t:process sigchld;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for loading policy
Chris PeBenito ab58ad
allow init_t policy_config_t:file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Set booleans.
Chris PeBenito ab58ad
can_setbool(init_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read and write the console and ttys.
Chris PeBenito ab58ad
allow init_t { tty_device_t console_device_t } :chr_file rw_file_perms;
Chris PeBenito ab58ad
ifdef(`distro_redhat', `
Chris PeBenito ab58ad
allow init_t tmpfs_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
allow init_t ttyfile:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow init_t ptyfile:chr_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Run system executables.
Chris PeBenito ab58ad
can_exec(init_t,bin_t)
Chris PeBenito ab58ad
ifdef(`consoletype.te', `
Chris PeBenito ab58ad
can_exec(init_t, consoletype_exec_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Run /etc/X11/prefdm.
Chris PeBenito ab58ad
can_exec(init_t,etc_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow init_t lib_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow init_t devtty_t:chr_file { read write };
Chris PeBenito ab58ad
allow init_t ramfs_t:dir search;
Chris PeBenito ab58ad
allow init_t ramfs_t:sock_file write;
Chris PeBenito ab58ad
r_dir_file(init_t, sysfs_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
r_dir_file(init_t, selinux_config_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# file descriptors inherited from the rootfs.
Chris PeBenito ab58ad
dontaudit init_t root_t:{ file chr_file } { read write }; 
Chris PeBenito ab58ad
ifdef(`targeted_policy', `
Chris PeBenito ab58ad
unconfined_domain(init_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad