selinux-policy/policy/modules/admin/sudo.if

147 lines
3.9 KiB
Plaintext
Raw Normal View History

2005-08-09 19:30:43 +00:00
## <summary>Execute a command with a substitute user</summary>
#######################################
## <summary>
2006-09-06 22:07:25 +00:00
## The per 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>
## <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">
## <summary>
2005-08-09 19:30:43 +00:00
## The prefix of the user domain (e.g., user
## is the prefix for user_t).
## </summary>
2005-08-09 19:30:43 +00:00
## </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-08-09 19:30:43 +00:00
#
2006-09-06 22:07:25 +00:00
template(`sudo_per_role_template',`
2005-08-09 19:30:43 +00:00
2005-09-14 00:30:10 +00:00
gen_require(`
type sudo_exec_t;
')
2005-08-09 19:30:43 +00:00
##############################
#
# Declarations
#
2005-09-26 20:26:32 +00:00
type $1_sudo_t;
2005-08-09 19:30:43 +00:00
domain_type($1_sudo_t)
domain_entry_file($1_sudo_t,sudo_exec_t)
2006-02-20 21:33:25 +00:00
domain_interactive_fd($1_sudo_t)
role $3 types $1_sudo_t;
2005-08-09 19:30:43 +00:00
##############################
#
# Local Policy
#
# Use capabilities.
2005-09-16 19:36:10 +00:00
allow $1_sudo_t self:capability { fowner setuid setgid dac_override sys_resource };
2005-09-01 20:13:42 +00:00
allow $1_sudo_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
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;
allow $1_sudo_t self:netlink_audit_socket { create bind write nlmsg_read read };
allow $1_sudo_t self:netlink_route_socket r_netlink_socket_perms;
2005-08-09 19:30:43 +00:00
# Enter this derived domain from the user domain
2006-12-12 20:08:08 +00:00
domtrans_pattern($2, 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.
corecmd_shell_domtrans($1_sudo_t,$2)
allow $2 $1_sudo_t:fd use;
2006-12-12 20:08:08 +00:00
allow $2 $1_sudo_t:fifo_file rw_file_perms;
allow $2 $1_sudo_t:process sigchld;
2005-08-09 19:30: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)
kernel_search_key($1_sudo_t)
2005-08-09 19:30:43 +00:00
dev_read_urand($1_sudo_t)
fs_search_auto_mountpoints($1_sudo_t)
fs_getattr_xattr_fs($1_sudo_t)
auth_domtrans_chk_passwd($1_sudo_t)
# sudo stores a token in the pam_pid directory
auth_manage_pam_pid($1_sudo_t)
2005-08-09 19:30:43 +00:00
2007-03-23 23:24:59 +00:00
corecmd_read_bin_symlinks($1_sudo_t)
corecmd_getattr_all_executables($1_sudo_t)
2005-08-09 19:30:43 +00:00
2006-02-20 21:33:25 +00:00
domain_use_interactive_fds($1_sudo_t)
domain_sigchld_interactive_fds($1_sudo_t)
2005-08-09 19:30:43 +00:00
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)
init_rw_utmp($1_sudo_t)
2005-08-09 19:30:43 +00:00
libs_use_ld_so($1_sudo_t)
libs_use_shared_libs($1_sudo_t)
logging_send_syslog_msg($1_sudo_t)
miscfiles_read_localization($1_sudo_t)
2006-02-21 18:40:44 +00:00
userdom_manage_user_home_content_files($1,$1_sudo_t)
userdom_manage_user_home_content_symlinks($1,$1_sudo_t)
userdom_manage_user_tmp_files($1,$1_sudo_t)
userdom_manage_user_tmp_symlinks($1,$1_sudo_t)
2006-01-25 19:40:21 +00:00
userdom_use_user_terminals($1,$1_sudo_t)
2006-02-21 18:40:44 +00:00
userdom_use_unpriv_users_fds($1_sudo_t)
2005-08-09 19:30:43 +00:00
# for some PAM modules and for cwd
2006-02-21 18:40:44 +00:00
userdom_dontaudit_search_all_users_home_content($1_sudo_t)
2005-08-09 19:30:43 +00:00
optional_policy(`
2005-08-09 19:30:43 +00:00
nis_use_ypbind($1_sudo_t)
')
optional_policy(`
2006-02-02 21:08:12 +00:00
nscd_socket_use($1_sudo_t)
2005-08-09 19:30:43 +00:00
')
ifdef(`TODO',`
# for when the network connection is killed
dontaudit unpriv_userdomain $1_sudo_t:process signal;
ifdef(`mta.te', `
domain_auto_trans($1_sudo_t, sendmail_exec_t, $1_mail_t)
')
') dnl end TODO
')