Chris PeBenito 31b7c0
#DESC Fsadm - Disk and file system administration
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser  
Chris PeBenito 31b7c0
# X-Debian-Packages: util-linux e2fsprogs xfsprogs reiserfsprogs parted raidtools2 mount
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the fsadm_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# fsadm_t is the domain for disk and file system
Chris PeBenito 31b7c0
# administration.
Chris PeBenito 31b7c0
# fsadm_exec_t is the type of the corresponding programs.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
type fsadm_t, domain, privlog, fs_domain, mlsfileread, mlsfilewrite;
Chris PeBenito 31b7c0
role system_r types fsadm_t;
Chris PeBenito 31b7c0
role sysadm_r types fsadm_t;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
general_domain_access(fsadm_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for swapon
Chris PeBenito 31b7c0
r_dir_file(fsadm_t, sysfs_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read system information files in /proc.
Chris PeBenito 31b7c0
r_dir_file(fsadm_t, proc_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read system variables in /proc/sys
Chris PeBenito 31b7c0
read_sysctl(fsadm_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for /dev/shm
Chris PeBenito 31b7c0
allow fsadm_t tmpfs_t:dir { getattr search };
Chris PeBenito 31b7c0
allow fsadm_t tmpfs_t:file { read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
base_file_read_access(fsadm_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read /etc.
Chris PeBenito 31b7c0
r_dir_file(fsadm_t, etc_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read module-related files.
Chris PeBenito 31b7c0
allow fsadm_t modules_conf_t:{ file lnk_file } r_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read /dev directories and any symbolic links.
Chris PeBenito 31b7c0
allow fsadm_t device_t:dir r_dir_perms;
Chris PeBenito 31b7c0
allow fsadm_t device_t:lnk_file r_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
uses_shlib(fsadm_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
type fsadm_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 31b7c0
domain_auto_trans(initrc_t, fsadm_exec_t, fsadm_t)
Chris PeBenito 31b7c0
ifdef(`targeted_policy', `', `
Chris PeBenito 31b7c0
domain_auto_trans(sysadm_t, fsadm_exec_t, fsadm_t)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
tmp_domain(fsadm)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# remount file system to apply changes
Chris PeBenito 31b7c0
allow fsadm_t fs_t:filesystem remount;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow fsadm_t fs_t:filesystem getattr;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# mkreiserfs needs this
Chris PeBenito 31b7c0
allow fsadm_t proc_t:filesystem getattr;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# mkreiserfs and other programs need this for UUID
Chris PeBenito 31b7c0
allow fsadm_t { urandom_device_t random_device_t }:chr_file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Use capabilities.  ipc_lock is for losetup
Chris PeBenito 31b7c0
allow fsadm_t self:capability { ipc_lock sys_rawio sys_admin sys_tty_config dac_override dac_read_search };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Write to /etc/mtab.
Chris PeBenito 31b7c0
file_type_auto_trans(fsadm_t, etc_t, etc_runtime_t, file)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Inherit and use descriptors from init.
Chris PeBenito 31b7c0
allow fsadm_t init_t:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Run other fs admin programs in the fsadm_t domain.
Chris PeBenito 31b7c0
can_exec(fsadm_t, fsadm_exec_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access disk devices.
Chris PeBenito 31b7c0
allow fsadm_t fixed_disk_device_t:devfile_class_set rw_file_perms;
Chris PeBenito 31b7c0
allow fsadm_t removable_device_t:devfile_class_set rw_file_perms;
Chris PeBenito 31b7c0
allow fsadm_t scsi_generic_device_t:chr_file r_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access lost+found.
Chris PeBenito 31b7c0
allow fsadm_t lost_found_t:dir create_dir_perms;
Chris PeBenito 31b7c0
allow fsadm_t lost_found_t:{ file sock_file fifo_file } create_file_perms;
Chris PeBenito 31b7c0
allow fsadm_t lost_found_t:lnk_file create_lnk_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow fsadm_t file_t:dir { search read getattr rmdir create };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Recreate /mnt/cdrom. 
Chris PeBenito 31b7c0
allow fsadm_t mnt_t:dir { search read getattr rmdir create };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Recreate /dev/cdrom.
Chris PeBenito 31b7c0
allow fsadm_t device_t:dir rw_dir_perms;
Chris PeBenito 31b7c0
allow fsadm_t device_t:lnk_file { unlink create };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Enable swapping to devices and files
Chris PeBenito 31b7c0
allow fsadm_t swapfile_t:file { getattr swapon };
Chris PeBenito 31b7c0
allow fsadm_t fixed_disk_device_t:blk_file { getattr swapon };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow console log change (updfstab)
Chris PeBenito 31b7c0
allow fsadm_t kernel_t:system syslog_console;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access terminals.
Chris PeBenito 31b7c0
can_access_pty(fsadm_t, initrc)
Chris PeBenito 31b7c0
allow fsadm_t { admin_tty_type devtty_t console_device_t }:chr_file rw_file_perms;
Chris PeBenito 31b7c0
ifdef(`gnome-pty-helper.te', `allow fsadm_t sysadm_gph_t:fd use;')
Chris PeBenito 31b7c0
allow fsadm_t privfd:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
read_locale(fsadm_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for smartctl cron jobs
Chris PeBenito 31b7c0
system_crond_entry(fsadm_exec_t, fsadm_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access to /initrd devices
Chris PeBenito 31b7c0
allow fsadm_t { file_t unlabeled_t }:dir rw_dir_perms;
Chris PeBenito 31b7c0
allow fsadm_t { file_t unlabeled_t }:blk_file rw_file_perms;
Chris PeBenito 31b7c0
allow fsadm_t usbfs_t:dir { getattr search };
Chris PeBenito 31b7c0
allow fsadm_t ramfs_t:fifo_file rw_file_perms;
Chris PeBenito 31b7c0
allow fsadm_t device_type:chr_file getattr;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for tune2fs
Chris PeBenito 31b7c0
allow fsadm_t file_type:dir { getattr search };