2005-08-09 19:30:43 +00:00
|
|
|
## <summary>Execute a command with a substitute user</summary>
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
## <summary>
|
2008-11-05 16:10:46 +00:00
|
|
|
## The role template for the sudo module.
|
2005-08-09 19:30:43 +00:00
|
|
|
## </summary>
|
|
|
|
## <desc>
|
|
|
|
## <p>
|
|
|
|
## This template creates a derived domain which is allowed
|
|
|
|
## to change the linux user id, to run commands as a different
|
|
|
|
## user.
|
|
|
|
## </p>
|
|
|
|
## </desc>
|
2008-11-05 16:10:46 +00:00
|
|
|
## <param name="role_prefix">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2008-11-05 16:10:46 +00:00
|
|
|
## The prefix of the user role (e.g., user
|
|
|
|
## is the prefix for user_r).
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-08-09 19:30:43 +00:00
|
|
|
## </param>
|
2008-11-05 16:10:46 +00:00
|
|
|
## <param name="user_role">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2008-11-05 16:10:46 +00:00
|
|
|
## The user role.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-08-30 15:48:57 +00:00
|
|
|
## </param>
|
2008-11-05 16:10:46 +00:00
|
|
|
## <param name="user_domain">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2008-11-05 16:10:46 +00:00
|
|
|
## The user domain associated with the role.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-08-30 15:48:57 +00:00
|
|
|
## </param>
|
2005-08-09 19:30:43 +00:00
|
|
|
#
|
2008-11-05 16:10:46 +00:00
|
|
|
template(`sudo_role_template',`
|
2005-08-09 19:30:43 +00:00
|
|
|
|
2005-09-14 00:30:10 +00:00
|
|
|
gen_require(`
|
|
|
|
type sudo_exec_t;
|
2009-07-28 14:29:11 +00:00
|
|
|
attribute sudodomain;
|
2005-09-14 00:30:10 +00:00
|
|
|
')
|
|
|
|
|
2005-08-09 19:30:43 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Declarations
|
|
|
|
#
|
|
|
|
|
2016-12-06 12:28:10 +00:00
|
|
|
type $1_sudo_t, sudodomain;
|
2011-10-28 12:48:10 +00:00
|
|
|
userdom_user_application_domain($1_sudo_t, sudo_exec_t)
|
2006-02-20 21:33:25 +00:00
|
|
|
domain_interactive_fd($1_sudo_t)
|
2009-07-28 14:29:11 +00:00
|
|
|
domain_role_change_exemption($1_sudo_t)
|
2008-11-05 16:10:46 +00:00
|
|
|
role $2 types $1_sudo_t;
|
2005-08-09 19:30:43 +00:00
|
|
|
|
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Local Policy
|
|
|
|
#
|
|
|
|
|
|
|
|
# Use capabilities.
|
2019-09-14 12:00:58 +00:00
|
|
|
allow $1_sudo_t self:capability { chown dac_override fowner kill setgid setuid sys_nice sys_resource };
|
2017-08-13 20:21:44 +00:00
|
|
|
allow $1_sudo_t self:process { signal_perms getsched setsched getsession getpgid setpgid getcap setcap share getattr getrlimit rlimitinh siginh transition setsockcreate dyntransition noatsecure setkeycreate };
|
2005-08-09 19:30:43 +00:00
|
|
|
allow $1_sudo_t self:process { setexec setrlimit };
|
|
|
|
allow $1_sudo_t self:fd use;
|
2006-12-12 20:08:08 +00:00
|
|
|
allow $1_sudo_t self:fifo_file rw_fifo_file_perms;
|
2005-08-09 19:30:43 +00:00
|
|
|
allow $1_sudo_t self:shm create_shm_perms;
|
|
|
|
allow $1_sudo_t self:sem create_sem_perms;
|
|
|
|
allow $1_sudo_t self:msgq create_msgq_perms;
|
|
|
|
allow $1_sudo_t self:msg { send receive };
|
2005-10-14 17:55:40 +00:00
|
|
|
allow $1_sudo_t self:unix_dgram_socket create_socket_perms;
|
|
|
|
allow $1_sudo_t self:unix_stream_socket create_stream_socket_perms;
|
|
|
|
allow $1_sudo_t self:unix_dgram_socket sendto;
|
|
|
|
allow $1_sudo_t self:unix_stream_socket connectto;
|
2010-02-11 14:15:45 +00:00
|
|
|
allow $1_sudo_t self:key manage_key_perms;
|
2009-07-28 14:29:11 +00:00
|
|
|
|
|
|
|
allow $1_sudo_t $3:key search;
|
2005-08-09 19:30:43 +00:00
|
|
|
|
2019-09-14 11:58:39 +00:00
|
|
|
# Transmit SIGWINCH to children
|
|
|
|
allow $1_sudo_t $3:process signal;
|
|
|
|
|
2005-08-09 19:30:43 +00:00
|
|
|
# Enter this derived domain from the user domain
|
2008-11-05 16:10:46 +00:00
|
|
|
domtrans_pattern($3, sudo_exec_t, $1_sudo_t)
|
2005-08-09 19:30:43 +00:00
|
|
|
|
|
|
|
# By default, revert to the calling domain when a shell is executed.
|
2008-11-05 16:10:46 +00:00
|
|
|
corecmd_shell_domtrans($1_sudo_t, $3)
|
2009-07-28 14:29:11 +00:00
|
|
|
corecmd_bin_domtrans($1_sudo_t, $3)
|
2008-11-05 16:10:46 +00:00
|
|
|
allow $3 $1_sudo_t:fd use;
|
2010-10-08 20:40:58 +00:00
|
|
|
allow $3 $1_sudo_t:fifo_file rw_fifo_file_perms;
|
2010-06-18 18:43:22 +00:00
|
|
|
allow $3 $1_sudo_t:process signal_perms;
|
2005-08-09 19:30:43 +00:00
|
|
|
|
2006-01-31 16:49:43 +00:00
|
|
|
kernel_read_kernel_sysctls($1_sudo_t)
|
2005-08-09 19:30:43 +00:00
|
|
|
kernel_read_system_state($1_sudo_t)
|
2009-07-28 14:29:11 +00:00
|
|
|
kernel_link_key($1_sudo_t)
|
2005-08-09 19:30:43 +00:00
|
|
|
|
2010-02-11 14:15:45 +00:00
|
|
|
corecmd_exec_all_executables($1_sudo_t)
|
2009-08-05 13:48:46 +00:00
|
|
|
|
2010-10-08 18:33:04 +00:00
|
|
|
dev_getattr_fs($1_sudo_t)
|
2005-08-09 19:30:43 +00:00
|
|
|
dev_read_urand($1_sudo_t)
|
2009-07-28 14:29:11 +00:00
|
|
|
dev_rw_generic_usb_dev($1_sudo_t)
|
|
|
|
dev_read_sysfs($1_sudo_t)
|
2005-08-09 19:30:43 +00:00
|
|
|
|
2009-08-05 13:48:46 +00:00
|
|
|
domain_use_interactive_fds($1_sudo_t)
|
|
|
|
domain_sigchld_interactive_fds($1_sudo_t)
|
|
|
|
domain_getattr_all_entry_files($1_sudo_t)
|
|
|
|
|
|
|
|
files_read_etc_files($1_sudo_t)
|
|
|
|
files_read_var_files($1_sudo_t)
|
|
|
|
files_read_usr_symlinks($1_sudo_t)
|
|
|
|
files_getattr_usr_files($1_sudo_t)
|
|
|
|
# for some PAM modules and for cwd
|
|
|
|
files_dontaudit_search_home($1_sudo_t)
|
|
|
|
files_list_tmp($1_sudo_t)
|
|
|
|
|
2005-08-09 19:30:43 +00:00
|
|
|
fs_search_auto_mountpoints($1_sudo_t)
|
|
|
|
fs_getattr_xattr_fs($1_sudo_t)
|
|
|
|
|
2009-07-28 14:29:11 +00:00
|
|
|
selinux_validate_context($1_sudo_t)
|
|
|
|
selinux_compute_relabel_context($1_sudo_t)
|
|
|
|
|
2010-10-04 18:23:50 +00:00
|
|
|
term_getattr_pty_fs($1_sudo_t)
|
2014-03-25 20:30:04 +00:00
|
|
|
term_dontaudit_getattr_unallocated_ttys($1_sudo_t)
|
2010-02-11 19:20:10 +00:00
|
|
|
term_relabel_all_ttys($1_sudo_t)
|
|
|
|
term_relabel_all_ptys($1_sudo_t)
|
2009-07-28 14:29:11 +00:00
|
|
|
|
|
|
|
auth_run_chk_passwd($1_sudo_t, $2)
|
2020-06-27 21:11:48 +00:00
|
|
|
# sudo stores a token in the pam runtime directory
|
|
|
|
auth_manage_pam_runtime_dirs($1_sudo_t)
|
|
|
|
auth_manage_pam_runtime_files($1_sudo_t)
|
2019-01-06 18:31:42 +00:00
|
|
|
auth_use_pam($1_sudo_t)
|
2020-06-27 21:11:48 +00:00
|
|
|
auth_runtime_filetrans_pam_runtime($1_sudo_t, dir, "sudo")
|
2005-08-09 19:30:43 +00:00
|
|
|
|
2006-01-18 18:08:39 +00:00
|
|
|
init_rw_utmp($1_sudo_t)
|
2005-08-09 19:30:43 +00:00
|
|
|
|
2009-07-28 14:29:11 +00:00
|
|
|
logging_send_audit_msgs($1_sudo_t)
|
2005-08-09 19:30:43 +00:00
|
|
|
logging_send_syslog_msg($1_sudo_t)
|
|
|
|
|
|
|
|
miscfiles_read_localization($1_sudo_t)
|
|
|
|
|
2019-08-28 08:46:22 +00:00
|
|
|
seutil_read_default_contexts($1_sudo_t)
|
2009-07-28 14:29:11 +00:00
|
|
|
seutil_libselinux_linked($1_sudo_t)
|
|
|
|
|
|
|
|
userdom_spec_domtrans_all_users($1_sudo_t)
|
2012-04-11 18:42:59 +00:00
|
|
|
userdom_create_all_users_keys($1_sudo_t)
|
2019-09-06 22:37:52 +00:00
|
|
|
userdom_create_user_pty($1_sudo_t)
|
2008-11-05 16:10:46 +00:00
|
|
|
userdom_manage_user_home_content_files($1_sudo_t)
|
|
|
|
userdom_manage_user_home_content_symlinks($1_sudo_t)
|
|
|
|
userdom_manage_user_tmp_files($1_sudo_t)
|
|
|
|
userdom_manage_user_tmp_symlinks($1_sudo_t)
|
2019-09-06 22:37:52 +00:00
|
|
|
userdom_setattr_user_ptys($1_sudo_t)
|
2008-11-05 16:10:46 +00:00
|
|
|
userdom_use_user_terminals($1_sudo_t)
|
2005-08-09 19:30:43 +00:00
|
|
|
# for some PAM modules and for cwd
|
2008-11-05 16:10:46 +00:00
|
|
|
userdom_dontaudit_search_user_home_content($1_sudo_t)
|
2012-03-22 20:13:34 +00:00
|
|
|
userdom_dontaudit_search_user_home_dirs($1_sudo_t)
|
2009-07-28 14:29:11 +00:00
|
|
|
|
2010-06-18 18:43:22 +00:00
|
|
|
ifdef(`hide_broken_symptoms', `
|
|
|
|
dontaudit $1_sudo_t $3:socket_class_set { read write };
|
|
|
|
')
|
|
|
|
|
2009-07-28 14:29:11 +00:00
|
|
|
tunable_policy(`use_nfs_home_dirs',`
|
|
|
|
fs_manage_nfs_files($1_sudo_t)
|
|
|
|
')
|
|
|
|
|
|
|
|
tunable_policy(`use_samba_home_dirs',`
|
|
|
|
fs_manage_cifs_files($1_sudo_t)
|
|
|
|
')
|
|
|
|
|
|
|
|
optional_policy(`
|
|
|
|
dbus_system_bus_client($1_sudo_t)
|
2019-01-05 19:17:18 +00:00
|
|
|
|
2019-01-04 07:51:18 +00:00
|
|
|
ifdef(`init_systemd',`
|
|
|
|
init_dbus_chat($1_sudo_t)
|
|
|
|
')
|
2009-07-28 14:29:11 +00:00
|
|
|
')
|
2010-02-11 14:15:45 +00:00
|
|
|
|
|
|
|
optional_policy(`
|
|
|
|
fprintd_dbus_chat($1_sudo_t)
|
|
|
|
')
|
|
|
|
|
2009-07-28 14:29:11 +00:00
|
|
|
')
|
|
|
|
|
|
|
|
########################################
|
|
|
|
## <summary>
|
|
|
|
## Send a SIGCHLD signal to the sudo domain.
|
|
|
|
## </summary>
|
|
|
|
## <param name="domain">
|
|
|
|
## <summary>
|
|
|
|
## Domain allowed access.
|
|
|
|
## </summary>
|
|
|
|
## </param>
|
|
|
|
#
|
|
|
|
interface(`sudo_sigchld',`
|
|
|
|
gen_require(`
|
|
|
|
attribute sudodomain;
|
|
|
|
')
|
|
|
|
|
|
|
|
allow $1 sudodomain:process sigchld;
|
2005-08-09 19:30:43 +00:00
|
|
|
')
|