Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Macros for mplayer
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Author: Ivan Gyurdiev <ivg2@cornell.edu>
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# mplayer_domains(user) declares domains for mplayer, gmplayer,
Chris PeBenito ab58ad
# and mencoder
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#####################################################
Chris PeBenito ab58ad
#    mplayer_common(role_prefix, mplayer_domain)    #
Chris PeBenito ab58ad
#####################################################
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`mplayer_common',`
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read global config
Chris PeBenito ab58ad
r_dir_file($1_$2_t, mplayer_etc_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow the user domain to signal/ps.
Chris PeBenito ab58ad
can_ps($1_t, $1_$2_t)
Chris PeBenito ab58ad
allow $1_t $1_$2_t:process signal_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read data in /usr/share (fonts, icons..)
Chris PeBenito ab58ad
r_dir_file($1_$2_t, usr_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read /proc files and directories
Chris PeBenito ab58ad
# Necessary for /proc/meminfo, /proc/cpuinfo, etc..
Chris PeBenito ab58ad
allow $1_$2_t proc_t:dir search;
Chris PeBenito ab58ad
allow $1_$2_t proc_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Sysctl on kernel version 
Chris PeBenito ab58ad
read_sysctl($1_$2_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow ps, shared libs, locale, terminal access
Chris PeBenito ab58ad
can_ps($1_t, $1_$2_t)
Chris PeBenito ab58ad
uses_shlib($1_$2_t)
Chris PeBenito ab58ad
read_locale($1_$2_t)
Chris PeBenito ab58ad
access_terminal($1_$2_t, $1)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Required for win32 binary loader 
Chris PeBenito ab58ad
allow $1_$2_t zero_device_t:chr_file { read write execute };
Chris PeBenito ab58ad
if (allow_execmem) {
Chris PeBenito ab58ad
allow $1_$2_t self:process execmem;
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
Chris PeBenito ab58ad
if (allow_execmod) {
Chris PeBenito ab58ad
allow $1_$2_t zero_device_t:chr_file execmod;
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
allow $1_$2_t texrel_shlib_t:file execmod;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access to DVD/CD/V4L
Chris PeBenito ab58ad
allow $1_$2_t device_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_$2_t device_t:lnk_file { getattr read };
Chris PeBenito ab58ad
allow $1_$2_t removable_device_t:blk_file { getattr read };
Chris PeBenito ab58ad
allow $1_$2_t v4l_device_t:chr_file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Legacy domain issues
Chris PeBenito ab58ad
if (allow_mplayer_execstack) {
Chris PeBenito ab58ad
legacy_domain($1_$2)
Chris PeBenito ab58ad
allow $1_$2_t lib_t:file execute;
Chris PeBenito ab58ad
allow $1_$2_t locale_t:file execute;
Chris PeBenito ab58ad
allow $1_$2_t sound_device_t:chr_file execute;
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
###################################
Chris PeBenito ab58ad
#  mplayer_domain(role_prefix)    #
Chris PeBenito ab58ad
###################################
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`mplayer_domain',`
Chris PeBenito ab58ad
Chris PeBenito ab58ad
type $1_mplayer_t, domain, nscd_client_domain;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Type transition
Chris PeBenito ab58ad
domain_auto_trans($1_t, mplayer_exec_t, $1_mplayer_t)
Chris PeBenito ab58ad
role $1_r types $1_mplayer_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Home access, X access
Chris PeBenito ab58ad
home_domain($1, mplayer)
Chris PeBenito ab58ad
x_client_domain($1_mplayer, $1)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Mplayer common stuff
Chris PeBenito ab58ad
mplayer_common($1, mplayer)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Fork 
Chris PeBenito ab58ad
allow $1_mplayer_t self:process { fork signal_perms getsched };
Chris PeBenito ab58ad
allow $1_mplayer_t self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Audio, alsa.conf
Chris PeBenito ab58ad
allow $1_mplayer_t sound_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow $1_mplayer_t etc_t:file { getattr read };
Chris PeBenito ab58ad
r_dir_file($1_mplayer_t, alsa_etc_rw_t);
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# RTC clock 
Chris PeBenito ab58ad
allow $1_mplayer_t clock_device_t:chr_file { ioctl read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Legacy domain issues
Chris PeBenito ab58ad
if (allow_mplayer_execstack) {
Chris PeBenito ab58ad
allow $1_mplayer_t $1_mplayer_tmpfs_t:file execute;
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#======gmplayer gui==========#
Chris PeBenito ab58ad
# File dialogs
Chris PeBenito ab58ad
dontaudit_getattr($1_mplayer_t)
Chris PeBenito ab58ad
dontaudit_read_dir($1_mplayer_t)
Chris PeBenito ab58ad
dontaudit_search_dir($1_mplayer_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Unfortunately the ancient file dialog starts in /
Chris PeBenito ab58ad
allow $1_mplayer_t home_root_t:dir read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read /etc/mtab
Chris PeBenito ab58ad
allow $1_mplayer_t etc_runtime_t:file { read getattr };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Run bash/sed (??) 
Chris PeBenito ab58ad
allow $1_mplayer_t bin_t:dir search;
Chris PeBenito ab58ad
allow $1_mplayer_t bin_t:lnk_file read;
Chris PeBenito ab58ad
can_exec($1_mplayer_t, bin_t)
Chris PeBenito ab58ad
can_exec($1_mplayer_t, shell_exec_t)
Chris PeBenito ab58ad
#============================#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read songs
Chris PeBenito ab58ad
read_content($1_mplayer_t, $1)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
') dnl end mplayer_domain
Chris PeBenito ab58ad
Chris PeBenito ab58ad
###################################
Chris PeBenito ab58ad
#  mencoder_domain(role_prefix)   #
Chris PeBenito ab58ad
###################################
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`mencoder_domain',`
Chris PeBenito ab58ad
Chris PeBenito ab58ad
type $1_mencoder_t, domain;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Type transition
Chris PeBenito ab58ad
domain_auto_trans($1_t, mencoder_exec_t, $1_mencoder_t)
Chris PeBenito ab58ad
role $1_r types $1_mencoder_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access mplayer home domain
Chris PeBenito ab58ad
home_domain_access($1_mencoder_t, $1, mplayer)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Mplayer common stuff
Chris PeBenito ab58ad
mplayer_common($1, mencoder)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read content to encode
Chris PeBenito ab58ad
read_content($1_mencoder_t, $1)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Save encoded files
Chris PeBenito ab58ad
write_trusted($1_mencoder_t, $1)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
') dnl end mencoder_domain
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#############################
Chris PeBenito ab58ad
#  mplayer_domains(role)    #
Chris PeBenito ab58ad
#############################
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`mplayer_domains', `
Chris PeBenito ab58ad
mplayer_domain($1)
Chris PeBenito ab58ad
mencoder_domain($1)
Chris PeBenito ab58ad
') dnl end mplayer_domains
Chris PeBenito ab58ad