Chris PeBenito b4cd15
# init_t is the domain of the init process.
Chris PeBenito b4cd15
# init_exec_t is the type of the init program.
Chris PeBenito b4cd15
# init_var_run_t is the type for /var/run/shutdown.pid.
Chris PeBenito b4cd15
# initctl_t is the type of the named pipe created 
Chris PeBenito b4cd15
#           by init during initialization.  This pipe is used
Chris PeBenito b4cd15
#           to communicate with init.
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
type init_t;
Chris PeBenito b4cd15
domain_make_domain(init_t)
Chris PeBenito b4cd15
role system_r types init_t;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type init_exec_t;
Chris PeBenito b4cd15
domain_make_entrypoint_file(init_t,init_exec_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type initctl_t;
Chris PeBenito b4cd15
files_make_file(initctl_t)
Chris PeBenito b4cd15
devices_create_dev_entry(init_t,initctl_t,fifo_file)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type init_var_run_t;
Chris PeBenito b4cd15
files_make_file(init_var_run_t)
Chris PeBenito b4cd15
files_create_daemon_runtime_data(init_t,init_var_run_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
kernel_transition_from(init_t,init_exec_t)
Chris PeBenito b4cd15
kernel_sigchld_from(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# If you load a new policy that removes active domains, processes can
Chris PeBenito b4cd15
# get stuck if you do not allow unlabeled processes to signal init
Chris PeBenito b4cd15
# If you load an incompatible policy, you should probably reboot,
Chris PeBenito b4cd15
# since you may have compromised system security.
Chris PeBenito b4cd15
kernel_unlabeled_sigchld_from(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
kernel_set_selinux_boolean(init_t)
Chris PeBenito b4cd15
kernel_read_system_state(init_t)
Chris PeBenito b4cd15
kernel_read_hardware_state(init_t)
Chris PeBenito b4cd15
kernel_share_state(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
terminal_use_all_terminals(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
domain_signal_all_domains(init_t)
Chris PeBenito b4cd15
domain_kill_all_domains(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
files_modify_system_runtime_data(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
libraries_use_dynamic_loader(init_t)
Chris PeBenito b4cd15
libraries_read_shared_libraries(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
corecommands_chroot(init_t)
Chris PeBenito b4cd15
corecommands_execute_general_programs(init_t)
Chris PeBenito b4cd15
corecommands_execute_system_programs(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
selinux_read_config(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
miscfiles_read_localization(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Re-exec itself
Chris PeBenito b4cd15
allow init_t init_exec_t:file { getattr read execute execute_no_trans };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# For /var/run/shutdown.pid.
Chris PeBenito b4cd15
allow init_t init_var_run_t:file { create getattr read append write setattr unlink };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Run init scripts.  this is ok since initrc
Chris PeBenito b4cd15
# is also in this module
Chris PeBenito b4cd15
allow init_t initrc_t:process transition;
Chris PeBenito b4cd15
allow init_t initrc_exec_t:file { getattr read execute };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Create unix sockets
Chris PeBenito b4cd15
allow init_t self:unix_dgram_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
Chris PeBenito b4cd15
allow init_t self:unix_stream_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
Chris PeBenito b4cd15
allow init_t self:fifo_file { read write ioctl };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
########################################
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# the following seem questionable
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito b4cd15
libraries_modify_dynamic_loader_cache(init_t)
Chris PeBenito b4cd15
files_create_runtime_system_config(init_t)
Chris PeBenito b4cd15
authlogin_modify_login_records(init_t)
Chris PeBenito b4cd15
logging_modify_system_logs(init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Use capabilities. old rule:
Chris PeBenito b4cd15
#allow init_t self:capability ~sys_module;
Chris PeBenito b4cd15
# is ~sys_module really needed? observed: 
Chris PeBenito b4cd15
# sys_boot
Chris PeBenito b4cd15
# sys_tty_config
Chris PeBenito b4cd15
# kill: now provided by domain_kill_all_domains()
Chris PeBenito b4cd15
# setuid (from /sbin/shutdown)
Chris PeBenito b4cd15
# sys_chroot (from /usr/bin/chroot): now provided by corecommands_chroot()
Chris PeBenito b4cd15
allow init_t self:capability { sys_boot sys_tty_config setuid };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Modify utmp.
Chris PeBenito b4cd15
allow init_t initrc_var_run_t:file { getattr read write setattr };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
define(`init_consoletype_optional_policy',`
Chris PeBenito b4cd15
consoletype_execute(init_t,optional)
Chris PeBenito b4cd15
')
Chris PeBenito b4cd15
Chris PeBenito b4cd15
########################################
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# Conditional policy logic
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito b4cd15
ifdef(`monolithic_policy',`
Chris PeBenito b4cd15
ifdef(`consoletype.te',`init_consoletype_optional_policy')
Chris PeBenito b4cd15
',`
Chris PeBenito b4cd15
optional consoletype { consoletype_execute_depend }
Chris PeBenito b4cd15
ifopt (consoletype) { init_consoletype_optional_policy }
Chris PeBenito b4cd15
') dnl end monolithic_policy
Chris PeBenito b4cd15
Chris PeBenito b4cd15
########################################
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# the following still need to be converted over
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# something other then static libs
Chris PeBenito b4cd15
allow init_t lib_t:file { getattr read };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# for mount points
Chris PeBenito b4cd15
allow init_t file_t:dir search;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# file descriptors inherited from the rootfs.
Chris PeBenito b4cd15
dontaudit init_t root_t:{ file chr_file } { read write }; 
Chris PeBenito b4cd15
Chris PeBenito b4cd15
Chris PeBenito b4cd15
Chris PeBenito b4cd15
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type initrc_t;
Chris PeBenito b4cd15
domain_make_domain(initrc_t)
Chris PeBenito b4cd15
role system_r types initrc_t;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type initrc_exec_t;
Chris PeBenito b4cd15
domain_make_entrypoint_file(initrc_t,initrc_exec_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type initrc_devpts_t;
Chris PeBenito b4cd15
terminal_make_pty(initrc_t,initrc_devpts_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type initrc_var_run_t;
Chris PeBenito b4cd15
files_make_file(initrc_var_run_t)
Chris PeBenito b4cd15
files_create_daemon_runtime_data(initrc_t,initrc_var_run_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type initrc_state_t;
Chris PeBenito b4cd15
files_make_file(initrc_state_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type initrc_tmp_t;
Chris PeBenito b4cd15
files_make_file(initrc_tmp_t)
Chris PeBenito b4cd15
files_create_private_tmp_data(initrc_t,initrc_tmp_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow initrc_t self:process { getpgid setsched setpgid setrlimit getsched };
Chris PeBenito b4cd15
allow initrc_t self:capability ~{ sys_admin sys_module };
Chris PeBenito b4cd15
allow initrc_t self:passwd rootok;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Allow IPC with self
Chris PeBenito b4cd15
allow initrc_t self:unix_dgram_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
Chris PeBenito b4cd15
allow initrc_t self:unix_stream_socket { create listen accept ioctl read getattr write setattr append bind connect getopt setopt shutdown connectto };
Chris PeBenito b4cd15
allow initrc_t self:fifo_file { read write ioctl };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow initrc_t self:netlink_route_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown nlmsg_read };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow initrc_t initrc_state_t:dir { create read getattr lock setattr ioctl unlink rename search add_name remove_name reparent write rmdir };
Chris PeBenito b4cd15
allow initrc_t initrc_state_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito b4cd15
allow initrc_t initrc_state_t:lnk_file { create read getattr setattr unlink rename };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
kernel_read_system_state(initrc_t)
Chris PeBenito b4cd15
kernel_read_software_raid_state(initrc_t)
Chris PeBenito b4cd15
kernel_read_network_state(initrc_t)
Chris PeBenito b4cd15
kernel_read_ring_buffer(initrc_t)
Chris PeBenito b4cd15
kernel_change_ring_buffer_level(initrc_t)
Chris PeBenito b4cd15
kernel_clear_ring_buffer(initrc_t)
Chris PeBenito b4cd15
kernel_get_sysvipc_info(initrc_t)
Chris PeBenito b4cd15
kernel_read_hardware_state(initrc_t)
Chris PeBenito b4cd15
kernel_modify_hardware_config_option(initrc_t)
Chris PeBenito b4cd15
kernel_read_all_sysctl(initrc_t)
Chris PeBenito b4cd15
kernel_modify_all_sysctl(initrc_t)
Chris PeBenito b4cd15
kernel_get_selinux_enforcement_mode(initrc_t)
Chris PeBenito b4cd15
kernel_list_usb_hardware(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
filesystem_register_binary_executable_type(initrc_t)
Chris PeBenito b4cd15
# cjp: not sure why these are here; should use mount policy
Chris PeBenito b4cd15
filesystem_mount_all_filesystems(initrc_t)
Chris PeBenito b4cd15
filesystem_unmount_all_filesystems(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# can_network(initrc_t):
Chris PeBenito b4cd15
allow initrc_t self:tcp_socket { connect listen accept create ioctl read getattr write setattr append bind getopt setopt shutdown };
Chris PeBenito b4cd15
allow initrc_t self:udp_socket { connect create ioctl read getattr write setattr append bind getopt setopt shutdown };
Chris PeBenito b4cd15
corenetwork_send_tcp_on_all_interfaces(initrc_t)
Chris PeBenito b4cd15
corenetwork_send_raw_on_all_interfaces(initrc_t)
Chris PeBenito b4cd15
corenetwork_send_udp_on_all_interfaces(initrc_t)
Chris PeBenito b4cd15
#corenetwork_send_tcp_on_all_nodes(initrc_t)
Chris PeBenito b4cd15
#corenetwork_send_raw_on_all_nodes(initrc_t)
Chris PeBenito b4cd15
#corenetwork_send_udp_on_all_nodes(initrc_t)
Chris PeBenito b4cd15
#corenetwork_send_tcp_on_all_ports(initrc_t)
Chris PeBenito b4cd15
#corenetwork_send_udp_on_all_ports(initrc_t)
Chris PeBenito b4cd15
corenetwork_receive_tcp_on_all_interfaces(initrc_t)
Chris PeBenito b4cd15
corenetwork_receive_raw_on_all_interfaces(initrc_t)
Chris PeBenito b4cd15
corenetwork_receive_udp_on_all_interfaces(initrc_t)
Chris PeBenito b4cd15
#corenetwork_receive_tcp_on_all_nodes(initrc_t)
Chris PeBenito b4cd15
#corenetwork_receive_raw_on_all_nodes(initrc_t)
Chris PeBenito b4cd15
#corenetwork_receive_udp_on_all_nodes(initrc_t)
Chris PeBenito b4cd15
#corenetwork_receive_tcp_on_all_ports(initrc_t)
Chris PeBenito b4cd15
#corenetwork_receive_udp_on_all_ports(initrc_t)
Chris PeBenito b4cd15
#corenetwork_bind_tcp_on_all_nodes(initrc_t)
Chris PeBenito b4cd15
#corenetwork_bind_udp_on_all_nodes(initrc_t)
Chris PeBenito b4cd15
#allow initrc_t net_conf_t:file r_file_perms;
Chris PeBenito b4cd15
#sysnetwork_read_network_config(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
domain_kill_all_domains(initrc_t)
Chris PeBenito b4cd15
domain_read_all_domains_process_state(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
devices_get_random_data(initrc_t)
Chris PeBenito b4cd15
devices_get_pseudorandom_data(initrc_t)
Chris PeBenito b4cd15
devices_add_entropy(initrc_t)
Chris PeBenito b4cd15
devices_set_pseudorandom_seed(initrc_t)
Chris PeBenito b4cd15
devices_read_framebuffer(initrc_t)
Chris PeBenito b4cd15
devices_read_realtime_clock(initrc_t)
Chris PeBenito b4cd15
devices_read_sound_mixer_levels(initrc_t)
Chris PeBenito b4cd15
devices_write_sound_mixer_levels(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
terminal_use_all_terminals(initrc_t)
Chris PeBenito b4cd15
terminal_reset_labels(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
bootloader_read_kernel_symbol_table(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
libraries_modify_dynamic_loader_cache(initrc_t)
Chris PeBenito b4cd15
libraries_use_dynamic_loader(initrc_t)
Chris PeBenito b4cd15
libraries_read_shared_libraries(initrc_t)
Chris PeBenito b4cd15
libraries_execute_library_scripts(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
files_get_all_file_stats(initrc_t)
Chris PeBenito b4cd15
files_remove_all_tmp_data(initrc_t)
Chris PeBenito b4cd15
files_remove_all_lock_files(initrc_t)
Chris PeBenito b4cd15
files_remove_all_daemon_runtime_data(initrc_t)
Chris PeBenito b4cd15
files_read_general_system_config(initrc_t)
Chris PeBenito b4cd15
files_create_runtime_system_config(initrc_t)
Chris PeBenito b4cd15
files_manage_general_lock_files(initrc_t)
Chris PeBenito b4cd15
files_execute_system_config_script(initrc_t)
Chris PeBenito b4cd15
files_read_general_shared_resources(initrc_t)
Chris PeBenito b4cd15
files_manage_pseudorandom_saved_seed(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
corecommands_execute_general_programs(initrc_t)
Chris PeBenito b4cd15
corecommands_execute_system_programs(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
selinux_read_config(initrc_t)
Chris PeBenito b4cd15
selinux_read_default_contexts(run_init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
modutils_read_kernel_module_loading_config(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
authlogin_modify_login_records(initrc_t)
Chris PeBenito b4cd15
authlogin_modify_last_login_log(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
miscfiles_read_localization(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
logging_modify_system_logs(initrc_t)
Chris PeBenito b4cd15
logging_read_all_logs(initrc_t)
Chris PeBenito b4cd15
logging_append_all_logs(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
ifdef(`distro_redhat',`
Chris PeBenito b4cd15
kernel_set_selinux_enforcement_mode(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
files_create_boot_flag(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Create and read /boot/kernel.h and /boot/System.map.
Chris PeBenito b4cd15
# Redhat systems typically create this file at boot time.
Chris PeBenito b4cd15
bootloader_create_runtime_data(initrc_t)
Chris PeBenito b4cd15
')
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#################################
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# Rules for the run_init_t domain.
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type run_init_t;
Chris PeBenito b4cd15
domain_make_domain(run_init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
type run_init_exec_t;
Chris PeBenito b4cd15
files_make_file(run_init_exec_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
Chris PeBenito b4cd15
ifdef(`targeted_policy',`
Chris PeBenito b4cd15
# targeted/unconfined stuff
Chris PeBenito b4cd15
',`
Chris PeBenito b4cd15
corecommands_execute_general_programs(run_init_t)
Chris PeBenito b4cd15
corecommands_execute_shell(run_init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
filesystem_read_persistent_filesystem_stats(run_init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
files_read_general_system_config(run_init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
libraries_use_dynamic_loader(run_init_t)
Chris PeBenito b4cd15
libraries_read_shared_libraries(run_init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
selinux_read_config(run_init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
miscfiles_read_localization(run_init_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow run_init_t initrc_t:process transition;
Chris PeBenito b4cd15
allow run_init_t initrc_exec_t:file { getattr read execute };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# for utmp
Chris PeBenito b4cd15
allow run_init_t initrc_var_run_t:file { getattr read write };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow run_init_t self:process setexec;
Chris PeBenito b4cd15
allow run_init_t self:capability setuid;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow run_init_t self:unix_stream_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
Chris PeBenito b4cd15
allow run_init_t self:unix_dgram_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow run_init_t self:fifo_file { getattr read write };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# often the administrator runs such programs from a directory that is owned
Chris PeBenito b4cd15
# by a different user or has restrictive SE permissions, do not want to audit
Chris PeBenito b4cd15
# the failed access to the current directory
Chris PeBenito b4cd15
dontaudit run_init_t self:capability { dac_override dac_read_search };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
devices_ignore_list_device_nodes(run_init_t)
Chris PeBenito b4cd15
terminal_ignore_list_ptys(run_init_t)
Chris PeBenito b4cd15
') dnl end ifdef targeted policy
Chris PeBenito b4cd15
Chris PeBenito b4cd15
Chris PeBenito b4cd15
ifdef(`TODO',`
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Mount and unmount file systems.
Chris PeBenito b4cd15
allow initrc_t { file_t default_t }:dir { read search getattr mounton };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow initrc_t var_spool_t:file rw_file_perms;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow initrc_t privfd:fd use;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# for cryptsetup
Chris PeBenito b4cd15
allow initrc_t fixed_disk_device_t:blk_file getattr;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Set device ownerships/modes.
Chris PeBenito b4cd15
allow initrc_t device_type:chr_file setattr;
Chris PeBenito b4cd15
allow initrc_t misc_device_t:{ chr_file blk_file } setattr;
Chris PeBenito b4cd15
allow initrc_t fixed_disk_device_t:blk_file setattr;
Chris PeBenito b4cd15
allow initrc_t removable_device_t:blk_file setattr;
Chris PeBenito b4cd15
allow initrc_t xconsole_device_t:fifo_file setattr;
Chris PeBenito b4cd15
allow initrc_t sound_device_t:chr_file setattr;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Allow access to the sysadm TTYs. Note that this will give access to the 
Chris PeBenito b4cd15
# TTYs to any process in the initrc_t domain. Therefore, daemons and such
Chris PeBenito b4cd15
# started from init should be placed in their own domain.
Chris PeBenito b4cd15
allow initrc_t admin_tty_type:chr_file rw_file_perms;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# Read user home directories.
Chris PeBenito b4cd15
allow initrc_t { home_root_t home_type }:dir r_dir_perms;
Chris PeBenito b4cd15
allow initrc_t home_type:file r_file_perms;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow initrc_t udev_runtime_t:file rw_file_perms;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# for lsof in shutdown scripts
Chris PeBenito b4cd15
can_kerberos(initrc_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# Wants to remove udev.tbl
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
allow initrc_t device_t:dir rw_dir_perms;
Chris PeBenito b4cd15
allow initrc_t device_t:lnk_file unlink;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
#  These rules are here to allow init scripts to su
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
ifdef(`su.te', `
Chris PeBenito b4cd15
su_restricted_domain(initrc,system)
Chris PeBenito b4cd15
role system_r types initrc_su_t;
Chris PeBenito b4cd15
')
Chris PeBenito b4cd15
Chris PeBenito b4cd15
ifdef(`distro_debian', `
Chris PeBenito b4cd15
allow initrc_t { etc_t device_t }:dir setattr;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# for storing state under /dev/shm
Chris PeBenito b4cd15
allow initrc_t tmpfs_t:dir setattr;
Chris PeBenito b4cd15
file_type_auto_trans(initrc_t, tmpfs_t, initrc_var_run_t, dir)
Chris PeBenito b4cd15
file_type_auto_trans(initrc_t, tmpfs_t, fixed_disk_device_t, blk_file)
Chris PeBenito b4cd15
allow { initrc_var_run_t fixed_disk_device_t } tmpfs_t:filesystem associate;
Chris PeBenito b4cd15
')
Chris PeBenito b4cd15
Chris PeBenito b4cd15
ifdef(`distro_redhat', `
Chris PeBenito b4cd15
# Create and read /boot/kernel.h and /boot/System.map.
Chris PeBenito b4cd15
# Redhat systems typically create this file at boot time.
Chris PeBenito b4cd15
allow initrc_t boot_t:lnk_file rw_file_perms;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow initrc_t tmpfs_t:chr_file rw_file_perms;
Chris PeBenito b4cd15
allow initrc_t tmpfs_t:dir r_dir_perms;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# readahead asks for these
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
allow initrc_t etc_aliases_t:file { getattr read };
Chris PeBenito b4cd15
allow initrc_t var_lib_nfs_t:file { getattr read };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
')dnl end distro_redhat
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# Shutting down xinet causes these
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# Fam
Chris PeBenito b4cd15
dontaudit initrc_t device_t:dir { read write };
Chris PeBenito b4cd15
# Rsync
Chris PeBenito b4cd15
dontaudit initrc_t mail_spool_t:lnk_file read;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# for lsof which is used by alsa shutdown
Chris PeBenito b4cd15
dontaudit initrc_t domain:{ udp_socket tcp_socket fifo_file unix_dgram_socket } getattr;
Chris PeBenito b4cd15
dontaudit initrc_t proc_kmsg_t:file getattr;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
Chris PeBenito b4cd15
#################################
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
# Rules for the run_init_t domain.
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito b4cd15
Chris PeBenito b4cd15
ifdef(`targeted_policy', `
Chris PeBenito b4cd15
domain_auto_trans(unconfined_t, initrc_exec_t, initrc_t)
Chris PeBenito b4cd15
allow unconfined_t initrc_t:dbus { acquire_svc send_msg };
Chris PeBenito b4cd15
allow initrc_t unconfined_t:dbus { acquire_svc send_msg };
Chris PeBenito b4cd15
domain_trans(initrc_t, shell_exec_t, unconfined_t)
Chris PeBenito b4cd15
', `
Chris PeBenito b4cd15
domain_auto_trans(sysadm_t, run_init_exec_t, run_init_t)
Chris PeBenito b4cd15
role sysadm_r types run_init_t;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
domain_auto_trans(run_init_t, chkpwd_exec_t, sysadm_chkpwd_t)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# for utmp
Chris PeBenito b4cd15
allow run_init_t admin_tty_type:chr_file rw_file_perms;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
allow run_init_t privfd:fd use;
Chris PeBenito b4cd15
allow run_init_t lib_t:file { getattr read };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
dontaudit run_init_t shadow_t:file { getattr read };
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# often the administrator runs such programs from a directory that is owned
Chris PeBenito b4cd15
# by a different user or has restrictive SE permissions, do not want to audit
Chris PeBenito b4cd15
# the failed access to the current directory
Chris PeBenito b4cd15
dontaudit run_init_t file_type:dir search;
Chris PeBenito b4cd15
Chris PeBenito b4cd15
') dnl endif targeted policy
Chris PeBenito b4cd15
Chris PeBenito b4cd15
ifdef(`distro_gentoo', `
Chris PeBenito b4cd15
# Gentoo integrated run_init+open_init_pty-runscript:
Chris PeBenito b4cd15
domain_auto_trans(sysadm_t,initrc_exec_t,run_init_t)
Chris PeBenito b4cd15
')
Chris PeBenito b4cd15
Chris PeBenito b4cd15
') dnl end TODO