selinux-refpolicy/policy/modules/admin/su.if

278 lines
6.4 KiB
Plaintext
Raw Normal View History

## <summary>Run shells with substitute user and group.</summary>
2005-08-08 21:03:23 +00:00
#######################################
## <summary>
## Restricted su domain template.
## </summary>
## <desc>
## <p>
## This template creates a derived domain which is allowed
## to change the linux user id, to run shells as a different
## user.
## </p>
## </desc>
## <param name="userdomain_prefix">
## <summary>
## The prefix of the user domain (e.g., user
## is the prefix for user_t).
## </summary>
## </param>
## <param name="user_domain">
## <summary>
## The type of the user domain.
## </summary>
## </param>
## <param name="user_role">
## <summary>
## The role associated with the user domain.
## </summary>
## </param>
#
2005-10-24 11:55:53 +00:00
template(`su_restricted_domain_template', `
gen_require(`
type su_exec_t;
')
type $1_su_t;
domain_entry_file($1_su_t, su_exec_t)
2005-10-24 11:55:53 +00:00
domain_type($1_su_t)
2006-02-20 21:33:25 +00:00
domain_interactive_fd($1_su_t)
2005-10-24 11:55:53 +00:00
role $3 types $1_su_t;
allow $2 $1_su_t:process signal;
allow $1_su_t self:capability { audit_control audit_write chown dac_override fowner net_bind_service setgid setuid sys_nice sys_resource };
2005-10-24 11:55:53 +00:00
dontaudit $1_su_t self:capability sys_tty_config;
allow $1_su_t self:key { search write };
2005-10-24 11:55:53 +00:00
allow $1_su_t self:process { setexec setsched setrlimit };
2006-12-12 20:08:08 +00:00
allow $1_su_t self:fifo_file rw_fifo_file_perms;
2005-10-24 11:55:53 +00:00
allow $1_su_t self:netlink_audit_socket { nlmsg_relay create_netlink_socket_perms };
2005-11-10 21:37:54 +00:00
allow $1_su_t self:unix_stream_socket create_stream_socket_perms;
2005-10-24 11:55:53 +00:00
# Transition from the user domain to this domain.
2006-12-12 20:08:08 +00:00
domtrans_pattern($2, su_exec_t, $1_su_t)
2005-10-24 11:55:53 +00:00
# By default, revert to the calling domain when a shell is executed.
corecmd_shell_domtrans($1_su_t,$2)
allow $2 $1_su_t:fd use;
allow $2 $1_su_t:fifo_file rw_file_perms;
allow $2 $1_su_t:process sigchld;
2005-10-24 11:55:53 +00:00
kernel_read_system_state($1_su_t)
kernel_read_kernel_sysctls($1_su_t)
kernel_search_key($1_su_t)
kernel_link_key($1_su_t)
2005-10-24 11:55:53 +00:00
# for SSP
dev_read_urand($1_su_t)
files_read_etc_files($1_su_t)
files_read_etc_runtime_files($1_su_t)
files_search_var_lib($1_su_t)
files_dontaudit_getattr_tmp_dirs($1_su_t)
2006-05-25 13:14:08 +00:00
# for the rootok check
selinux_compute_access_vector($1_su_t)
2005-10-24 11:55:53 +00:00
auth_domtrans_chk_passwd($1_su_t)
auth_dontaudit_read_shadow($1_su_t)
auth_use_nsswitch($1_su_t)
auth_rw_faillog($1_su_t)
2005-10-24 11:55:53 +00:00
2006-02-20 21:33:25 +00:00
domain_use_interactive_fds($1_su_t)
2005-10-24 11:55:53 +00:00
init_dontaudit_use_fds($1_su_t)
2006-02-02 21:08:12 +00:00
init_dontaudit_use_script_ptys($1_su_t)
2005-10-24 11:55:53 +00:00
# Write to utmp.
init_rw_utmp($1_su_t)
init_search_script_keys($1_su_t)
2005-10-24 11:55:53 +00:00
logging_send_syslog_msg($1_su_t)
miscfiles_read_localization($1_su_t)
2009-01-13 19:44:23 +00:00
ifdef(`distro_redhat',`
# RHEL5 and possibly newer releases incl. Fedora
auth_domtrans_upd_passwd($1_su_t)
optional_policy(`
locallogin_search_keys($1_su_t)
')
')
optional_policy(`
2006-02-02 21:08:12 +00:00
cron_read_pipes($1_su_t)
2005-10-24 11:55:53 +00:00
')
optional_policy(`
2005-10-24 11:55:53 +00:00
kerberos_use($1_su_t)
')
optional_policy(`
# used when the password has expired
usermanage_read_crack_db($1_su_t)
')
2005-10-24 11:55:53 +00:00
')
2005-08-09 19:21:25 +00:00
#######################################
## <summary>
2008-11-05 16:10:46 +00:00
## The role template for the su module.
2005-08-09 19:21:25 +00:00
## </summary>
2008-11-05 16:10:46 +00:00
## <param name="role_prefix">
## <summary>
2008-11-05 16:10:46 +00:00
## The prefix of the user role (e.g., user
## is the prefix for user_r).
## </summary>
2005-08-09 19:21:25 +00:00
## </param>
2008-11-05 16:10:46 +00:00
## <param name="user_role">
## <summary>
2008-11-05 16:10:46 +00:00
## The role associated with the user domain.
## </summary>
## </param>
2008-11-05 16:10:46 +00:00
## <param name="user_domain">
## <summary>
2008-11-05 16:10:46 +00:00
## The type of the user domain.
## </summary>
## </param>
2005-08-09 19:21:25 +00:00
#
2008-11-05 16:10:46 +00:00
template(`su_role_template',`
gen_require(`
type su_exec_t;
')
type $1_su_t;
userdom_user_application_domain($1_su_t, su_exec_t)
2006-02-20 21:33:25 +00:00
domain_interactive_fd($1_su_t)
2008-11-05 16:10:46 +00:00
role $2 types $1_su_t;
2008-11-05 16:10:46 +00:00
allow $3 $1_su_t:process signal;
allow $1_su_t self:capability { audit_control audit_write chown dac_override fowner net_bind_service setgid setuid sys_nice sys_resource };
dontaudit $1_su_t self:capability { net_admin sys_tty_config };
allow $1_su_t self:process { setexec setsched setrlimit };
2006-12-12 20:08:08 +00:00
allow $1_su_t self:fifo_file rw_fifo_file_perms;
allow $1_su_t self:netlink_audit_socket { nlmsg_relay create_netlink_socket_perms };
allow $1_su_t self:key { search write };
allow $1_su_t $3:key search;
# Transition from the user domain to this domain.
2008-11-05 16:10:46 +00:00
domtrans_pattern($3, su_exec_t, $1_su_t)
ps_process_pattern($3, $1_su_t)
# By default, revert to the calling domain when a shell is executed.
2008-11-05 16:10:46 +00:00
corecmd_shell_domtrans($1_su_t, $3)
allow $3 $1_su_t:fd use;
allow $3 $1_su_t:fifo_file rw_file_perms;
allow $3 $1_su_t:process sigchld;
kernel_read_system_state($1_su_t)
kernel_read_kernel_sysctls($1_su_t)
kernel_search_key($1_su_t)
kernel_link_key($1_su_t)
# for SSP
dev_read_urand($1_su_t)
fs_search_auto_mountpoints($1_su_t)
# needed for pam_rootok
selinux_compute_access_vector($1_su_t)
2008-11-05 16:10:46 +00:00
auth_domtrans_chk_passwd($1_su_t)
auth_dontaudit_read_shadow($1_su_t)
2005-10-14 17:55:40 +00:00
auth_use_nsswitch($1_su_t)
2007-04-30 14:32:31 +00:00
auth_rw_faillog($1_su_t)
2005-10-25 14:31:53 +00:00
corecmd_search_bin($1_su_t)
2006-02-20 21:33:25 +00:00
domain_use_interactive_fds($1_su_t)
files_read_etc_files($1_su_t)
2006-01-11 15:28:14 +00:00
files_read_etc_runtime_files($1_su_t)
files_search_var_lib($1_su_t)
files_dontaudit_getattr_tmp_dirs($1_su_t)
init_dontaudit_use_fds($1_su_t)
init_dontaudit_read_state($1_su_t)
# Write to utmp.
init_rw_utmp($1_su_t)
mls_file_write_all_levels($1_su_t)
logging_send_syslog_msg($1_su_t)
miscfiles_read_localization($1_su_t)
# pam_unix is linked against libselinux
seutil_libselinux_linked($1_su_t)
2008-11-05 16:10:46 +00:00
userdom_use_user_terminals($1_su_t)
userdom_search_user_home_dirs($1_su_t)
2009-01-13 19:44:23 +00:00
ifdef(`distro_redhat',`
# RHEL5 and possibly newer releases incl. Fedora
auth_domtrans_upd_passwd($1_su_t)
optional_policy(`
locallogin_search_keys($1_su_t)
')
')
optional_policy(`
auth_use_pam_systemd($1_su_t)
')
tunable_policy(`allow_polyinstantiation',`
fs_mount_xattr_fs($1_su_t)
fs_unmount_xattr_fs($1_su_t)
')
tunable_policy(`use_nfs_home_dirs',`
fs_search_nfs($1_su_t)
')
tunable_policy(`use_samba_home_dirs',`
fs_search_cifs($1_su_t)
')
optional_policy(`
2006-02-02 21:08:12 +00:00
cron_read_pipes($1_su_t)
')
optional_policy(`
kerberos_use($1_su_t)
')
optional_policy(`
# used when the password has expired
usermanage_read_crack_db($1_su_t)
')
# Modify .Xauthority file (via xauth program).
optional_policy(`
2008-11-05 16:10:46 +00:00
xserver_user_home_dir_filetrans_user_xauth($1_su_t)
xserver_domtrans_xauth($1_su_t)
')
2005-08-08 21:03:23 +00:00
')
2005-10-11 15:36:53 +00:00
#######################################
## <summary>
## Execute su in the caller domain.
## </summary>
## <param name="domain">
## <summary>
2005-10-11 15:36:53 +00:00
## Domain allowed access.
## </summary>
2005-10-11 15:36:53 +00:00
## </param>
#
interface(`su_exec',`
gen_require(`
type su_exec_t;
')
corecmd_search_bin($1)
can_exec($1, su_exec_t)
2005-10-11 15:36:53 +00:00
')