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