Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Macros for gpg and pgp
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Author:  Russell Coker <russell@coker.com.au>
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# based on the work of:
Chris PeBenito ab58ad
# Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# gpg_domain(domain_prefix)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define a derived domain for the gpg/pgp 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/gpg.te.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`gpg_domain', `
Chris PeBenito ab58ad
# Derived domain based on the calling user domain and the program.
Chris PeBenito ab58ad
type $1_gpg_t, domain, privlog;
Chris PeBenito ab58ad
type $1_gpg_secret_t, file_type, $1_file_type, sysadmfile;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Transition from the user domain to the derived domain.
Chris PeBenito ab58ad
domain_auto_trans($1_t, gpg_exec_t, $1_gpg_t)
Chris PeBenito ab58ad
role $1_r types $1_gpg_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_network($1_gpg_t)
Chris PeBenito ab58ad
allow $1_gpg_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
can_ypbind($1_gpg_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for a bug in kmail
Chris PeBenito ab58ad
dontaudit $1_gpg_t $1_t:unix_stream_socket { getattr read write };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_gpg_t device_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_gpg_t { random_device_t urandom_device_t }:chr_file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_gpg_t etc_t:file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_gpg_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito ab58ad
allow $1_gpg_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
access_terminal($1_gpg_t, $1)
Chris PeBenito ab58ad
ifdef(`gnome-pty-helper.te', `allow $1_gpg_t $1_gph_t:fd use;')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Inherit and use descriptors
Chris PeBenito ab58ad
allow $1_gpg_t { privfd $1_t }:fd use;
Chris PeBenito ab58ad
allow { $1_t $1_gpg_t } $1_gpg_t:process signal;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# setrlimit is for ulimit -c 0
Chris PeBenito ab58ad
allow $1_gpg_t self:process { setrlimit setcap setpgid };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# allow ps to show gpg
Chris PeBenito ab58ad
can_ps($1_t, $1_gpg_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
uses_shlib($1_gpg_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access .gnupg
Chris PeBenito ab58ad
rw_dir_create_file($1_gpg_t, $1_gpg_secret_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read content to encrypt/decrypt/sign
Chris PeBenito ab58ad
read_content($1_gpg_t, $1)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Write content to encrypt/decrypt/sign
Chris PeBenito ab58ad
write_trusted($1_gpg_t, $1)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_gpg_t self:capability { ipc_lock setuid };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_gpg_t { etc_t usr_t }:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_gpg_t fs_t:filesystem getattr;
Chris PeBenito ab58ad
allow $1_gpg_t usr_t:file r_file_perms;
Chris PeBenito ab58ad
read_locale($1_gpg_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
dontaudit $1_gpg_t var_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`gpg-agent.te', `gpg_agent_domain($1)')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for helper programs (which automatically fetch keys)
Chris PeBenito ab58ad
# Note: this is only tested with the hkp interface. If you use eg the 
Chris PeBenito ab58ad
# mail interface you will likely need additional permissions.
Chris PeBenito ab58ad
type $1_gpg_helper_t, domain;
Chris PeBenito ab58ad
role $1_r types $1_gpg_helper_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
domain_auto_trans($1_gpg_t, gpg_helper_exec_t, $1_gpg_helper_t)
Chris PeBenito ab58ad
uses_shlib($1_gpg_helper_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# allow gpg to fork so it can call the helpers
Chris PeBenito ab58ad
allow $1_gpg_t self:process { fork sigchld };
Chris PeBenito ab58ad
allow $1_gpg_t self:fifo_file { getattr read write };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
dontaudit $1_gpg_helper_t $1_gpg_secret_t:file read;
Chris PeBenito ab58ad
if (use_nfs_home_dirs) {
Chris PeBenito ab58ad
dontaudit $1_gpg_helper_t nfs_t:file { read write };
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
if (use_samba_home_dirs) {
Chris PeBenito ab58ad
dontaudit $1_gpg_helper_t cifs_t:file { read write };
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# communicate with the user 
Chris PeBenito ab58ad
allow $1_gpg_helper_t $1_t:fd use;
Chris PeBenito ab58ad
allow $1_gpg_helper_t $1_t:fifo_file write;
Chris PeBenito ab58ad
# get keys from the network
Chris PeBenito ab58ad
can_network_client($1_gpg_helper_t)
Chris PeBenito ab58ad
allow $1_gpg_helper_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
allow $1_gpg_helper_t etc_t:file { getattr read };
Chris PeBenito ab58ad
allow $1_gpg_helper_t urandom_device_t:chr_file read;
Chris PeBenito ab58ad
allow $1_gpg_helper_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito ab58ad
# for nscd
Chris PeBenito ab58ad
dontaudit $1_gpg_helper_t var_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_pipe_xdm($1_gpg_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
')dnl end gpg_domain definition