2005-08-08 21:03:23 +00:00
|
|
|
## <summary>Run shells with substitute user and group</summary>
|
|
|
|
|
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)
|
|
|
|
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 setuid setgid net_bind_service chown dac_override fowner sys_nice sys_resource };
|
|
|
|
dontaudit $1_su_t self:capability sys_tty_config;
|
|
|
|
allow $1_su_t self:process { setexec setsched setrlimit };
|
|
|
|
allow $1_su_t self:fifo_file rw_file_perms;
|
|
|
|
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.
|
|
|
|
domain_auto_trans($2, su_exec_t, $1_su_t)
|
|
|
|
allow $1_su_t $2:fd use;
|
|
|
|
allow $1_su_t $2:fifo_file rw_file_perms;
|
|
|
|
allow $1_su_t $2:process sigchld;
|
|
|
|
|
|
|
|
# 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;
|
2006-02-13 22:05:08 +00:00
|
|
|
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)
|
2006-01-31 16:49:43 +00:00
|
|
|
kernel_read_kernel_sysctls($1_su_t)
|
2005-10-24 11:55:53 +00:00
|
|
|
|
|
|
|
# for SSP
|
|
|
|
dev_read_urand($1_su_t)
|
|
|
|
|
2005-12-09 15:42:39 +00:00
|
|
|
files_read_etc_files($1_su_t)
|
|
|
|
files_read_etc_runtime_files($1_su_t)
|
|
|
|
files_search_var_lib($1_su_t)
|
2006-01-31 19:21:01 +00:00
|
|
|
files_dontaudit_getattr_tmp_dirs($1_su_t)
|
2005-12-09 15:42:39 +00:00
|
|
|
|
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)
|
|
|
|
|
2006-02-20 21:33:25 +00:00
|
|
|
domain_use_interactive_fds($1_su_t)
|
2005-10-24 11:55:53 +00:00
|
|
|
|
2005-11-08 22:00:30 +00:00
|
|
|
init_dontaudit_use_fd($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.
|
2006-01-18 18:08:39 +00:00
|
|
|
init_rw_utmp($1_su_t)
|
2005-10-24 11:55:53 +00:00
|
|
|
|
|
|
|
libs_use_ld_so($1_su_t)
|
|
|
|
libs_use_shared_libs($1_su_t)
|
|
|
|
|
|
|
|
logging_send_syslog_msg($1_su_t)
|
|
|
|
|
|
|
|
miscfiles_read_localization($1_su_t)
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`cron',`
|
2006-02-02 21:08:12 +00:00
|
|
|
cron_read_pipes($1_su_t)
|
2005-10-24 11:55:53 +00:00
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`kerberos',`
|
2005-10-24 11:55:53 +00:00
|
|
|
kerberos_use($1_su_t)
|
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`nscd',`
|
2006-02-02 21:08:12 +00:00
|
|
|
nscd_socket_use($1_su_t)
|
2005-10-24 11:55:53 +00:00
|
|
|
')
|
|
|
|
|
|
|
|
ifdef(`TODO',`
|
|
|
|
# Caused by su - init scripts
|
|
|
|
dontaudit $1_su_t initrc_devpts_t:chr_file { getattr ioctl };
|
|
|
|
') dnl end TODO
|
|
|
|
')
|
|
|
|
|
2005-08-09 19:21:25 +00:00
|
|
|
#######################################
|
|
|
|
## <summary>
|
|
|
|
## The per user domain template for the su module.
|
|
|
|
## </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>
|
|
|
|
## <p>
|
|
|
|
## This template is invoked automatically for each user, and
|
|
|
|
## generally does not need to be invoked directly
|
|
|
|
## by policy writers.
|
|
|
|
## </p>
|
|
|
|
## </desc>
|
|
|
|
## <param name="userdomain_prefix">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2005-08-09 19:21:25 +00:00
|
|
|
## The prefix of the user domain (e.g., user
|
|
|
|
## is the prefix for user_t).
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-08-09 19:21:25 +00:00
|
|
|
## </param>
|
2005-08-30 15:48:57 +00:00
|
|
|
## <param name="user_domain">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2005-08-30 15:48:57 +00:00
|
|
|
## The type of the user domain.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-08-30 15:48:57 +00:00
|
|
|
## </param>
|
|
|
|
## <param name="user_role">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2005-08-30 15:48:57 +00:00
|
|
|
## The role associated with the user domain.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-08-30 15:48:57 +00:00
|
|
|
## </param>
|
2005-08-09 19:21:25 +00:00
|
|
|
#
|
2005-08-08 21:03:23 +00:00
|
|
|
template(`su_per_userdomain_template',`
|
2005-10-13 20:59:36 +00:00
|
|
|
gen_require(`
|
|
|
|
type su_exec_t;
|
2005-10-19 14:36:04 +00:00
|
|
|
bool secure_mode;
|
2005-10-13 20:59:36 +00:00
|
|
|
')
|
|
|
|
|
|
|
|
type $1_su_t;
|
|
|
|
domain_entry_file($1_su_t,su_exec_t)
|
|
|
|
domain_type($1_su_t)
|
2006-02-20 21:33:25 +00:00
|
|
|
domain_interactive_fd($1_su_t)
|
2005-10-13 20:59:36 +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 setuid setgid net_bind_service chown dac_override fowner sys_nice sys_resource };
|
|
|
|
dontaudit $1_su_t self:capability sys_tty_config;
|
|
|
|
allow $1_su_t self:process { setexec setsched setrlimit };
|
|
|
|
allow $1_su_t self:fifo_file rw_file_perms;
|
|
|
|
allow $1_su_t self:netlink_audit_socket { nlmsg_relay create_netlink_socket_perms };
|
|
|
|
|
|
|
|
# Transition from the user domain to this domain.
|
|
|
|
domain_auto_trans($2, su_exec_t, $1_su_t)
|
|
|
|
allow $2 $1_su_t:fd use;
|
|
|
|
allow $1_su_t $2:fd use;
|
|
|
|
allow $1_su_t $2:fifo_file rw_file_perms;
|
|
|
|
allow $1_su_t $2:process sigchld;
|
|
|
|
|
|
|
|
# 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 $1_su_t $2:fd use;
|
|
|
|
allow $1_su_t $2:fifo_file rw_file_perms;
|
|
|
|
allow $1_su_t $2:process sigchld;
|
|
|
|
|
|
|
|
kernel_read_system_state($1_su_t)
|
2006-01-31 16:49:43 +00:00
|
|
|
kernel_read_kernel_sysctls($1_su_t)
|
2005-10-13 20:59:36 +00:00
|
|
|
|
|
|
|
# for SSP
|
|
|
|
dev_read_urand($1_su_t)
|
|
|
|
|
|
|
|
fs_search_auto_mountpoints($1_su_t)
|
|
|
|
|
2005-10-24 19:50:21 +00:00
|
|
|
auth_domtrans_user_chk_passwd($1,$1_su_t)
|
2005-10-13 20:59:36 +00:00
|
|
|
auth_dontaudit_read_shadow($1_su_t)
|
2005-10-14 17:55:40 +00:00
|
|
|
auth_use_nsswitch($1_su_t)
|
2005-10-13 20:59:36 +00:00
|
|
|
|
2005-10-25 14:31:53 +00:00
|
|
|
corecmd_search_bin($1_su_t)
|
|
|
|
corecmd_search_sbin($1_su_t)
|
|
|
|
|
2006-02-20 21:33:25 +00:00
|
|
|
domain_use_interactive_fds($1_su_t)
|
2005-10-13 20:59:36 +00:00
|
|
|
|
|
|
|
files_read_etc_files($1_su_t)
|
2006-01-11 15:28:14 +00:00
|
|
|
files_read_etc_runtime_files($1_su_t)
|
2005-10-13 20:59:36 +00:00
|
|
|
files_search_var_lib($1_su_t)
|
2006-01-31 19:21:01 +00:00
|
|
|
files_dontaudit_getattr_tmp_dirs($1_su_t)
|
2005-10-13 20:59:36 +00:00
|
|
|
|
|
|
|
init_dontaudit_use_fd($1_su_t)
|
|
|
|
# Write to utmp.
|
2006-01-18 18:08:39 +00:00
|
|
|
init_rw_utmp($1_su_t)
|
2005-10-13 20:59:36 +00:00
|
|
|
|
|
|
|
libs_use_ld_so($1_su_t)
|
|
|
|
libs_use_shared_libs($1_su_t)
|
|
|
|
|
|
|
|
logging_send_syslog_msg($1_su_t)
|
|
|
|
|
|
|
|
miscfiles_read_localization($1_su_t)
|
|
|
|
|
|
|
|
userdom_use_user_terminals($1,$1_su_t)
|
2006-02-21 18:40:44 +00:00
|
|
|
userdom_search_user_home_dirs($1,$1_su_t)
|
2005-10-13 20:59:36 +00:00
|
|
|
|
2006-01-10 21:03:16 +00:00
|
|
|
ifdef(`enable_polyinstantiation',`
|
2006-01-25 19:40:21 +00:00
|
|
|
fs_mount_xattr_fs($1_su_t)
|
2006-01-10 21:03:16 +00:00
|
|
|
fs_unmount_xattr_fs($1_su_t)
|
|
|
|
')
|
|
|
|
|
2005-10-24 20:01:03 +00:00
|
|
|
ifdef(`targeted_policy',`
|
2005-11-18 18:38:37 +00:00
|
|
|
# allow user to suspend terminal.
|
|
|
|
# does not work in strict since the
|
|
|
|
# parent may not be able to use
|
|
|
|
# the terminal if we newrole,
|
|
|
|
# which relabels the terminal.
|
|
|
|
allow $1_su_t self:process sigstop;
|
|
|
|
|
2005-10-24 20:01:03 +00:00
|
|
|
corecmd_exec_bin($1_su_t)
|
2006-02-21 18:40:44 +00:00
|
|
|
userdom_manage_all_users_home_content_files($1_su_t)
|
|
|
|
userdom_manage_all_users_home_content_symlinks($1_su_t)
|
2005-10-24 20:01:03 +00:00
|
|
|
')
|
|
|
|
|
2005-10-13 20:59:36 +00:00
|
|
|
tunable_policy(`use_nfs_home_dirs',`
|
|
|
|
fs_search_nfs($1_su_t)
|
|
|
|
')
|
|
|
|
|
|
|
|
tunable_policy(`use_samba_home_dirs',`
|
|
|
|
fs_search_cifs($1_su_t)
|
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`cron',`
|
2006-02-02 21:08:12 +00:00
|
|
|
cron_read_pipes($1_su_t)
|
2005-10-13 20:59:36 +00:00
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`kerberos',`
|
2005-10-13 20:59:36 +00:00
|
|
|
kerberos_use($1_su_t)
|
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`nscd',`
|
2006-02-02 21:08:12 +00:00
|
|
|
nscd_socket_use($1_su_t)
|
2005-10-13 20:59:36 +00:00
|
|
|
')
|
|
|
|
|
2006-02-22 21:21:26 +00:00
|
|
|
# Modify .Xauthority file (via xauth program).
|
|
|
|
optional_policy(`xserver',`
|
|
|
|
# file_type_auto_trans($1_su_t, staff_home_dir_t, staff_xauth_home_t, file)
|
|
|
|
# file_type_auto_trans($1_su_t, user_home_dir_t, user_xauth_home_t, file)
|
|
|
|
# file_type_auto_trans($1_su_t, sysadm_home_dir_t, sysadm_xauth_home_t, file)
|
|
|
|
xserver_domtrans_user_xauth($1, $1_su_t)
|
|
|
|
')
|
|
|
|
|
2005-10-13 20:59:36 +00:00
|
|
|
ifdef(`TODO',`
|
|
|
|
# Caused by su - init scripts
|
|
|
|
dontaudit $1_su_t initrc_devpts_t:chr_file { getattr ioctl };
|
|
|
|
|
|
|
|
# Inherit and use descriptors from gnome-pty-helper.
|
|
|
|
ifdef(`gnome-pty-helper.te', `allow $1_su_t $1_gph_t:fd use;')
|
|
|
|
|
|
|
|
allow $1_su_t $1_home_t:file create_file_perms;
|
|
|
|
|
|
|
|
ifdef(`user_canbe_sysadm', `
|
|
|
|
allow $1_su_t home_dir_type:dir { search write };
|
|
|
|
', `
|
|
|
|
dontaudit $1_su_t home_dir_type:dir { search write };
|
|
|
|
')
|
|
|
|
|
|
|
|
ifdef(`ssh.te', `
|
|
|
|
# Access sshd cookie files.
|
|
|
|
allow $1_su_t sshd_tmp_t:file rw_file_perms;
|
|
|
|
file_type_auto_trans($1_su_t, sshd_tmp_t, $1_tmp_t)
|
2005-08-08 21:03:23 +00:00
|
|
|
')
|
2005-10-13 20:59:36 +00:00
|
|
|
') dnl end TODO
|
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">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2005-10-11 15:36:53 +00:00
|
|
|
## Domain allowed access.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-10-11 15:36:53 +00:00
|
|
|
## </param>
|
|
|
|
#
|
|
|
|
interface(`su_exec',`
|
|
|
|
gen_require(`
|
|
|
|
type su_exec_t;
|
|
|
|
')
|
|
|
|
|
|
|
|
can_exec($1,su_exec_t)
|
|
|
|
')
|