|
Chris PeBenito |
948914 |
## <summary>Run shells with substitute user and group</summary>
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
b9d7d7 |
#######################################
|
|
Chris PeBenito |
b9d7d7 |
## <summary>
|
|
Chris PeBenito |
b9d7d7 |
## The per user domain template for the su module.
|
|
Chris PeBenito |
b9d7d7 |
## </summary>
|
|
Chris PeBenito |
b9d7d7 |
## <desc>
|
|
Chris PeBenito |
b9d7d7 |
##
|
|
Chris PeBenito |
b9d7d7 |
## This template creates a derived domain which is allowed
|
|
Chris PeBenito |
b9d7d7 |
## to change the linux user id, to run shells as a different
|
|
Chris PeBenito |
b9d7d7 |
## user.
|
|
Chris PeBenito |
b9d7d7 |
##
|
|
Chris PeBenito |
b9d7d7 |
##
|
|
Chris PeBenito |
b9d7d7 |
## This template is invoked automatically for each user, and
|
|
Chris PeBenito |
b9d7d7 |
## generally does not need to be invoked directly
|
|
Chris PeBenito |
b9d7d7 |
## by policy writers.
|
|
Chris PeBenito |
b9d7d7 |
##
|
|
Chris PeBenito |
b9d7d7 |
## </desc>
|
|
Chris PeBenito |
b9d7d7 |
## <param name="userdomain_prefix">
|
|
Chris PeBenito |
b9d7d7 |
## The prefix of the user domain (e.g., user
|
|
Chris PeBenito |
b9d7d7 |
## is the prefix for user_t).
|
|
Chris PeBenito |
b9d7d7 |
## </param>
|
|
Chris PeBenito |
451c1e |
## <param name="user_domain">
|
|
Chris PeBenito |
451c1e |
## The type of the user domain.
|
|
Chris PeBenito |
451c1e |
## </param>
|
|
Chris PeBenito |
451c1e |
## <param name="user_role">
|
|
Chris PeBenito |
451c1e |
## The role associated with the user domain.
|
|
Chris PeBenito |
451c1e |
## </param>
|
|
Chris PeBenito |
b9d7d7 |
#
|
|
Chris PeBenito |
948914 |
template(`su_per_userdomain_template',`
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
type $1_su_t;
|
|
Chris PeBenito |
948914 |
domain_entry_file($1_su_t,su_exec_t)
|
|
Chris PeBenito |
948914 |
domain_type($1_su_t)
|
|
Chris PeBenito |
948914 |
domain_role_change_exempt($1_su_t)
|
|
Chris PeBenito |
948914 |
domain_subj_id_change_exempt($1_su_t)
|
|
Chris PeBenito |
948914 |
domain_obj_id_change_exempt($1_su_t)
|
|
Chris PeBenito |
948914 |
domain_wide_inherit_fd($1_su_t)
|
|
Chris PeBenito |
451c1e |
role $3 types $1_su_t;
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
451c1e |
allow $2 $1_su_t:process signal;
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
allow $1_su_t self:capability { setuid setgid net_bind_service chown dac_override fowner sys_nice sys_resource };
|
|
Chris PeBenito |
948914 |
dontaudit $1_su_t self:capability sys_tty_config;
|
|
Chris PeBenito |
948914 |
allow $1_su_t self:process { setexec setsched setrlimit };
|
|
Chris PeBenito |
948914 |
allow $1_su_t self:fifo_file rw_file_perms;
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
# Transition from the user domain to this domain.
|
|
Chris PeBenito |
451c1e |
domain_auto_trans($2, su_exec_t, $1_su_t)
|
|
Chris PeBenito |
451c1e |
allow $2 $1_su_t:fd use;
|
|
Chris PeBenito |
451c1e |
allow $1_su_t $2:fd use;
|
|
Chris PeBenito |
451c1e |
allow $1_su_t $2:fifo_file rw_file_perms;
|
|
Chris PeBenito |
451c1e |
allow $1_su_t $2:process sigchld;
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
# By default, revert to the calling domain when a shell is executed.
|
|
Chris PeBenito |
451c1e |
corecmd_shell_domtrans($1_su_t,$2)
|
|
Chris PeBenito |
451c1e |
allow $2 $1_su_t:fd use;
|
|
Chris PeBenito |
451c1e |
allow $1_su_t $2:fd use;
|
|
Chris PeBenito |
451c1e |
allow $1_su_t $2:fifo_file rw_file_perms;
|
|
Chris PeBenito |
451c1e |
allow $1_su_t $2:process sigchld;
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
kernel_read_system_state($1_su_t)
|
|
Chris PeBenito |
948914 |
kernel_read_kernel_sysctl($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
# for SSP
|
|
Chris PeBenito |
948914 |
dev_read_urand($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
fs_search_auto_mountpoints($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
selinux_get_fs_mount($1_su_t)
|
|
Chris PeBenito |
948914 |
selinux_validate_context($1_su_t)
|
|
Chris PeBenito |
948914 |
selinux_compute_access_vector($1_su_t)
|
|
Chris PeBenito |
948914 |
selinux_compute_create_context($1_su_t)
|
|
Chris PeBenito |
948914 |
selinux_compute_relabel_context($1_su_t)
|
|
Chris PeBenito |
948914 |
selinux_compute_user_contexts($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
# Relabel ttys and ptys.
|
|
Chris PeBenito |
948914 |
term_relabel_all_user_ttys($1_su_t)
|
|
Chris PeBenito |
948914 |
term_relabel_all_user_ptys($1_su_t)
|
|
Chris PeBenito |
948914 |
# Close and re-open ttys and ptys to get the fd into the correct domain.
|
|
Chris PeBenito |
948914 |
term_use_all_user_ttys($1_su_t)
|
|
Chris PeBenito |
948914 |
term_use_all_user_ptys($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
2a9456 |
auth_domtrans_user_chk_passwd($1_su_t,$1)
|
|
Chris PeBenito |
948914 |
auth_dontaudit_read_shadow($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
domain_wide_inherit_fd($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
files_read_etc_files($1_su_t)
|
|
Chris PeBenito |
948914 |
files_search_var_lib($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
init_dontaudit_use_fd($1_su_t)
|
|
Chris PeBenito |
948914 |
# Write to utmp.
|
|
Chris PeBenito |
948914 |
init_rw_script_pid($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
libs_use_ld_so($1_su_t)
|
|
Chris PeBenito |
948914 |
libs_use_shared_libs($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
logging_send_syslog_msg($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
miscfiles_read_localization($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
seutil_read_config($1_su_t)
|
|
Chris PeBenito |
948914 |
seutil_read_default_contexts($1_su_t)
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
451c1e |
userdom_use_user_terminals($1,$1_su_t)
|
|
Chris PeBenito |
2a9456 |
|
|
Chris PeBenito |
948914 |
if(secure_mode)
|
|
Chris PeBenito |
948914 |
{
|
|
Chris PeBenito |
948914 |
# Only allow transitions to unprivileged user domains.
|
|
Chris PeBenito |
948914 |
userdom_spec_domtrans_unpriv_users($1_su_t)
|
|
Chris PeBenito |
948914 |
} else {
|
|
Chris PeBenito |
948914 |
# Allow transitions to all user domains
|
|
Chris PeBenito |
948914 |
userdom_spec_domtrans_all_users($1_su_t)
|
|
Chris PeBenito |
948914 |
}
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
if (use_nfs_home_dirs) {
|
|
Chris PeBenito |
948914 |
fs_search_nfs($1_su_t)
|
|
Chris PeBenito |
948914 |
}
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
if (use_samba_home_dirs) {
|
|
Chris PeBenito |
948914 |
fs_search_cifs($1_su_t)
|
|
Chris PeBenito |
948914 |
}
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
optional_policy(`crond.te',`
|
|
Chris PeBenito |
948914 |
cron_read_pipe($1_su_t)
|
|
Chris PeBenito |
948914 |
')
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
optional_policy(`kerberos.te',`
|
|
Chris PeBenito |
948914 |
kerberos_use($1_su_t)
|
|
Chris PeBenito |
948914 |
')
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
optional_policy(`nis.te',`
|
|
Chris PeBenito |
948914 |
nis_use_ypbind($1_su_t)
|
|
Chris PeBenito |
948914 |
')
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
optional_policy(`nscd.te',`
|
|
Chris PeBenito |
948914 |
nscd_use_socket($1_su_t)
|
|
Chris PeBenito |
948914 |
')
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
ifdef(`TODO',`
|
|
Chris PeBenito |
948914 |
# Caused by su - init scripts
|
|
Chris PeBenito |
948914 |
dontaudit $1_su_t initrc_devpts_t:chr_file { getattr ioctl };
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
# Inherit and use descriptors from gnome-pty-helper.
|
|
Chris PeBenito |
948914 |
ifdef(`gnome-pty-helper.te', `allow $1_su_t $1_gph_t:fd use;')
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
allow $1_su_t { home_root_t $1_home_dir_t }:dir search;
|
|
Chris PeBenito |
948914 |
allow $1_su_t $1_home_t:file create_file_perms;
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
ifdef(`user_canbe_sysadm', `
|
|
Chris PeBenito |
948914 |
allow $1_su_t home_dir_type:dir { search write };
|
|
Chris PeBenito |
948914 |
', `
|
|
Chris PeBenito |
948914 |
dontaudit $1_su_t home_dir_type:dir { search write };
|
|
Chris PeBenito |
948914 |
')
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
# Modify .Xauthority file (via xauth program).
|
|
Chris PeBenito |
948914 |
ifdef(`xauth.te', `
|
|
Chris PeBenito |
948914 |
file_type_auto_trans($1_su_t, staff_home_dir_t, staff_xauth_home_t, file)
|
|
Chris PeBenito |
948914 |
file_type_auto_trans($1_su_t, user_home_dir_t, user_xauth_home_t, file)
|
|
Chris PeBenito |
948914 |
file_type_auto_trans($1_su_t, sysadm_home_dir_t, sysadm_xauth_home_t, file)
|
|
Chris PeBenito |
948914 |
domain_auto_trans($1_su_t, xauth_exec_t, $1_xauth_t)
|
|
Chris PeBenito |
948914 |
')
|
|
Chris PeBenito |
948914 |
|
|
Chris PeBenito |
948914 |
ifdef(`cyrus.te', `
|
|
Chris PeBenito |
948914 |
allow $1_su_t cyrus_var_lib_t:dir search;
|
|
Chris PeBenito |
948914 |
')
|
|
Chris PeBenito |
948914 |
ifdef(`ssh.te', `
|
|
Chris PeBenito |
948914 |
# Access sshd cookie files.
|
|
Chris PeBenito |
948914 |
allow $1_su_t sshd_tmp_t:file rw_file_perms;
|
|
Chris PeBenito |
948914 |
file_type_auto_trans($1_su_t, sshd_tmp_t, $1_tmp_t)
|
|
Chris PeBenito |
948914 |
')
|
|
Chris PeBenito |
948914 |
') dnl end TODO
|
|
Chris PeBenito |
948914 |
')
|