|
Chris PeBenito |
7c2f5a |
## <summary>SELinux utility to run a shell with a new role</summary>
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
#######################################
|
|
Chris PeBenito |
7c2f5a |
## <summary>
|
|
Chris PeBenito |
296273 |
## The role template for the userhelper module.
|
|
Chris PeBenito |
7c2f5a |
## </summary>
|
|
Chris PeBenito |
296273 |
## <param name="userrole_prefix">
|
|
Chris PeBenito |
885b83 |
## <summary>
|
|
Chris PeBenito |
296273 |
## The prefix of the user role (e.g., user
|
|
Chris PeBenito |
296273 |
## is the prefix for user_r).
|
|
Chris PeBenito |
885b83 |
## </summary>
|
|
Chris PeBenito |
7c2f5a |
## </param>
|
|
Chris PeBenito |
296273 |
## <param name="user_role">
|
|
Chris PeBenito |
885b83 |
## <summary>
|
|
Chris PeBenito |
296273 |
## The user role.
|
|
Chris PeBenito |
885b83 |
## </summary>
|
|
Chris PeBenito |
7c2f5a |
## </param>
|
|
Chris PeBenito |
296273 |
## <param name="user_domain">
|
|
Chris PeBenito |
885b83 |
## <summary>
|
|
Chris PeBenito |
296273 |
## The user domain associated with the role.
|
|
Chris PeBenito |
885b83 |
## </summary>
|
|
Chris PeBenito |
7c2f5a |
## </param>
|
|
Chris PeBenito |
7c2f5a |
#
|
|
Chris PeBenito |
296273 |
template(`userhelper_role_template',`
|
|
Chris PeBenito |
7c2f5a |
gen_require(`
|
|
Chris PeBenito |
296273 |
attribute userhelper_type;
|
|
Chris PeBenito |
7c2f5a |
type userhelper_exec_t, userhelper_conf_t;
|
|
Chris PeBenito |
7c2f5a |
')
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
########################################
|
|
Chris PeBenito |
7c2f5a |
#
|
|
Chris PeBenito |
7c2f5a |
# Declarations
|
|
Chris PeBenito |
7c2f5a |
#
|
|
Chris PeBenito |
1c1ac6 |
|
|
Chris PeBenito |
296273 |
type $1_userhelper_t, userhelper_type;
|
|
Chris PeBenito |
0bfccd |
application_domain($1_userhelper_t, userhelper_exec_t)
|
|
Chris PeBenito |
1815ba |
domain_role_change_exemption($1_userhelper_t)
|
|
Chris PeBenito |
1815ba |
domain_obj_id_change_exemption($1_userhelper_t)
|
|
Chris PeBenito |
15722e |
domain_interactive_fd($1_userhelper_t)
|
|
Chris PeBenito |
1815ba |
domain_subj_id_change_exemption($1_userhelper_t)
|
|
Chris PeBenito |
296273 |
ubac_constrained($1_userhelper_t)
|
|
Chris PeBenito |
296273 |
role $2 types $1_userhelper_t;
|
|
Chris PeBenito |
2a9837 |
|
|
Chris PeBenito |
7c2f5a |
########################################
|
|
Chris PeBenito |
7c2f5a |
#
|
|
Chris PeBenito |
7c2f5a |
# Local policy
|
|
Chris PeBenito |
7c2f5a |
#
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:capability { setuid setgid net_bind_service dac_override chown sys_tty_config };
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
|
|
Chris PeBenito |
c0868a |
allow $1_userhelper_t self:process setexec;
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:fd use;
|
|
Chris PeBenito |
c0868a |
allow $1_userhelper_t self:fifo_file rw_fifo_file_perms;
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:shm create_shm_perms;
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:sem create_sem_perms;
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:msgq create_msgq_perms;
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:msg { send receive };
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:unix_dgram_socket create_socket_perms;
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:unix_stream_socket create_stream_socket_perms;
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:unix_dgram_socket sendto;
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t self:unix_stream_socket connectto;
|
|
Chris PeBenito |
c0868a |
allow $1_userhelper_t self:sock_file read_sock_file_perms;
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
#Transition to the derived domain.
|
|
Chris PeBenito |
296273 |
domtrans_pattern($3, userhelper_exec_t, $1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
allow $1_userhelper_t userhelper_conf_t:dir rw_dir_perms;
|
|
Chris PeBenito |
0bfccd |
rw_files_pattern($1_userhelper_t, userhelper_conf_t, userhelper_conf_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
can_exec($1_userhelper_t, userhelper_exec_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
296273 |
dontaudit $3 $1_userhelper_t:process signal;
|
|
Chris PeBenito |
2a9837 |
|
|
Chris PeBenito |
445522 |
kernel_read_all_sysctls($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
kernel_getattr_debugfs($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
kernel_read_system_state($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
# Execute shells
|
|
Chris PeBenito |
7c2f5a |
corecmd_exec_shell($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
# By default, revert to the calling domain when a program is executed
|
|
Chris PeBenito |
296273 |
corecmd_bin_domtrans($1_userhelper_t, $3)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
# Inherit descriptors from the current session.
|
|
Chris PeBenito |
15722e |
domain_use_interactive_fds($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
# for when the user types "exec userhelper" at the command line
|
|
Chris PeBenito |
15722e |
domain_sigchld_interactive_fds($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
dev_read_urand($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
# Read /dev directories and any symbolic links.
|
|
Chris PeBenito |
7c2f5a |
dev_list_all_dev_nodes($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
files_list_var_lib($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
# Read the /etc/security/default_type file
|
|
Chris PeBenito |
7c2f5a |
files_read_etc_files($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
# Read /var.
|
|
Chris PeBenito |
7c2f5a |
files_read_var_files($1_userhelper_t)
|
|
Chris PeBenito |
9e04f5 |
files_read_var_symlinks($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
# for some PAM modules and for cwd
|
|
Chris PeBenito |
7c2f5a |
files_search_home($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
fs_search_auto_mountpoints($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
fs_read_nfs_files($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
fs_read_nfs_symlinks($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
# Allow $1_userhelper to obtain contexts to relabel TTYs
|
|
Chris PeBenito |
7c2f5a |
selinux_get_fs_mount($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
selinux_validate_context($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
selinux_compute_access_vector($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
selinux_compute_create_context($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
selinux_compute_relabel_context($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
selinux_compute_user_contexts($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
# Read the devpts root directory.
|
|
Chris PeBenito |
7c2f5a |
term_list_ptys($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
# Relabel terminals.
|
|
Chris PeBenito |
7c2f5a |
term_relabel_all_user_ttys($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
term_relabel_all_user_ptys($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
# Access terminals.
|
|
Chris PeBenito |
7c2f5a |
term_use_all_user_ttys($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
term_use_all_user_ptys($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
auth_domtrans_chk_passwd($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
auth_manage_pam_pid($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
auth_manage_var_auth($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
auth_search_pam_console_data($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
# Inherit descriptors from the current session.
|
|
Chris PeBenito |
1c1ac6 |
init_use_fds($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
# Write to utmp.
|
|
Chris PeBenito |
7c2f5a |
init_manage_utmp($1_userhelper_t)
|
|
Chris PeBenito |
296273 |
init_pid_filetrans_utmp($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
miscfiles_read_localization($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
seutil_read_config($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
seutil_read_default_contexts($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
# Allow $1_userhelper_t to transition to user domains.
|
|
Chris PeBenito |
7c2f5a |
userdom_bin_spec_domtrans_unpriv_users($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
userdom_entry_spec_domtrans_unpriv_users($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
ifdef(`distro_redhat',`
|
|
Chris PeBenito |
bb7170 |
optional_policy(`
|
|
Chris PeBenito |
7c2f5a |
# Allow transitioning to rpm_t, for up2date
|
|
Chris PeBenito |
7c2f5a |
rpm_domtrans($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
')
|
|
Chris PeBenito |
7c2f5a |
')
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
bb7170 |
optional_policy(`
|
|
Chris PeBenito |
296273 |
ethereal_domtrans($1_userhelper_t)
|
|
Chris PeBenito |
0834f9 |
')
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
bb7170 |
optional_policy(`
|
|
Chris PeBenito |
7c2f5a |
logging_send_syslog_msg($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
')
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
bb7170 |
optional_policy(`
|
|
Chris PeBenito |
7c2f5a |
nis_use_ypbind($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
')
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
bb7170 |
optional_policy(`
|
|
Chris PeBenito |
1815ba |
nscd_socket_use($1_userhelper_t)
|
|
Chris PeBenito |
7c2f5a |
')
|
|
Chris PeBenito |
296273 |
|
|
Chris PeBenito |
296273 |
optional_policy(`
|
|
Chris PeBenito |
296273 |
tunable_policy(`! secure_mode',`
|
|
Chris PeBenito |
296273 |
#if we are not in secure mode then we can transition to sysadm_t
|
|
Chris PeBenito |
296273 |
sysadm_bin_spec_domtrans($1_userhelper_t)
|
|
Chris PeBenito |
296273 |
sysadm_entry_spec_domtrans($1_userhelper_t)
|
|
Chris PeBenito |
296273 |
')
|
|
Chris PeBenito |
296273 |
')
|
|
Chris PeBenito |
7c2f5a |
')
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
7c2f5a |
########################################
|
|
Chris PeBenito |
7c2f5a |
## <summary>
|
|
Chris PeBenito |
2ce6b0 |
## Search the userhelper configuration directory.
|
|
Chris PeBenito |
7c2f5a |
## </summary>
|
|
Chris PeBenito |
7c2f5a |
## <param name="domain">
|
|
Chris PeBenito |
885b83 |
## <summary>
|
|
Chris PeBenito |
ff8f0a |
## Domain allowed access.
|
|
Chris PeBenito |
885b83 |
## </summary>
|
|
Chris PeBenito |
2ce6b0 |
## </param>
|
|
Chris PeBenito |
2ce6b0 |
#
|
|
Chris PeBenito |
2ce6b0 |
interface(`userhelper_search_config',`
|
|
Chris PeBenito |
2ce6b0 |
gen_require(`
|
|
Chris PeBenito |
2ce6b0 |
type userhelper_conf_t;
|
|
Chris PeBenito |
2ce6b0 |
')
|
|
Chris PeBenito |
2ce6b0 |
|
|
Chris PeBenito |
2ce6b0 |
allow $1 userhelper_conf_t:dir search_dir_perms;
|
|
Chris PeBenito |
2ce6b0 |
')
|
|
Chris PeBenito |
2ce6b0 |
|
|
Chris PeBenito |
2ce6b0 |
########################################
|
|
Chris PeBenito |
2ce6b0 |
## <summary>
|
|
Chris PeBenito |
2ce6b0 |
## Do not audit attempts to search
|
|
Chris PeBenito |
2ce6b0 |
## the userhelper configuration directory.
|
|
Chris PeBenito |
2ce6b0 |
## </summary>
|
|
Chris PeBenito |
2ce6b0 |
## <param name="domain">
|
|
Chris PeBenito |
885b83 |
## <summary>
|
|
Chris PeBenito |
ff8f0a |
## Domain to not audit.
|
|
Chris PeBenito |
885b83 |
## </summary>
|
|
Chris PeBenito |
7c2f5a |
## </param>
|
|
Chris PeBenito |
7c2f5a |
#
|
|
Chris PeBenito |
7c2f5a |
interface(`userhelper_dontaudit_search_config',`
|
|
Chris PeBenito |
7c2f5a |
gen_require(`
|
|
Chris PeBenito |
7c2f5a |
type userhelper_conf_t;
|
|
Chris PeBenito |
7c2f5a |
')
|
|
Chris PeBenito |
7c2f5a |
|
|
Chris PeBenito |
2ce6b0 |
dontaudit $1 userhelper_conf_t:dir search_dir_perms;
|
|
Chris PeBenito |
7c2f5a |
')
|
|
Chris PeBenito |
0834f9 |
|
|
Chris PeBenito |
0834f9 |
########################################
|
|
Chris PeBenito |
0834f9 |
## <summary>
|
|
Chris PeBenito |
0834f9 |
## Allow domain to use userhelper file descriptor.
|
|
Chris PeBenito |
0834f9 |
## </summary>
|
|
Chris PeBenito |
0834f9 |
## <param name="domain">
|
|
Chris PeBenito |
0834f9 |
## <summary>
|
|
Chris PeBenito |
ff8f0a |
## Domain allowed access.
|
|
Chris PeBenito |
0834f9 |
## </summary>
|
|
Chris PeBenito |
0834f9 |
## </param>
|
|
Chris PeBenito |
0834f9 |
#
|
|
Chris PeBenito |
296273 |
interface(`userhelper_use_fd',`
|
|
Chris PeBenito |
0834f9 |
gen_require(`
|
|
Chris PeBenito |
296273 |
attribute userhelper_type;
|
|
Chris PeBenito |
0834f9 |
')
|
|
Chris PeBenito |
0834f9 |
|
|
Chris PeBenito |
296273 |
allow $1 userhelper_type:fd use;
|
|
Chris PeBenito |
0834f9 |
')
|
|
Chris PeBenito |
c0868a |
|
|
Chris PeBenito |
0834f9 |
########################################
|
|
Chris PeBenito |
0834f9 |
## <summary>
|
|
Chris PeBenito |
0834f9 |
## Allow domain to send sigchld to userhelper.
|
|
Chris PeBenito |
0834f9 |
## </summary>
|
|
Chris PeBenito |
0834f9 |
## <param name="domain">
|
|
Chris PeBenito |
0834f9 |
## <summary>
|
|
Chris PeBenito |
ff8f0a |
## Domain allowed access.
|
|
Chris PeBenito |
0834f9 |
## </summary>
|
|
Chris PeBenito |
0834f9 |
## </param>
|
|
Chris PeBenito |
0834f9 |
#
|
|
Chris PeBenito |
296273 |
interface(`userhelper_sigchld',`
|
|
Chris PeBenito |
0834f9 |
gen_require(`
|
|
Chris PeBenito |
296273 |
attribute userhelper_type;
|
|
Chris PeBenito |
0834f9 |
')
|
|
Chris PeBenito |
0834f9 |
|
|
Chris PeBenito |
296273 |
allow $1 userhelper_type:process sigchld;
|
|
Chris PeBenito |
0834f9 |
')
|
|
Chris PeBenito |
6b19be |
|
|
Chris PeBenito |
6b19be |
########################################
|
|
Chris PeBenito |
6b19be |
## <summary>
|
|
Chris PeBenito |
6b19be |
## Execute the userhelper program in the caller domain.
|
|
Chris PeBenito |
6b19be |
## </summary>
|
|
Chris PeBenito |
6b19be |
## <param name="domain">
|
|
Chris PeBenito |
6b19be |
## <summary>
|
|
Chris PeBenito |
6b19be |
## The type of the process performing this action.
|
|
Chris PeBenito |
6b19be |
## </summary>
|
|
Chris PeBenito |
6b19be |
## </param>
|
|
Chris PeBenito |
6b19be |
#
|
|
Chris PeBenito |
6b19be |
interface(`userhelper_exec',`
|
|
Chris PeBenito |
6b19be |
gen_require(`
|
|
Chris PeBenito |
6b19be |
type userhelper_exec_t;
|
|
Chris PeBenito |
6b19be |
')
|
|
Chris PeBenito |
6b19be |
|
|
Chris PeBenito |
0bfccd |
can_exec($1, userhelper_exec_t)
|
|
Chris PeBenito |
6b19be |
')
|