Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Macros for mount
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Author:  Brian May <bam@snoopy.apana.org.au>
Chris PeBenito 0fbfa5
# Extended by Russell Coker <russell@coker.com.au>
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# mount_domain(domain_prefix,dst_domain_prefix)
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Define a derived domain for the mount program for anyone.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
define(`mount_domain', `
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Rules for the $2_t domain, used by the $1_t domain.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# $2_t is the domain for the mount process.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# This macro will not be included by all users and it may be included twice if
Chris PeBenito 0fbfa5
# called from other macros, so we need protection for this do not call this
Chris PeBenito 0fbfa5
# macro if $2_def is defined
Chris PeBenito 0fbfa5
define(`$2_def', `')
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
type $2_t, domain, privlog $3, nscd_client_domain;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $2_t sysfs_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
uses_shlib($2_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
role $1_r types $2_t;
Chris PeBenito 0fbfa5
# when mount is run by $1 goto $2_t domain
Chris PeBenito 0fbfa5
domain_auto_trans($1_t, mount_exec_t, $2_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $2_t proc_t:dir search;
Chris PeBenito 0fbfa5
allow $2_t proc_t:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Allow mounting of cdrom by user
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
allow $2_t device_type:blk_file getattr;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
tmp_domain($2)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Use capabilities.
Chris PeBenito 0fbfa5
allow $2_t self:capability { net_bind_service sys_rawio sys_admin dac_override chown };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $2_t self:unix_stream_socket create_socket_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Create and modify /etc/mtab.
Chris PeBenito 0fbfa5
file_type_auto_trans($2_t, etc_t, etc_runtime_t, file)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $2_t etc_t:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
read_locale($2_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $2_t home_root_t:dir search;
Chris PeBenito 0fbfa5
allow $2_t $1_home_dir_t:dir search;
Chris PeBenito 0fbfa5
allow $2_t noexattrfile:filesystem { mount unmount };
Chris PeBenito 0fbfa5
allow $2_t fs_t:filesystem getattr;
Chris PeBenito 0fbfa5
allow $2_t removable_t:filesystem { mount unmount };
Chris PeBenito 0fbfa5
allow $2_t mnt_t:dir { mounton search };
Chris PeBenito 0fbfa5
allow $2_t sbin_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Access the terminal.
Chris PeBenito 0fbfa5
access_terminal($2_t, $1)
Chris PeBenito 0fbfa5
ifdef(`gnome-pty-helper.te', `allow $2_t $1_gph_t:fd use;')
Chris PeBenito 0fbfa5
allow $2_t var_t:dir search;
Chris PeBenito 0fbfa5
allow $2_t var_run_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifdef(`distro_redhat',`
Chris PeBenito 0fbfa5
ifdef(`pamconsole.te',`
Chris PeBenito 0fbfa5
r_dir_file($2_t,pam_var_console_t)
Chris PeBenito 0fbfa5
# mount config by default sets fscontext=removable_t
Chris PeBenito 0fbfa5
allow $2_t dosfs_t:filesystem relabelfrom;
Chris PeBenito 0fbfa5
') dnl end pamconsole.te
Chris PeBenito 0fbfa5
') dnl end distro_redhat
Chris PeBenito 0fbfa5
') dnl end mount_domain
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# mount_loopback_privs(domain_prefix,dst_domain_prefix)
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Add loopback mounting privileges to a particular derived
Chris PeBenito 0fbfa5
# mount domain. 
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
define(`mount_loopback_privs',`
Chris PeBenito 0fbfa5
type $1_$2_source_t, file_type, sysadmfile, $1_file_type;
Chris PeBenito 0fbfa5
allow $1_t $1_$2_source_t:file create_file_perms;
Chris PeBenito 0fbfa5
allow $1_t $1_$2_source_t:file { relabelto relabelfrom };
Chris PeBenito 0fbfa5
allow $2_t $1_$2_source_t:file rw_file_perms;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5