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