|
Chris PeBenito |
0fbfa5 |
#DESC Userhelper - SELinux utility to run a shell with a new role
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
# Authors: Dan Walsh (Red Hat)
|
|
Chris PeBenito |
0fbfa5 |
# Maintained by Dan Walsh <dwalsh@redhat.com>
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
# userhelper_domain(domain_prefix)
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
# Define a derived domain for the userhelper/userhelper program when executed by
|
|
Chris PeBenito |
0fbfa5 |
# a user domain.
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
# The type declaration for the executable type for this program is
|
|
Chris PeBenito |
0fbfa5 |
# provided separately in domains/program/userhelper.te.
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
define(`userhelper_domain',`
|
|
Chris PeBenito |
0fbfa5 |
type $1_userhelper_t, domain, userhelperdomain, privlog, privrole, privowner, auth_chkpwd, privfd, privuser, nscd_client_domain;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
in_user_role($1_userhelper_t)
|
|
Chris PeBenito |
0fbfa5 |
role sysadm_r types $1_userhelper_t;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
ifelse($1, sysadm, `
|
|
Chris PeBenito |
0fbfa5 |
typealias sysadm_userhelper_t alias userhelper_t;
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans(initrc_t, userhelper_exec_t, sysadm_userhelper_t)
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
general_domain_access($1_userhelper_t);
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
uses_shlib($1_userhelper_t)
|
|
Chris PeBenito |
0fbfa5 |
read_locale($1_userhelper_t)
|
|
Chris PeBenito |
0fbfa5 |
read_sysctl($1_userhelper_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# for when the user types "exec userhelper" at the command line
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t privfd:process sigchld;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans($1_t, userhelper_exec_t, $1_userhelper_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Inherit descriptors from the current session.
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t { init_t privfd }:fd use;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
can_exec($1_userhelper_t, { bin_t sbin_t userhelper_exec_t })
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Execute shells
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t { sbin_t bin_t }:dir r_dir_perms;
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t { sbin_t bin_t }:lnk_file read;
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t shell_exec_t:file r_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# By default, revert to the calling domain when a program is executed.
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans($1_userhelper_t, { bin_t sbin_t }, $1_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Allow $1_userhelper_t to transition to user domains.
|
|
Chris PeBenito |
0fbfa5 |
domain_trans($1_userhelper_t, { bin_t sbin_t exec_type }, unpriv_userdomain)
|
|
Chris PeBenito |
0fbfa5 |
if (!secure_mode) {
|
|
Chris PeBenito |
0fbfa5 |
# if we are not in secure mode then we can transition to sysadm_t
|
|
Chris PeBenito |
0fbfa5 |
domain_trans($1_userhelper_t, { bin_t sbin_t exec_type }, sysadm_t)
|
|
Chris PeBenito |
0fbfa5 |
}
|
|
Chris PeBenito |
0fbfa5 |
can_setexec($1_userhelper_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`distro_redhat', `
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`rpm.te', `
|
|
Chris PeBenito |
0fbfa5 |
# Allow transitioning to rpm_t, for up2date
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t rpm_t:process { transition siginh rlimitinh noatsecure };
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Use capabilities.
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t self:capability { setuid setgid net_bind_service dac_override chown sys_tty_config };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Write to utmp.
|
|
Chris PeBenito |
0fbfa5 |
file_type_auto_trans($1_userhelper_t, var_run_t, initrc_var_run_t, file)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Read the devpts root directory.
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t devpts_t:dir r_dir_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Read the /etc/security/default_type file
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t etc_t:file r_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Read /var.
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t var_t:dir r_dir_perms;
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t var_t:notdevfile_class_set r_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Read /dev directories and any symbolic links.
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t device_t:dir r_dir_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Relabel terminals.
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t { ttyfile ptyfile }:chr_file { relabelfrom relabelto };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# Access terminals.
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t { ttyfile ptyfile devtty_t }:chr_file rw_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`gnome-pty-helper.te', `allow $1_userhelper_t gphdomain:fd use;')
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
# Allow $1_userhelper to obtain contexts to relabel TTYs
|
|
Chris PeBenito |
0fbfa5 |
#
|
|
Chris PeBenito |
0fbfa5 |
can_getsecurity($1_userhelper_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t fs_t:filesystem getattr;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# for some PAM modules and for cwd
|
|
Chris PeBenito |
0fbfa5 |
dontaudit $1_userhelper_t { home_root_t home_type }:dir search;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t proc_t:dir search;
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t proc_t:file { getattr read };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
# for when the network connection is killed
|
|
Chris PeBenito |
0fbfa5 |
dontaudit unpriv_userdomain $1_userhelper_t:process signal;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t userhelper_conf_t:file rw_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t userhelper_conf_t:dir rw_dir_perms;
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`pam.te', `
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t pam_var_run_t:dir create_dir_perms;
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t pam_var_run_t:file create_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t urandom_device_t:chr_file { getattr read };
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t autofs_t:dir search;
|
|
Chris PeBenito |
0fbfa5 |
role system_r types $1_userhelper_t;
|
|
Chris PeBenito |
0fbfa5 |
r_dir_file($1_userhelper_t, nfs_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`xdm.te', `
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t xdm_t:fd use;
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t xdm_t:fifo_file rw_file_perms;
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t xdm_var_run_t:dir search;
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
r_dir_file($1_userhelper_t, selinux_config_t)
|
|
Chris PeBenito |
0fbfa5 |
r_dir_file($1_userhelper_t, default_context_t)
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`xauth.te', `
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans($1_userhelper_t, xauth_exec_t, $1_xauth_t)
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t $1_xauth_home_t:file { getattr read };
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`pamconsole.te', `
|
|
Chris PeBenito |
0fbfa5 |
allow $1_userhelper_t pam_var_console_t:dir { search };
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
ifdef(`mozilla.te', `
|
|
Chris PeBenito |
0fbfa5 |
domain_auto_trans($1_mozilla_t, userhelper_exec_t, $1_userhelper_t)
|
|
Chris PeBenito |
0fbfa5 |
')
|
|
Chris PeBenito |
0fbfa5 |
|
|
Chris PeBenito |
0fbfa5 |
')dnl end userhelper macro
|