Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Macros for X server domains.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# xserver_domain(domain_prefix)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define a derived domain for the X server when executed
Chris PeBenito ab58ad
# by a user domain (e.g. via startx).  See the xdm_t domain
Chris PeBenito ab58ad
# in domains/program/xdm.te if using an X Display Manager.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# The type declarations for the executable type for this program 
Chris PeBenito ab58ad
# and the log type are provided separately in domains/program/xserver.te. 
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# FIXME!  The X server requires far too many privileges.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
undefine(`xserver_domain')
Chris PeBenito ab58ad
ifdef(`xserver.te', `
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`xserver_domain',`
Chris PeBenito ab58ad
# Derived domain based on the calling user domain and the program.
Chris PeBenito ab58ad
ifdef(`distro_redhat', `
Chris PeBenito ab58ad
type $1_xserver_t, domain, privlog, privmem, privmodule, nscd_client_domain;
Chris PeBenito ab58ad
allow $1_xserver_t sysctl_modprobe_t:file { getattr read };
Chris PeBenito ab58ad
ifdef(`rpm.te', `
Chris PeBenito ab58ad
allow $1_xserver_t rpm_t:shm { unix_read unix_write read write associate getattr };
Chris PeBenito ab58ad
allow $1_xserver_t rpm_tmpfs_t:file { read write };
Chris PeBenito ab58ad
allow $1_xserver_t rpm_t:fd use;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
type $1_xserver_t, domain, privlog, privmem, nscd_client_domain;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for SSP
Chris PeBenito ab58ad
allow $1_xserver_t urandom_device_t:chr_file { getattr read ioctl };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Transition from the user domain to this domain.
Chris PeBenito ab58ad
ifelse($1, xdm, `
Chris PeBenito ab58ad
ifdef(`xdm.te', `
Chris PeBenito ab58ad
domain_auto_trans(xdm_t, xserver_exec_t, xdm_xserver_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
domain_auto_trans($1_t, xserver_exec_t, $1_xserver_t)
Chris PeBenito ab58ad
')dnl end ifelse xdm
Chris PeBenito ab58ad
can_exec($1_xserver_t, xserver_exec_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
uses_shlib($1_xserver_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_xserver_t texrel_shlib_t:file execmod;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_network($1_xserver_t)
Chris PeBenito ab58ad
allow $1_xserver_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
can_ypbind($1_xserver_t)
Chris PeBenito ab58ad
allow $1_xserver_t xserver_port_t:tcp_socket name_bind;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for access within the domain
Chris PeBenito ab58ad
general_domain_access($1_xserver_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_xserver_t self:process execmem;
Chris PeBenito ab58ad
# Until the X module loader is fixed.
Chris PeBenito ab58ad
allow $1_xserver_t self:process execheap;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_xserver_t etc_runtime_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifelse($1, xdm, `
Chris PeBenito ab58ad
# The system role is authorised for the xdm and initrc domains
Chris PeBenito ab58ad
role system_r types xdm_xserver_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow xdm_xserver_t init_t:fd use;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
dontaudit xdm_xserver_t home_dir_type:dir { read search };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read all global and per user fonts
Chris PeBenito ab58ad
read_fonts($1_xserver_t, sysadm)
Chris PeBenito ab58ad
read_fonts($1_xserver_t, staff)
Chris PeBenito ab58ad
read_fonts($1_xserver_t, user)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
# The user role is authorized for this domain.
Chris PeBenito ab58ad
role $1_r types $1_xserver_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_xserver_t getty_t:fd use;
Chris PeBenito ab58ad
allow $1_xserver_t local_login_t:fd use;
Chris PeBenito ab58ad
allow $1_xserver_t $1_tty_device_t:chr_file { setattr rw_file_perms };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_xserver_t $1_tmpfs_t:file rw_file_perms;
Chris PeBenito ab58ad
allow $1_t $1_xserver_tmpfs_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_unix_connect($1_t, $1_xserver_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read fonts
Chris PeBenito ab58ad
read_fonts($1_xserver_t, $1)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access the home directory.
Chris PeBenito ab58ad
allow $1_xserver_t home_root_t:dir search;
Chris PeBenito ab58ad
allow $1_xserver_t $1_home_dir_t:dir { getattr search };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`xauth.te', `
Chris PeBenito ab58ad
domain_auto_trans($1_xserver_t, xauth_exec_t, $1_xauth_t)
Chris PeBenito ab58ad
allow $1_xserver_t $1_xauth_home_t:file { getattr read };
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
allow $1_xserver_t $1_home_t:file { getattr read };
Chris PeBenito ab58ad
')dnl end ifdef xauth
Chris PeBenito ab58ad
ifdef(`userhelper.te', `
Chris PeBenito ab58ad
allow $1_xserver_t userhelper_conf_t:dir search;
Chris PeBenito ab58ad
')dnl end ifdef userhelper
Chris PeBenito ab58ad
')dnl end ifelse xdm
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_xserver_t self:process setsched;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_xserver_t fs_t:filesystem getattr;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Xorg wants to check if kernel is tainted
Chris PeBenito ab58ad
read_sysctl($1_xserver_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use capabilities.
Chris PeBenito ab58ad
# allow setuid/setgid for the wrapper program to change UID
Chris PeBenito ab58ad
# sys_rawio is for iopl access - should not be needed for frame-buffer
Chris PeBenito ab58ad
# sys_admin, locking shared mem?  chowning IPC message queues or semaphores?
Chris PeBenito ab58ad
# admin of APM bios?
Chris PeBenito ab58ad
# sys_nice is so that the X server can set a negative nice value
Chris PeBenito ab58ad
allow $1_xserver_t self:capability { dac_override fsetid setgid setuid ipc_owner sys_rawio sys_admin sys_nice sys_tty_config mknod net_bind_service };
Chris PeBenito ab58ad
allow $1_xserver_t nfs_t:dir { getattr search };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# memory_device_t access is needed if not using the frame buffer
Chris PeBenito ab58ad
#dontaudit $1_xserver_t memory_device_t:chr_file read;
Chris PeBenito ab58ad
allow $1_xserver_t memory_device_t:chr_file { rw_file_perms execute };
Chris PeBenito ab58ad
# net_bind_service is needed if you want your X server to allow TCP connections
Chris PeBenito ab58ad
# from other hosts, EG an XDM serving a network of X terms
Chris PeBenito ab58ad
# if you want good security you do not want this
Chris PeBenito ab58ad
# not sure why some people want chown, fsetid, and sys_tty_config.
Chris PeBenito ab58ad
#allow $1_xserver_t self:capability { net_bind_service chown fsetid sys_tty_config };
Chris PeBenito ab58ad
dontaudit $1_xserver_t self:capability chown;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for nscd
Chris PeBenito ab58ad
dontaudit $1_xserver_t var_run_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_xserver_t mtrr_device_t:file rw_file_perms;
Chris PeBenito ab58ad
allow $1_xserver_t apm_bios_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow $1_xserver_t framebuf_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow $1_xserver_t device_t:lnk_file { getattr read };
Chris PeBenito ab58ad
allow $1_xserver_t devtty_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow $1_xserver_t zero_device_t:chr_file { read write execute };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Type for temporary files.
Chris PeBenito ab58ad
tmp_domain($1_xserver, `', `{ dir file sock_file }')
Chris PeBenito ab58ad
file_type_auto_trans($1_xserver_t, xdm_xserver_tmp_t, $1_xserver_tmp_t, sock_file)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifelse($1, xdm, `
Chris PeBenito ab58ad
ifdef(`xdm.te', `
Chris PeBenito ab58ad
allow xdm_t xdm_xserver_tmp_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow xdm_t xdm_xserver_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
allow xdm_t $1_xserver_t:process signal;
Chris PeBenito ab58ad
can_unix_connect(xdm_t, xdm_xserver_t)
Chris PeBenito ab58ad
allow xdm_t xdm_xserver_tmp_t:sock_file rw_file_perms;
Chris PeBenito ab58ad
allow xdm_t xdm_xserver_tmp_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow xdm_xserver_t xdm_t:process signal;
Chris PeBenito ab58ad
allow xdm_xserver_t xdm_t:shm rw_shm_perms;
Chris PeBenito ab58ad
allow xdm_t xdm_xserver_t:shm rw_shm_perms;
Chris PeBenito ab58ad
dontaudit xdm_xserver_t sysadm_t:shm { unix_read unix_write };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
allow $1_t xdm_xserver_tmp_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_t xdm_xserver_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
allow $1_t $1_xserver_t:process signal;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow the user domain to connect to the X server.
Chris PeBenito ab58ad
can_unix_connect($1_t, $1_xserver_t)
Chris PeBenito ab58ad
allow $1_t $1_xserver_tmp_t:sock_file rw_file_perms;
Chris PeBenito ab58ad
allow $1_t $1_xserver_tmp_t:dir r_dir_perms;
Chris PeBenito ab58ad
ifdef(`xdm.te', `
Chris PeBenito ab58ad
allow $1_t xdm_tmp_t:sock_file unlink;
Chris PeBenito ab58ad
allow $1_xserver_t xdm_var_run_t:dir search;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Signal the user domain.
Chris PeBenito ab58ad
allow $1_xserver_t $1_t:process signal;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Communicate via System V shared memory.
Chris PeBenito ab58ad
allow $1_xserver_t $1_t:shm rw_shm_perms;
Chris PeBenito ab58ad
allow $1_t $1_xserver_t:shm rw_shm_perms;
Chris PeBenito ab58ad
allow $1_xserver_t initrc_t:shm rw_shm_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
')dnl end ifelse xdm
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Create files in /var/log with the xserver_log_t type.
Chris PeBenito ab58ad
allow $1_xserver_t var_t:dir search;
Chris PeBenito ab58ad
file_type_auto_trans($1_xserver_t, var_log_t, xserver_log_t, file)
Chris PeBenito ab58ad
allow $1_xserver_t xserver_log_t:dir r_dir_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access AGP device.
Chris PeBenito ab58ad
allow $1_xserver_t agp_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for other device nodes such as the NVidia binary-only driver
Chris PeBenito ab58ad
allow $1_xserver_t xserver_misc_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access /proc/mtrr
Chris PeBenito ab58ad
allow $1_xserver_t proc_t:file rw_file_perms;
Chris PeBenito ab58ad
allow $1_xserver_t proc_t:lnk_file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access /proc/sys/dev
Chris PeBenito ab58ad
allow $1_xserver_t sysctl_dev_t:dir search;
Chris PeBenito ab58ad
allow $1_xserver_t sysctl_dev_t:file { getattr read };
Chris PeBenito ab58ad
# Access /proc/bus/pci
Chris PeBenito ab58ad
allow $1_xserver_t proc_t:dir r_dir_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Create and access /dev/dri devices.
Chris PeBenito ab58ad
allow $1_xserver_t device_t:dir { create setattr };
Chris PeBenito ab58ad
file_type_auto_trans($1_xserver_t, device_t, dri_device_t, chr_file)
Chris PeBenito ab58ad
# brought on by rhgb
Chris PeBenito ab58ad
allow $1_xserver_t mnt_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_xserver_t tty_device_t:chr_file { setattr rw_file_perms };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Run helper programs in $1_xserver_t.
Chris PeBenito ab58ad
allow $1_xserver_t { bin_t sbin_t }:dir search;
Chris PeBenito ab58ad
allow $1_xserver_t etc_t:{ file lnk_file } { getattr read };
Chris PeBenito ab58ad
allow $1_xserver_t bin_t:lnk_file read;
Chris PeBenito ab58ad
can_exec($1_xserver_t, { bin_t shell_exec_t })
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Connect to xfs.
Chris PeBenito ab58ad
ifdef(`xfs.te', `
Chris PeBenito ab58ad
can_unix_connect($1_xserver_t, xfs_t)
Chris PeBenito ab58ad
allow $1_xserver_t xfs_tmp_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_xserver_t xfs_tmp_t:sock_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Bind to the X server socket in /tmp.
Chris PeBenito ab58ad
allow $1_xserver_t $1_xserver_tmp_t:unix_stream_socket name_bind;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
read_locale($1_xserver_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Type for tmpfs/shm files.
Chris PeBenito ab58ad
tmpfs_domain($1_xserver)
Chris PeBenito ab58ad
ifelse($1, xdm, `
Chris PeBenito ab58ad
ifdef(`xdm.te', `
Chris PeBenito ab58ad
allow xdm_xserver_t xdm_t:shm rw_shm_perms;
Chris PeBenito ab58ad
allow xdm_xserver_t xdm_tmpfs_t:file rw_file_perms;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
allow $1_xserver_t $1_t:shm rw_shm_perms;
Chris PeBenito ab58ad
rw_dir_file($1_xserver_t, $1_tmpfs_t)
Chris PeBenito ab58ad
')dnl end ifelse xdm
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
r_dir_file($1_xserver_t,sysfs_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use the mouse.
Chris PeBenito ab58ad
allow $1_xserver_t mouse_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
# Allow xserver to read events - the synaptics touchpad
Chris PeBenito ab58ad
# driver reads raw events
Chris PeBenito ab58ad
allow $1_xserver_t event_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
ifdef(`pamconsole.te', `
Chris PeBenito ab58ad
allow $1_xserver_t pam_var_console_t:dir search;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
dontaudit $1_xserver_t selinux_config_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_xserver_t var_lib_t:dir search;
Chris PeBenito ab58ad
rw_dir_create_file($1_xserver_t, xkb_var_lib_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
')dnl end macro definition
Chris PeBenito ab58ad
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`xserver_domain',`')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad