Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Macros for gpg agent
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Author: Thomas Bleher <ThomasBleher@gmx.de>
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# 
Chris PeBenito 31b7c0
# gpg_agent_domain(domain_prefix)
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/gpg-agent.te. 
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
define(`gpg_agent_domain',`
Chris PeBenito 31b7c0
# Define a derived domain for the gpg-agent program when executed
Chris PeBenito 31b7c0
# by a user domain.
Chris PeBenito 31b7c0
# Derived domain based on the calling user domain and the program.
Chris PeBenito 31b7c0
type $1_gpg_agent_t, domain;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Transition from the user domain to the derived domain.
Chris PeBenito 31b7c0
domain_auto_trans($1_t, gpg_agent_exec_t, $1_gpg_agent_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# The user role is authorized for this domain.
Chris PeBenito 31b7c0
role $1_r types $1_gpg_agent_t;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow $1_gpg_agent_t privfd:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Write to the user domain tty.
Chris PeBenito 31b7c0
access_terminal($1_gpg_agent_t, $1)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow the user shell to signal the gpg-agent program.
Chris PeBenito 31b7c0
allow $1_t $1_gpg_agent_t:process { signal sigkill };
Chris PeBenito 31b7c0
# allow ps to show gpg-agent
Chris PeBenito 31b7c0
can_ps($1_t, $1_gpg_agent_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
uses_shlib($1_gpg_agent_t)
Chris PeBenito 31b7c0
read_locale($1_gpg_agent_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# rlimit: gpg-agent wants to prevent coredumps
Chris PeBenito 31b7c0
allow $1_gpg_agent_t self:process { setrlimit fork sigchld };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow $1_gpg_agent_t { self proc_t }:dir search;
Chris PeBenito 31b7c0
allow $1_gpg_agent_t { self proc_t }:lnk_file read;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow $1_gpg_agent_t device_t:dir { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# read and write ~/.gnupg (gpg-agent stores secret keys in ~/.gnupg/private-keys-v1.d )
Chris PeBenito 31b7c0
allow $1_gpg_agent_t { home_root_t $1_home_dir_t }:dir search;
Chris PeBenito 31b7c0
create_dir_file($1_gpg_agent_t, $1_gpg_secret_t)
Chris PeBenito 31b7c0
if (use_nfs_home_dirs) {
Chris PeBenito 31b7c0
create_dir_file($1_gpg_agent_t, nfs_t)
Chris PeBenito 31b7c0
}
Chris PeBenito 31b7c0
if (use_samba_home_dirs) {
Chris PeBenito 31b7c0
create_dir_file($1_gpg_agent_t, cifs_t)
Chris PeBenito 31b7c0
}
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow $1_gpg_agent_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
allow $1_gpg_agent_t self:fifo_file { getattr read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# create /tmp files
Chris PeBenito 31b7c0
tmp_domain($1_gpg_agent, `', `{ file dir sock_file }')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# gpg connect
Chris PeBenito 31b7c0
allow $1_gpg_t $1_gpg_agent_tmp_t:dir search;
Chris PeBenito 31b7c0
allow $1_gpg_t $1_gpg_agent_tmp_t:sock_file write;
Chris PeBenito 31b7c0
can_unix_connect($1_gpg_t, $1_gpg_agent_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# policy for pinentry
Chris PeBenito 31b7c0
# ===================
Chris PeBenito 31b7c0
# we need to allow gpg-agent to call pinentry so it can get the passphrase 
Chris PeBenito 31b7c0
# from the user.
Chris PeBenito 31b7c0
# Please note that I didnt use the x_client_domain-macro as it gives too 
Chris PeBenito 31b7c0
# much permissions
Chris PeBenito 31b7c0
type $1_gpg_pinentry_t, domain;
Chris PeBenito 31b7c0
role $1_r types $1_gpg_pinentry_t;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow $1_gpg_agent_t bin_t:dir search;
Chris PeBenito 31b7c0
domain_auto_trans($1_gpg_agent_t, pinentry_exec_t, $1_gpg_pinentry_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
uses_shlib($1_gpg_pinentry_t)
Chris PeBenito 31b7c0
read_locale($1_gpg_pinentry_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t self:unix_stream_socket { connect create getattr read shutdown write };
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t self:fifo_file { getattr read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`xdm.te', `
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t xdm_xserver_tmp_t:dir search;
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t xdm_xserver_tmp_t:sock_file { read write };
Chris PeBenito 31b7c0
can_unix_connect($1_gpg_pinentry_t, xdm_xserver_t)
Chris PeBenito 31b7c0
')dnl end ig xdm.te
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
read_fonts($1_gpg_pinentry_t, $1)
Chris PeBenito 31b7c0
# read kde font cache
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t usr_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t { proc_t self }:dir search;
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t { proc_t self }:lnk_file read;
Chris PeBenito 31b7c0
# read /proc/meminfo
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t proc_t:file read;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t { tmp_t home_root_t }:dir { getattr search };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for .Xauthority
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t $1_home_dir_t:dir { getattr search };
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t $1_home_t:file { getattr read };
Chris PeBenito 31b7c0
# wants to put some lock files into the user home dir, seems to work fine without
Chris PeBenito 31b7c0
dontaudit $1_gpg_pinentry_t $1_home_t:dir { read write };
Chris PeBenito 31b7c0
dontaudit $1_gpg_pinentry_t $1_home_t:file write;
Chris PeBenito 31b7c0
if (use_nfs_home_dirs) {
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t nfs_t:dir { getattr search };
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t nfs_t:file { getattr read };
Chris PeBenito 31b7c0
dontaudit $1_gpg_pinentry_t nfs_t:dir { read write };
Chris PeBenito 31b7c0
dontaudit $1_gpg_pinentry_t nfs_t:file write;
Chris PeBenito 31b7c0
}
Chris PeBenito 31b7c0
if (use_samba_home_dirs) {
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t cifs_t:dir { getattr search };
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t cifs_t:file { getattr read };
Chris PeBenito 31b7c0
dontaudit $1_gpg_pinentry_t cifs_t:dir { read write };
Chris PeBenito 31b7c0
dontaudit $1_gpg_pinentry_t cifs_t:file write;
Chris PeBenito 31b7c0
}
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# read /etc/X11/qtrc
Chris PeBenito 31b7c0
allow $1_gpg_pinentry_t etc_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
dontaudit $1_gpg_pinentry_t { sysctl_t sysctl_kernel_t bin_t }:dir { getattr search };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
')dnl end if gpg_agent