Chris PeBenito ab58ad
Chris PeBenito ab58ad
# $1 is the source domain (or domains), $2 is the source role (or roles) and $3
Chris PeBenito ab58ad
# is the base name for the domain to run.  $1 is normally sysadm_t, and $2 is
Chris PeBenito ab58ad
# normally sysadm_r.  $4 is the type of program to run and $5 is the domain to
Chris PeBenito ab58ad
# transition to.
Chris PeBenito ab58ad
# sample usage:
Chris PeBenito ab58ad
# run_program(sysadm_t, sysadm_r, init, etc_t, initrc_t)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# if you have several users who run the same run_init type program for
Chris PeBenito ab58ad
# different purposes (think of a run_db program used by several database
Chris PeBenito ab58ad
# administrators to start several databases) then you can list all the source
Chris PeBenito ab58ad
# domains in $1, all the source roles in $2, but you may not want to list all
Chris PeBenito ab58ad
# types of programs to run in $4 and target domains in $5 (as that may permit
Chris PeBenito ab58ad
# entering a domain from the wrong type).  In such a situation just specify
Chris PeBenito ab58ad
# one value for each of $4 and $5 and have some rules such as the following:
Chris PeBenito ab58ad
# domain_trans(run_whatever_t, whatever_exec_t, whatever_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`run_program', `
Chris PeBenito ab58ad
type run_$3_exec_t, file_type, exec_type, sysadmfile;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# domain for program to run in, needs to change role (priv_system_role), change
Chris PeBenito ab58ad
# identity to system_u (privuser), log failures to syslog (privlog) and
Chris PeBenito ab58ad
# authenticate users
Chris PeBenito ab58ad
type run_$3_t, domain, priv_system_role, privuser, privlog;
Chris PeBenito ab58ad
domain_auto_trans($1, run_$3_exec_t, run_$3_t)
Chris PeBenito ab58ad
role $2 types run_$3_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
domain_auto_trans(run_$3_t, chkpwd_exec_t, sysadm_chkpwd_t)
Chris PeBenito ab58ad
dontaudit run_$3_t shadow_t:file getattr;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for utmp
Chris PeBenito ab58ad
allow run_$3_t initrc_var_run_t:file rw_file_perms;
Chris PeBenito ab58ad
allow run_$3_t admin_tty_type:chr_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
dontaudit run_$3_t devpts_t:dir { getattr read };
Chris PeBenito ab58ad
dontaudit run_$3_t device_t:dir read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for auth_chkpwd
Chris PeBenito ab58ad
dontaudit run_$3_t shadow_t:file read;
Chris PeBenito ab58ad
allow run_$3_t self:process { fork sigchld };
Chris PeBenito ab58ad
allow run_$3_t self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
allow run_$3_t self:capability setuid;
Chris PeBenito ab58ad
allow run_$3_t self:lnk_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# often the administrator runs such programs from a directory that is owned
Chris PeBenito ab58ad
# by a different user or has restrictive SE permissions, do not want to audit
Chris PeBenito ab58ad
# the failed access to the current directory
Chris PeBenito ab58ad
dontaudit run_$3_t file_type:dir search;
Chris PeBenito ab58ad
dontaudit run_$3_t self:capability { dac_override dac_read_search };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow run_$3_t bin_t:lnk_file read;
Chris PeBenito ab58ad
can_exec(run_$3_t, { bin_t shell_exec_t })
Chris PeBenito ab58ad
ifdef(`chkpwd.te', `
Chris PeBenito ab58ad
can_exec(run_$3_t, chkpwd_exec_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
domain_trans(run_$3_t, $4, $5)
Chris PeBenito ab58ad
can_setexec(run_$3_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow run_$3_t privfd:fd use;
Chris PeBenito ab58ad
uses_shlib(run_$3_t)
Chris PeBenito ab58ad
allow run_$3_t lib_t:file { getattr read };
Chris PeBenito ab58ad
can_getsecurity(run_$3_t)
Chris PeBenito ab58ad
r_dir_file(run_$3_t,selinux_config_t)
Chris PeBenito ab58ad
r_dir_file(run_$3_t,default_context_t)
Chris PeBenito ab58ad
allow run_$3_t self:unix_stream_socket create_socket_perms;
Chris PeBenito ab58ad
allow run_$3_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow run_$3_t etc_t:file { getattr read };
Chris PeBenito ab58ad
read_locale(run_$3_t)
Chris PeBenito ab58ad
allow run_$3_t fs_t:filesystem getattr;
Chris PeBenito ab58ad
allow run_$3_t { bin_t sbin_t }:dir search;
Chris PeBenito ab58ad
dontaudit run_$3_t device_t:dir { getattr search };
Chris PeBenito ab58ad
')