Blob Blame History Raw

policy_module(mount,1.0)

########################################
#
# Declarations
#

type mount_t;
type mount_exec_t;
init_system_domain(mount_t,mount_exec_t)
role system_r types mount_t;

type mount_tmp_t;
files_tmp_file(mount_tmp_t)

########################################
#
# mount local policy
#

allow mount_t self:capability { ipc_lock sys_rawio sys_admin dac_override chown };

allow mount_t mount_tmp_t:file create_file_perms;
allow mount_t mount_tmp_t:dir create_dir_perms;
files_create_tmp_files(mount_t,mount_tmp_t,{ file dir })

kernel_read_system_state(mount_t)
kernel_dontaudit_use_fd(mount_t)

corenet_dontaudit_tcp_bind_all_reserved_ports(mount_t)
corenet_dontaudit_udp_bind_all_reserved_ports(mount_t)

dev_getattr_all_blk_files(mount_t)
dev_list_all_dev_nodes(mount_t)

storage_raw_read_fixed_disk(mount_t)
storage_raw_write_fixed_disk(mount_t)
storage_raw_read_removable_device(mount_t)
storage_raw_write_removable_device(mount_t)

fs_getattr_xattr_fs(mount_t)
fs_mount_all_fs(mount_t)
fs_unmount_all_fs(mount_t)
fs_remount_all_fs(mount_t)
fs_relabelfrom_xattr_fs(mount_t)
fs_search_auto_mountpoints(mount_t)

term_use_console(mount_t)

# required for mount.smbfs
corecmd_exec_sbin(mount_t)
corecmd_exec_bin(mount_t)

domain_use_wide_inherit_fd(mount_t)

files_search_all_dirs(mount_t)
files_read_etc_files(mount_t)
files_manage_etc_runtime_files(mount_t)
files_mounton_all_mountpoints(mount_t)
files_unmount_rootfs(mount_t)
# These rules need to be generalized.  Only admin, initrc should have it:
files_relabelto_all_file_type_fs(mount_t)
files_mount_all_file_type_fs(mount_t)
files_mount_all_file_type_fs(mount_t)
# for when /etc/mtab loses its type
# cjp: this seems wrong, the type should probably be etc
files_read_isid_type_file(mount_t)

init_use_fd(mount_t)
init_use_script_pty(mount_t)

libs_use_ld_so(mount_t)
libs_use_shared_libs(mount_t)

logging_send_syslog_msg(mount_t)

miscfiles_read_localization(mount_t)

userdom_use_all_user_fd(mount_t)

ifdef(`distro_redhat',`
	fs_use_tmpfs_chr_dev(mount_t)
	allow mount_t tmpfs_t:dir mounton;

	optional_policy(`authlogin.te',`
		auth_read_pam_console_data(mount_t)
		# mount config by default sets fscontext=removable_t
		fs_relabelfrom_dos_fs(mount_t)
	')
')

optional_policy(`portmap.te', `
	# for nfs
	#allow portmap_t mount_t:udp_socket { sendto recvfrom };
	#allow mount_t portmap_t:udp_socket { sendto recvfrom };
	#allow mount_t rpc_pipefs_t:dir search;
	corenet_tcp_sendrecv_all_if(mount_t)
	corenet_raw_sendrecv_all_if(mount_t)
	corenet_udp_sendrecv_all_if(mount_t)
	corenet_tcp_sendrecv_all_nodes(mount_t)
	corenet_raw_sendrecv_all_nodes(mount_t)
	corenet_udp_sendrecv_all_nodes(mount_t)
	corenet_tcp_sendrecv_all_ports(mount_t)
	corenet_udp_sendrecv_all_ports(mount_t)
	corenet_tcp_bind_all_nodes(mount_t)
	corenet_udp_bind_all_nodes(mount_t)
	corenet_tcp_bind_generic_port(mount_t)
	corenet_udp_bind_generic_port(mount_t)
	corenet_tcp_bind_reserved_port(mount_t)
	corenet_udp_bind_reserved_port(mount_t)

	optional_policy(`nis.te',`
		nis_use_ypbind(mount_t)
	')
')

# for kernel package installation
optional_policy(`rpm.te', `
	rpm_rw_pipe(mount_t)
')

ifdef(`TODO',`
# this goes to the nfs/rpc module
files_mountpoint(var_lib_nfs_t)

# TODO: Need to examine this further. Not sure how to handle this
#type sysadm_mount_source_t, file_type, sysadmfile, $1_file_type;
#allow sysadm_t sysadm_mount_source_t:file create_file_perms;
#allow sysadm_t sysadm_mount_source_t:file { relabelto relabelfrom };
#allow mount_t sysadm_mount_source_t:file rw_file_perms;

# for when /etc/mtab loses its type
allow mount_t file_t:file unlink;

ifdef(`gnome-pty-helper.te', `
allow mount_t sysadm_gph_t:fd use;
')

optional_policy(`rhgb.te', `
rhgb_domain(mount_t)
')

') dnl endif TODO