Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Macros for giFT
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Author: Ivan Gyurdiev <ivg2@cornell.edu>
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# gift_domains(domain_prefix)
Chris PeBenito 0fbfa5
# declares a domain for giftui and giftd
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#########################
Chris PeBenito 0fbfa5
#  gift_domain(user)    #
Chris PeBenito 0fbfa5
#########################
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
define(`gift_domain', `
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Connect to X
Chris PeBenito 0fbfa5
x_client_domain($1, gift, `')	
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Transition
Chris PeBenito 0fbfa5
domain_auto_trans($1_t, gift_exec_t, $1_gift_t)
Chris PeBenito 0fbfa5
can_exec($1_gift_t, gift_exec_t)
Chris PeBenito 0fbfa5
role $1_r types $1_gift_t;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Self permissions
Chris PeBenito 0fbfa5
allow $1_gift_t self:process getsched;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Home files
Chris PeBenito 0fbfa5
home_domain($1, gift)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Fonts, icons
Chris PeBenito 0fbfa5
r_dir_file($1_gift_t, usr_t)
Chris PeBenito 0fbfa5
r_dir_file($1_gift_t, fonts_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Launch gift daemon
Chris PeBenito 0fbfa5
allow $1_gift_t self:process fork;
Chris PeBenito 0fbfa5
domain_auto_trans($1_gift_t, giftd_exec_t, $1_giftd_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Connect to gift daemon
Chris PeBenito 0fbfa5
can_network($1_gift_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Read /proc/meminfo
Chris PeBenito 0fbfa5
allow $1_gift_t proc_t:dir search;
Chris PeBenito 0fbfa5
allow $1_gift_t proc_t:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Tmp/ORBit
Chris PeBenito 0fbfa5
tmp_domain($1_gift)
Chris PeBenito 0fbfa5
file_type_auto_trans($1_gift_t, $1_tmp_t, $1_gift_tmp_t)
Chris PeBenito 0fbfa5
can_unix_connect($1_t, $1_gift_t)
Chris PeBenito 0fbfa5
can_unix_connect($1_gift_t, $1_t)
Chris PeBenito 0fbfa5
allow $1_t $1_gift_tmp_t:sock_file write;
Chris PeBenito 0fbfa5
allow $1_gift_t $1_tmp_t:file { getattr read write lock };
Chris PeBenito 0fbfa5
allow $1_gift_t $1_tmp_t:sock_file { read write };
Chris PeBenito 0fbfa5
dontaudit $1_gift_t $1_tmp_t:dir setattr;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Access random device
Chris PeBenito 0fbfa5
allow $1_gift_t urandom_device_t:chr_file { read getattr ioctl };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# giftui looks in .icons, .themes, .fonts-cache.
Chris PeBenito 0fbfa5
dontaudit $1_gift_t $1_home_t:dir { getattr read search };
Chris PeBenito 0fbfa5
dontaudit $1_gift_t $1_home_t:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
') dnl gift_domain
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
##########################
Chris PeBenito 0fbfa5
#  giftd_domain(user)    #
Chris PeBenito 0fbfa5
##########################
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
define(`giftd_domain', `
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
type $1_giftd_t, domain;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Transition from user type
Chris PeBenito 0fbfa5
domain_auto_trans($1_t, giftd_exec_t, $1_giftd_t)
Chris PeBenito 0fbfa5
role $1_r types $1_giftd_t;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Self permissions, allow fork
Chris PeBenito 0fbfa5
allow $1_giftd_t self:process { fork signal sigchld setsched };
Chris PeBenito 0fbfa5
allow $1_giftd_t self:unix_stream_socket create_socket_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
read_sysctl($1_giftd_t)
Chris PeBenito 0fbfa5
read_locale($1_giftd_t)
Chris PeBenito 0fbfa5
uses_shlib($1_giftd_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Access home domain
Chris PeBenito 0fbfa5
home_domain_access($1_giftd_t, $1, gift)
Chris PeBenito 0fbfa5
	
Chris PeBenito 0fbfa5
# Allow networking
Chris PeBenito 0fbfa5
allow $1_giftd_t port_t:tcp_socket name_bind;
Chris PeBenito 0fbfa5
allow $1_giftd_t port_t:udp_socket name_bind;
Chris PeBenito 0fbfa5
can_network_server($1_giftd_t)
Chris PeBenito 0fbfa5
can_network_client($1_giftd_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# FIXME: ???
Chris PeBenito 0fbfa5
dontaudit $1_giftd_t self:udp_socket listen;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Plugins
Chris PeBenito 0fbfa5
r_dir_file($1_giftd_t, usr_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Connect to xdm
Chris PeBenito 0fbfa5
ifdef(`xdm.te', `
Chris PeBenito 0fbfa5
allow $1_giftd_t xdm_t:fd use;
Chris PeBenito 0fbfa5
allow $1_giftd_t xdm_t:fifo_file write;
Chris PeBenito 0fbfa5
') 
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
') dnl giftd_domain
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
##########################
Chris PeBenito 0fbfa5
#  gift_domains(user)    #
Chris PeBenito 0fbfa5
##########################
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
define(`gift_domains', `
Chris PeBenito 0fbfa5
gift_domain($1)
Chris PeBenito 0fbfa5
giftd_domain($1)
Chris PeBenito 0fbfa5
') dnl gift_domains