Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Macros for Dbus
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Author: Colin Walters <walters@redhat.com>
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# dbusd_domain(domain_prefix)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define a derived domain for the DBus daemon.
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`dbusd_domain', `
Chris PeBenito ab58ad
ifelse(`system', `$1',`
Chris PeBenito ab58ad
daemon_domain(system_dbusd, `, userspace_objmgr, nscd_client_domain', `nosysadm')
Chris PeBenito ab58ad
# For backwards compatibility
Chris PeBenito ab58ad
typealias system_dbusd_t alias dbusd_t;
Chris PeBenito ab58ad
type etc_dbusd_t, file_type, sysadmfile;
Chris PeBenito ab58ad
',`
Chris PeBenito ab58ad
type $1_dbusd_t, domain, privlog, nscd_client_domain, userspace_objmgr;
Chris PeBenito ab58ad
role $1_r types $1_dbusd_t;
Chris PeBenito ab58ad
domain_auto_trans($1_t, system_dbusd_exec_t, $1_dbusd_t)
Chris PeBenito ab58ad
read_locale($1_dbusd_t)
Chris PeBenito ab58ad
allow $1_t $1_dbusd_t:process { sigkill signal };
Chris PeBenito ab58ad
allow $1_dbusd_t self:process { sigkill signal };
Chris PeBenito ab58ad
dontaudit $1_dbusd_t var_t:dir { getattr search };
Chris PeBenito ab58ad
')dnl end ifelse system
Chris PeBenito ab58ad
Chris PeBenito ab58ad
base_file_read_access($1_dbusd_t)
Chris PeBenito ab58ad
uses_shlib($1_dbusd_t)
Chris PeBenito ab58ad
allow $1_dbusd_t etc_t:file { getattr read };
Chris PeBenito ab58ad
r_dir_file($1_dbusd_t, etc_dbusd_t)
Chris PeBenito ab58ad
tmp_domain($1_dbusd) 
Chris PeBenito ab58ad
allow $1_dbusd_t self:process fork;
Chris PeBenito ab58ad
can_pipe_xdm($1_dbusd_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_dbusd_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito ab58ad
allow $1_dbusd_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_dbusd_t urandom_device_t:chr_file { getattr read };
Chris PeBenito ab58ad
allow $1_dbusd_t self:file { getattr read write };
Chris PeBenito ab58ad
allow $1_dbusd_t proc_t:file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_getsecurity($1_dbusd_t)
Chris PeBenito ab58ad
r_dir_file($1_dbusd_t, default_context_t)
Chris PeBenito ab58ad
allow system_dbusd_t self:netlink_selinux_socket create_socket_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`pamconsole.te', `
Chris PeBenito ab58ad
r_dir_file($1_dbusd_t, pam_var_console_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_dbusd_t self:dbus { send_msg acquire_svc };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
')dnl end dbusd_domain definition
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# dbusd_client(dbus_type, domain_prefix)
Chris PeBenito ab58ad
# Example: dbusd_client_domain(system, user)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define a new derived domain for connecting to dbus_type
Chris PeBenito ab58ad
# from domain_prefix_t. 
Chris PeBenito ab58ad
undefine(`dbusd_client')
Chris PeBenito ab58ad
define(`dbusd_client',`
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`dbusd.te',`
Chris PeBenito ab58ad
# Derived type used for connection
Chris PeBenito ab58ad
type $2_dbusd_$1_t;
Chris PeBenito ab58ad
type_change $2_t $1_dbusd_t:dbus $2_dbusd_$1_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# SE-DBus specific permissions
Chris PeBenito ab58ad
allow $2_dbusd_$1_t { $1_dbusd_t self }:dbus send_msg;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# For connecting to the bus
Chris PeBenito ab58ad
allow $2_t $1_dbusd_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifelse(`system', `$1', `
Chris PeBenito ab58ad
allow { $2_t } { var_run_t system_dbusd_var_run_t }:dir search;
Chris PeBenito ab58ad
allow { $2_t } system_dbusd_var_run_t:sock_file write;
Chris PeBenito ab58ad
',`') dnl endif system
Chris PeBenito ab58ad
') dnl endif dbusd.te
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# can_dbusd_converse(dbus_type, domain_prefix_a, domain_prefix_b)
Chris PeBenito ab58ad
# Example: can_dbusd_converse(system, hald, updfstab)
Chris PeBenito ab58ad
# Example: can_dbusd_converse(session, user, user)
Chris PeBenito ab58ad
define(`can_dbusd_converse',`')
Chris PeBenito ab58ad
ifdef(`dbusd.te',`
Chris PeBenito ab58ad
undefine(`can_dbusd_converse')
Chris PeBenito ab58ad
define(`can_dbusd_converse',`
Chris PeBenito ab58ad
allow $2_dbusd_$1_t $3_dbusd_$1_t:dbus { send_msg };
Chris PeBenito ab58ad
allow $3_dbusd_$1_t $2_dbusd_$1_t:dbus { send_msg };
Chris PeBenito ab58ad
') dnl endif dbusd.te
Chris PeBenito ab58ad
')