Chris PeBenito 0fbfa5
#DESC SE Linux User Manager (seuser)
Chris PeBenito 0fbfa5
#DEPENDS checkpolicy.te load_policy.te
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Authors:   don.patterson@tresys.com, mayerf@tresys.com
Chris PeBenito 0fbfa5
# Additions: wsalamon@tislabs.com, dac@tresys.com
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#################################
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Rules for the seuser_t domain.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# seuser_t is the domain of the seuser application when it is executed.
Chris PeBenito 0fbfa5
# seuser_conf_t is the type of the seuser configuration file.
Chris PeBenito 0fbfa5
# seuser_exec_t is the type of the seuser executable.
Chris PeBenito 0fbfa5
# seuser_tmp_t is the type of the temporary file(s) created by seuser.
Chris PeBenito 0fbfa5
# 
Chris PeBenito 0fbfa5
##############################################
Chris PeBenito 0fbfa5
# Define types, and typical rules including
Chris PeBenito 0fbfa5
# access to execute and transition
Chris PeBenito 0fbfa5
##############################################
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Defined seuser types
Chris PeBenito 0fbfa5
type seuser_t, domain, privhome  ;
Chris PeBenito 0fbfa5
type seuser_conf_t, file_type, sysadmfile ;
Chris PeBenito 0fbfa5
type seuser_exec_t, file_type, sysadmfile, exec_type ;
Chris PeBenito 0fbfa5
tmp_domain(seuser)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Authorize roles
Chris PeBenito 0fbfa5
role sysadm_r types seuser_t ;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Allow sysadm_t to run with privilege
Chris PeBenito 0fbfa5
domain_auto_trans(sysadm_t, seuser_exec_t, seuser_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Grant the new domain permissions to many common operations
Chris PeBenito 0fbfa5
# FIX: Should be more resticted than this.
Chris PeBenito 0fbfa5
#every_domain(seuser_t)
Chris PeBenito 0fbfa5
allow seuser_t self:process { fork sigchld };
Chris PeBenito 0fbfa5
allow seuser_t self:fifo_file read;
Chris PeBenito 0fbfa5
allow seuser_t self:unix_stream_socket {create connect};
Chris PeBenito 0fbfa5
allow seuser_t self:dir search;
Chris PeBenito 0fbfa5
allow seuser_t self:file { read getattr };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow seuser_t etc_t:dir search;
Chris PeBenito 0fbfa5
allow seuser_t etc_t:{lnk_file file} { read getattr};
Chris PeBenito 0fbfa5
read_locale(seuser_t)
Chris PeBenito 0fbfa5
allow seuser_t { var_run_t var_t}:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
uses_shlib(seuser_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow seuser_t devtty_t:chr_file {read write };
Chris PeBenito 0fbfa5
allow seuser_t proc_t:dir search;
Chris PeBenito 0fbfa5
allow seuser_t proc_t:{lnk_file file} { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow seuser_t root_t:dir search;
Chris PeBenito 0fbfa5
allow seuser_t staff_home_dir_t:dir search;
Chris PeBenito 0fbfa5
allow seuser_t home_root_t:dir { getattr search };
Chris PeBenito 0fbfa5
allow seuser_t staff_home_dir_t:dir getattr;
Chris PeBenito 0fbfa5
allow seuser_t default_t:file {read getattr};
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow seuser_t bin_t:dir { getattr search read} ;
Chris PeBenito 0fbfa5
allow seuser_t bin_t:lnk_file { read getattr };
Chris PeBenito 0fbfa5
allow seuser_t sbin_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Inherit and use descriptors from login.
Chris PeBenito 0fbfa5
allow seuser_t privfd:fd use;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
###############################################
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Use capabilities to self
Chris PeBenito 0fbfa5
allow seuser_t self:capability { dac_override setuid setgid } ;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Grant the seuser domain ability to change passwords for a user.
Chris PeBenito 0fbfa5
allow seuser_t self:passwd { passwd chfn chsh } ;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Read permissions for seuser.conf file
Chris PeBenito 0fbfa5
allow seuser_t seuser_conf_t:file r_file_perms ;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
###################################################################
Chris PeBenito 0fbfa5
# Policy section: Define the ability to change and load policies
Chris PeBenito 0fbfa5
###################################################################
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# seuser_t domain needs to transition to the checkpolicy and loadpolicy 
Chris PeBenito 0fbfa5
# domains in order to install and load new policies.
Chris PeBenito 0fbfa5
domain_auto_trans(seuser_t, checkpolicy_exec_t, checkpolicy_t)
Chris PeBenito 0fbfa5
domain_auto_trans(seuser_t, load_policy_exec_t, load_policy_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# allow load_policy and checkpolicy domains access to seuser_tmp_t
Chris PeBenito 0fbfa5
# files in order for their stdout/stderr able to be put into
Chris PeBenito 0fbfa5
# seuser's tmp files.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Since both these domains carefully try to limit where the
Chris PeBenito 0fbfa5
# assoicated program can read from, we won't use the standard
Chris PeBenito 0fbfa5
# rw_file_perm macro, but instead only grant the minimum needed
Chris PeBenito 0fbfa5
# to redirect output, write and getattr.
Chris PeBenito 0fbfa5
allow checkpolicy_t seuser_tmp_t:file { getattr write } ;
Chris PeBenito 0fbfa5
allow load_policy_t seuser_tmp_t:file { getattr write } ;
Chris PeBenito 0fbfa5
allow useradd_t seuser_tmp_t:file { getattr write } ;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# FIX:  Temporarily allow seuser_t permissions for executing programs with a 
Chris PeBenito 0fbfa5
# bint_t type without changing domains. We have to give seuser_t the following 
Chris PeBenito 0fbfa5
# access because we use the policy make process to build new plicy.conf files. 
Chris PeBenito 0fbfa5
# At some point, a new policy management infrastructure should remove the ability 
Chris PeBenito 0fbfa5
# to modify policy source files with arbitrary progams
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
can_exec(seuser_t, bin_t)
Chris PeBenito 0fbfa5
can_exec(seuser_t, shell_exec_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Read/write permission to the login context files in /etc/security
Chris PeBenito 0fbfa5
allow seuser_t login_contexts:file create_file_perms ;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Read/write permission to the policy source and its' directory
Chris PeBenito 0fbfa5
allow seuser_t policy_src_t:dir create_dir_perms ;
Chris PeBenito 0fbfa5
allow seuser_t policy_src_t:file create_file_perms ;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Allow search and stat for policy_config_t
Chris PeBenito 0fbfa5
allow seuser_t policy_config_t:dir { search getattr } ;
Chris PeBenito 0fbfa5
allow seuser_t policy_config_t:file stat_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#ifdef(`xserver.te', `
Chris PeBenito 0fbfa5
############################################################
Chris PeBenito 0fbfa5
# Xserver section - To support our GUI interface, 
Chris PeBenito 0fbfa5
############################################################
Chris PeBenito 0fbfa5
# Permission to create files in /tmp/.X11-Unix
Chris PeBenito 0fbfa5
#allow seuser_t sysadm_xserver_tmp_t:dir search ;
Chris PeBenito 0fbfa5
#allow seuser_t sysadm_xserver_tmp_t:sock_file write ;
Chris PeBenito 0fbfa5
#allow seuser_t user_xserver_tmp_t:dir search ;
Chris PeBenito 0fbfa5
#allow seuser_t user_xserver_tmp_t:sock_file write ;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Permission to establish a Unix stream connection to X server
Chris PeBenito 0fbfa5
#can_unix_connect(seuser_t, user_xserver_t)
Chris PeBenito 0fbfa5
#can_unix_connect(seuser_t, sysadm_xserver_t)
Chris PeBenito 0fbfa5
#')
Chris PeBenito 0fbfa5
ifdef(`xdm.te', `
Chris PeBenito 0fbfa5
can_unix_connect(seuser_t, xdm_xserver_t)
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# seuser_t domain needs execute access to the library files so that it can run.
Chris PeBenito 0fbfa5
can_exec(seuser_t, lib_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Access ttys
Chris PeBenito 0fbfa5
allow seuser_t sysadm_tty_device_t:chr_file rw_file_perms ;
Chris PeBenito 0fbfa5
allow seuser_t sysadm_devpts_t:chr_file rw_file_perms ;
Chris PeBenito 0fbfa5