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