Chris PeBenito ab58ad
# Macro for vmware
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Based on work contributed by Mark Westerman (mark.westerman@westcam.com), 
Chris PeBenito ab58ad
# modifications by NAI Labs.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Turned into a macro by Thomas Bleher <ThomasBleher@gmx.de>
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# vmware_domain(domain_prefix)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define a derived domain for the vmware program when executed by
Chris PeBenito ab58ad
# a user domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# The type declaration for the executable type for this program is
Chris PeBenito ab58ad
# provided separately in domains/program/vmware.te. This file also
Chris PeBenito ab58ad
# implements a separate domain vmware_t.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
 
Chris PeBenito ab58ad
define(`vmware_domain', `
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Domain for the user applications to run in.
Chris PeBenito ab58ad
type $1_vmware_t, domain, privmem;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
role $1_r types $1_vmware_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# The user file type is for files created when the user is running VMWare
Chris PeBenito ab58ad
type $1_vmware_file_t, $1_file_type, file_type, sysadmfile;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# The user file type for the VMWare configuration files
Chris PeBenito ab58ad
type $1_vmware_conf_t, $1_file_type, file_type, sysadmfile;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#############################################################
Chris PeBenito ab58ad
# User rules for running VMWare
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Transition to VMWare user domain
Chris PeBenito ab58ad
domain_auto_trans($1_t, vmware_user_exec_t, $1_vmware_t)
Chris PeBenito ab58ad
can_exec($1_vmware_t, vmware_user_exec_t)
Chris PeBenito ab58ad
uses_shlib($1_vmware_t)
Chris PeBenito ab58ad
var_run_domain($1_vmware)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
general_domain_access($1_vmware_t);
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Capabilities needed by VMWare for the user execution. This seems a 
Chris PeBenito ab58ad
# bit too much, so be careful.
Chris PeBenito ab58ad
allow $1_vmware_t self:capability { dac_override setgid sys_nice sys_resource setuid sys_admin sys_rawio };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access to ttys
Chris PeBenito ab58ad
allow $1_vmware_t vmware_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow $1_vmware_t $1_tty_device_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow $1_vmware_t privfd:fd use;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access /proc
Chris PeBenito ab58ad
r_dir_file($1_vmware_t, proc_t)
Chris PeBenito ab58ad
allow $1_vmware_t proc_net_t:dir search;
Chris PeBenito ab58ad
allow $1_vmware_t proc_net_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access to some files in the user home directory
Chris PeBenito ab58ad
r_dir_file($1_vmware_t, $1_home_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access to runtime files for user
Chris PeBenito ab58ad
allow $1_vmware_t $1_vmware_file_t:dir rw_dir_perms;
Chris PeBenito ab58ad
allow $1_vmware_t $1_vmware_file_t:file create_file_perms;
Chris PeBenito ab58ad
allow $1_vmware_t $1_vmware_conf_t:file create_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow read access to /etc/vmware and /usr/lib/vmware configuration files
Chris PeBenito ab58ad
r_dir_file($1_vmware_t, vmware_sys_conf_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow $1_vmware_t to read/write files in the tmp dir
Chris PeBenito ab58ad
tmp_domain($1_vmware)
Chris PeBenito ab58ad
allow $1_vmware_t $1_vmware_tmp_t:file execute;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow read access to several paths
Chris PeBenito ab58ad
r_dir_file($1_vmware_t, etc_t)
Chris PeBenito ab58ad
allow $1_vmware_t etc_runtime_t:file r_file_perms;
Chris PeBenito ab58ad
allow $1_vmware_t device_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_vmware_t var_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_vmware_t tmpfs_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow vmware to write to ~/.vmware
Chris PeBenito ab58ad
rw_dir_create_file($1_vmware_t, $1_vmware_file_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# This is bad; VMWare needs execute permission to the .cfg file for the
Chris PeBenito ab58ad
# configuration to run.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow $1_vmware_t $1_vmware_conf_t:file execute;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access X11 config files
Chris PeBenito ab58ad
allow $1_vmware_t lib_t:file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access components of VMWare in /usr/lib/vmware/bin by default
Chris PeBenito ab58ad
allow $1_vmware_t bin_t:dir r_dir_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow access to lp port (Need to create an lp device domain )
Chris PeBenito ab58ad
allow $1_vmware_t device_t:chr_file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow access to /dev/mem
Chris PeBenito ab58ad
allow $1_vmware_t memory_device_t:chr_file { read write };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow access to mouse
Chris PeBenito ab58ad
allow $1_vmware_t mouse_device_t:chr_file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow access the sound device 
Chris PeBenito ab58ad
allow $1_vmware_t sound_device_t:chr_file { ioctl write };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow removable media and devices
Chris PeBenito ab58ad
allow $1_vmware_t removable_device_t:blk_file r_file_perms;
Chris PeBenito ab58ad
allow $1_vmware_t device_t:lnk_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow access to the real time clock device
Chris PeBenito ab58ad
allow $1_vmware_t clock_device_t:chr_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow to attach to Xserver, and Xserver to attach back
Chris PeBenito ab58ad
ifdef(`gnome-pty-helper.te', `
Chris PeBenito ab58ad
allow $1_vmware_t $1_gph_t:fd use;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
ifdef(`startx.te', `
Chris PeBenito ab58ad
allow $1_vmware_t $1_xserver_tmp_t:sock_file { unlink write };
Chris PeBenito ab58ad
allow $1_vmware_t $1_xserver_tmp_t:dir search;
Chris PeBenito ab58ad
allow $1_vmware_t $1_xserver_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
allow $1_xserver_t $1_vmware_t:shm r_shm_perms;
Chris PeBenito ab58ad
allow $1_xserver_t $1_vmware_t:fd use;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow filesystem read access
Chris PeBenito ab58ad
allow $1_vmware_t fs_t:filesystem getattr;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad