Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Macros for uml domains.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Author:  Russell Coker <russell@coker.com.au>
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# uml_domain(domain_prefix)
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Define a derived domain for the uml program when executed
Chris PeBenito 0fbfa5
# by a user domain.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# The type declaration for the executable type for this program is
Chris PeBenito 0fbfa5
# provided separately in domains/program/uml.te. 
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
undefine(`uml_domain')
Chris PeBenito 0fbfa5
ifdef(`uml.te', `
Chris PeBenito 0fbfa5
define(`uml_domain',`
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Derived domain based on the calling user domain and the program.
Chris PeBenito 0fbfa5
type $1_uml_t, domain;
Chris PeBenito 0fbfa5
type $1_uml_exec_t, file_type, sysadmfile, $1_file_type;
Chris PeBenito 0fbfa5
type $1_uml_ro_t, file_type, sysadmfile, $1_file_type;
Chris PeBenito 0fbfa5
type $1_uml_rw_t, file_type, sysadmfile, $1_file_type;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for X
Chris PeBenito 0fbfa5
ifdef(`startx.te', `
Chris PeBenito 0fbfa5
ifelse($1, sysadm, `', `
Chris PeBenito 0fbfa5
ifdef(`xdm.te', `
Chris PeBenito 0fbfa5
allow $1_uml_t xdm_xserver_tmp_t:dir search;
Chris PeBenito 0fbfa5
')dnl end if xdm.te
Chris PeBenito 0fbfa5
allow $1_uml_t $1_xserver_tmp_t:sock_file write;
Chris PeBenito 0fbfa5
can_unix_connect($1_uml_t, $1_xserver_t)
Chris PeBenito 0fbfa5
')dnl end ifelse sysadm
Chris PeBenito 0fbfa5
')dnl end ifdef startx
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_t { $1_uml_ro_t $1_uml_rw_t }:{ file sock_file fifo_file } { relabelfrom relabelto create_file_perms };
Chris PeBenito 0fbfa5
allow $1_t $1_uml_exec_t:file { relabelfrom relabelto create_file_perms };
Chris PeBenito 0fbfa5
allow $1_t { $1_uml_ro_t $1_uml_rw_t }:lnk_file { relabelfrom relabelto create_lnk_perms };
Chris PeBenito 0fbfa5
allow $1_t { $1_uml_ro_t $1_uml_rw_t $1_uml_exec_t }:dir { relabelfrom relabelto create_dir_perms };
Chris PeBenito 0fbfa5
r_dir_file($1_t, uml_ro_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Transition from the user domain to this domain.
Chris PeBenito 0fbfa5
domain_auto_trans($1_t, { uml_exec_t $1_uml_exec_t }, $1_uml_t)
Chris PeBenito 0fbfa5
can_exec($1_uml_t, { uml_exec_t $1_uml_exec_t })
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# The user role is authorized for this domain.
Chris PeBenito 0fbfa5
role $1_r types $1_uml_t;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Inherit and use descriptors from gnome-pty-helper.
Chris PeBenito 0fbfa5
ifdef(`gnome-pty-helper.te', `allow $1_uml_t $1_gph_t:fd use;')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Inherit and use descriptors from newrole.
Chris PeBenito 0fbfa5
ifdef(`newrole.te', `allow $1_uml_t newrole_t:fd use;')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# allow ps, ptrace, signal
Chris PeBenito 0fbfa5
can_ps($1_t, $1_uml_t)
Chris PeBenito 0fbfa5
can_ptrace($1_t, $1_uml_t)
Chris PeBenito 0fbfa5
allow $1_t $1_uml_t:process signal_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# allow the UML thing to happen
Chris PeBenito 0fbfa5
allow $1_uml_t self:process { fork signal_perms ptrace };
Chris PeBenito 0fbfa5
can_create_pty($1_uml)
Chris PeBenito 0fbfa5
allow $1_uml_t root_t:dir search;
Chris PeBenito 0fbfa5
tmp_domain($1_uml)
Chris PeBenito 0fbfa5
can_exec($1_uml_t, $1_uml_tmp_t)
Chris PeBenito 0fbfa5
tmpfs_domain($1_uml)
Chris PeBenito 0fbfa5
can_exec($1_uml_t, $1_uml_tmpfs_t)
Chris PeBenito 0fbfa5
create_dir_file($1_t, $1_uml_tmp_t)
Chris PeBenito 0fbfa5
allow $1_t $1_uml_tmp_t:sock_file create_file_perms;
Chris PeBenito 0fbfa5
allow $1_uml_t self:fifo_file rw_file_perms;
Chris PeBenito 0fbfa5
allow $1_uml_t fs_t:filesystem getattr;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_uml_t tun_tap_device_t:chr_file { read write ioctl };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifdef(`uml_net.te', `
Chris PeBenito 0fbfa5
# for uml_net
Chris PeBenito 0fbfa5
domain_auto_trans($1_uml_t, uml_net_exec_t, uml_net_t)
Chris PeBenito 0fbfa5
allow uml_net_t $1_uml_t:unix_stream_socket { read write };
Chris PeBenito 0fbfa5
allow uml_net_t $1_uml_t:unix_dgram_socket { read write };
Chris PeBenito 0fbfa5
dontaudit uml_net_t privfd:fd use;
Chris PeBenito 0fbfa5
allow uml_net_t $1_uml_devpts_t:chr_file { read write };
Chris PeBenito 0fbfa5
dontaudit uml_net_t $1_uml_rw_t:dir { getattr search };
Chris PeBenito 0fbfa5
')dnl end ifdef uml_net.te
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for mconsole
Chris PeBenito 0fbfa5
allow { $1_t $1_uml_t } $1_uml_t:unix_dgram_socket sendto;
Chris PeBenito 0fbfa5
allow $1_uml_t $1_t:unix_dgram_socket sendto;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Use the network.
Chris PeBenito 0fbfa5
can_network($1_uml_t)
Chris PeBenito 0fbfa5
can_ypbind($1_uml_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for xterm
Chris PeBenito 0fbfa5
uses_shlib($1_uml_t)
Chris PeBenito 0fbfa5
can_exec($1_uml_t, { bin_t sbin_t lib_t })
Chris PeBenito 0fbfa5
allow $1_uml_t { bin_t sbin_t }:dir search;
Chris PeBenito 0fbfa5
allow $1_uml_t etc_t:file { getattr read };
Chris PeBenito 0fbfa5
dontaudit $1_uml_t etc_runtime_t:file read;
Chris PeBenito 0fbfa5
can_tcp_connect($1_uml_t, sshd_t)
Chris PeBenito 0fbfa5
ifdef(`xauth.te', `
Chris PeBenito 0fbfa5
allow $1_uml_t $1_xauth_home_t:file { getattr read };
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
allow $1_uml_t var_run_t:dir search;
Chris PeBenito 0fbfa5
allow $1_uml_t initrc_var_run_t:file { getattr read };
Chris PeBenito 0fbfa5
dontaudit $1_uml_t initrc_var_run_t:file { write lock };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_uml_t device_t:dir search;
Chris PeBenito 0fbfa5
allow $1_uml_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 0fbfa5
allow $1_uml_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 0fbfa5
allow $1_uml_t privfd:fd use;
Chris PeBenito 0fbfa5
allow $1_uml_t proc_t:dir search;
Chris PeBenito 0fbfa5
allow $1_uml_t proc_t:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for SKAS - need something better
Chris PeBenito 0fbfa5
allow $1_uml_t proc_t:file write;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Write to the user domain tty.
Chris PeBenito 0fbfa5
access_terminal($1_uml_t, $1)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# access config files
Chris PeBenito 0fbfa5
allow $1_uml_t home_root_t:dir search;
Chris PeBenito 0fbfa5
file_type_auto_trans($1_uml_t, $1_home_dir_t, $1_uml_rw_t)
Chris PeBenito 0fbfa5
r_dir_file($1_uml_t, { $1_uml_ro_t uml_ro_t })
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# putting uml data under /var is usual...
Chris PeBenito 0fbfa5
allow $1_uml_t var_t:dir search;
Chris PeBenito 0fbfa5
')dnl end macro definition
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
define(`uml_domain',`')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
')