Chris PeBenito b2b38c
Chris PeBenito c12621
policy_module(gpg, 2.0.2)
Chris PeBenito b2b38c
Chris PeBenito b2b38c
########################################
Chris PeBenito b2b38c
#
Chris PeBenito b2b38c
# Declarations
Chris PeBenito b2b38c
#
Chris PeBenito b2b38c
Chris PeBenito a42ce9
## <desc>
Chris PeBenito a42ce9
## 

Chris PeBenito a42ce9
## Allow usage of the gpg-agent --write-env-file option.
Chris PeBenito a42ce9
## This also allows gpg-agent to manage user files.
Chris PeBenito a42ce9
## 

Chris PeBenito a42ce9
## </desc>
Chris PeBenito a42ce9
gen_tunable(gpg_agent_env_file, false)
Chris PeBenito a42ce9
Chris PeBenito 296273
type gpg_t;
Chris PeBenito b2b38c
type gpg_exec_t;
Chris PeBenito 296273
typealias gpg_t alias { user_gpg_t staff_gpg_t sysadm_gpg_t };
Chris PeBenito 296273
typealias gpg_t alias { auditadm_gpg_t secadm_gpg_t };
Chris PeBenito 296273
application_domain(gpg_t, gpg_exec_t)
Chris PeBenito 296273
ubac_constrained(gpg_t)
Chris PeBenito b2b38c
Chris PeBenito 296273
type gpg_agent_t;
Chris PeBenito b2b38c
type gpg_agent_exec_t;
Chris PeBenito 296273
typealias gpg_agent_t alias { user_gpg_agent_t staff_gpg_agent_t sysadm_gpg_agent_t };
Chris PeBenito 296273
typealias gpg_agent_t alias { auditadm_gpg_agent_t secadm_gpg_agent_t };
Chris PeBenito 296273
application_domain(gpg_agent_t, gpg_agent_exec_t)
Chris PeBenito 296273
ubac_constrained(gpg_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
type gpg_agent_tmp_t;
Chris PeBenito 296273
typealias gpg_agent_tmp_t alias { user_gpg_agent_tmp_t staff_gpg_agent_tmp_t sysadm_gpg_agent_tmp_t };
Chris PeBenito 296273
typealias gpg_agent_tmp_t alias { auditadm_gpg_agent_tmp_t secadm_gpg_agent_tmp_t };
Chris PeBenito 296273
files_tmp_file(gpg_agent_tmp_t)
Chris PeBenito 296273
ubac_constrained(gpg_agent_tmp_t)
Chris PeBenito 296273
Chris PeBenito 296273
type gpg_secret_t;
Chris PeBenito 296273
typealias gpg_secret_t alias { user_gpg_secret_t staff_gpg_secret_t sysadm_gpg_secret_t };
Chris PeBenito 296273
typealias gpg_secret_t alias { auditadm_gpg_secret_t secadm_gpg_secret_t };
Chris PeBenito 296273
userdom_user_home_content(gpg_secret_t)
Chris PeBenito 296273
Chris PeBenito 296273
type gpg_helper_t;
Chris PeBenito 296273
type gpg_helper_exec_t;
Chris PeBenito 296273
typealias gpg_helper_t alias { user_gpg_helper_t staff_gpg_helper_t sysadm_gpg_helper_t };
Chris PeBenito 296273
typealias gpg_helper_t alias { auditadm_gpg_helper_t secadm_gpg_helper_t };
Chris PeBenito 296273
application_domain(gpg_helper_t, gpg_helper_exec_t)
Chris PeBenito 296273
ubac_constrained(gpg_helper_t)
Chris PeBenito b2b38c
Chris PeBenito 296273
type gpg_pinentry_t;
Chris PeBenito b2b38c
type pinentry_exec_t;
Chris PeBenito 296273
typealias gpg_pinentry_t alias { user_gpg_pinentry_t staff_gpg_pinentry_t sysadm_gpg_pinentry_t };
Chris PeBenito 296273
typealias gpg_pinentry_t alias { auditadm_gpg_pinentry_t secadm_gpg_pinentry_t };
Chris PeBenito 296273
application_domain(gpg_pinentry_t, pinentry_exec_t)
Chris PeBenito 296273
ubac_constrained(gpg_pinentry_t)
Chris PeBenito 296273
Chris PeBenito 296273
########################################
Chris PeBenito 296273
#
Chris PeBenito 296273
# GPG local policy
Chris PeBenito 296273
#
Chris PeBenito 296273
Chris PeBenito 296273
allow gpg_t self:capability { ipc_lock setuid };
Chris PeBenito 296273
# setrlimit is for ulimit -c 0
Chris PeBenito 296273
allow gpg_t self:process { signal setrlimit setcap setpgid };
Chris PeBenito 296273
Chris PeBenito 296273
allow gpg_t self:fifo_file rw_fifo_file_perms;
Chris PeBenito 296273
allow gpg_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito 296273
Chris PeBenito 296273
# transition from the gpg domain to the helper domain
Chris PeBenito 296273
domtrans_pattern(gpg_t, gpg_helper_exec_t, gpg_helper_t)
Chris PeBenito 296273
Chris PeBenito 296273
allow gpg_t gpg_secret_t:dir create_dir_perms;
Chris PeBenito 296273
manage_files_pattern(gpg_t, gpg_secret_t, gpg_secret_t)
Chris PeBenito 296273
manage_lnk_files_pattern(gpg_t, gpg_secret_t, gpg_secret_t)
Chris PeBenito 296273
userdom_user_home_dir_filetrans(gpg_t, gpg_secret_t, dir)
Chris PeBenito 296273
Chris PeBenito 296273
corenet_all_recvfrom_unlabeled(gpg_t)
Chris PeBenito 296273
corenet_all_recvfrom_netlabel(gpg_t)
Chris PeBenito 668b30
corenet_tcp_sendrecv_generic_if(gpg_t)
Chris PeBenito 668b30
corenet_udp_sendrecv_generic_if(gpg_t)
Chris PeBenito c12621
corenet_tcp_sendrecv_generic_node(gpg_t)
Chris PeBenito c12621
corenet_udp_sendrecv_generic_node(gpg_t)
Chris PeBenito 296273
corenet_tcp_sendrecv_all_ports(gpg_t)
Chris PeBenito 296273
corenet_udp_sendrecv_all_ports(gpg_t)
Chris PeBenito 296273
corenet_tcp_connect_all_ports(gpg_t)
Chris PeBenito 296273
corenet_sendrecv_all_client_packets(gpg_t)
Chris PeBenito 296273
Chris PeBenito 296273
dev_read_rand(gpg_t)
Chris PeBenito 296273
dev_read_urand(gpg_t)
Chris PeBenito 296273
Chris PeBenito 296273
fs_getattr_xattr_fs(gpg_t)
Chris PeBenito 296273
Chris PeBenito 296273
domain_use_interactive_fds(gpg_t)
Chris PeBenito 296273
Chris PeBenito 296273
files_read_etc_files(gpg_t)
Chris PeBenito 296273
files_read_usr_files(gpg_t)
Chris PeBenito 296273
files_dontaudit_search_var(gpg_t)
Chris PeBenito 296273
Chris PeBenito 296273
miscfiles_read_localization(gpg_t)
Chris PeBenito 296273
Chris PeBenito 296273
logging_send_syslog_msg(gpg_t)
Chris PeBenito 296273
Chris PeBenito 296273
sysnet_read_config(gpg_t)
Chris PeBenito 296273
Chris PeBenito 296273
userdom_use_user_terminals(gpg_t)
Chris PeBenito 296273
Chris PeBenito 296273
optional_policy(`
Chris PeBenito 296273
	nis_use_ypbind(gpg_t)
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
########################################
Chris PeBenito 296273
#
Chris PeBenito 296273
# GPG helper local policy
Chris PeBenito 296273
#
Chris PeBenito 296273
Chris PeBenito 296273
# for helper programs (which automatically fetch keys)
Chris PeBenito 296273
# Note: this is only tested with the hkp interface. If you use eg the 
Chris PeBenito 296273
# mail interface you will likely need additional permissions.
Chris PeBenito 296273
Chris PeBenito 296273
allow gpg_helper_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 296273
allow gpg_helper_t self:tcp_socket { connect connected_socket_perms };
Chris PeBenito 296273
allow gpg_helper_t self:udp_socket { connect connected_socket_perms };
Chris PeBenito 296273
Chris PeBenito 296273
dontaudit gpg_helper_t gpg_secret_t:file read;
Chris PeBenito 296273
Chris PeBenito 296273
corenet_all_recvfrom_unlabeled(gpg_helper_t)
Chris PeBenito 296273
corenet_all_recvfrom_netlabel(gpg_helper_t)
Chris PeBenito 668b30
corenet_tcp_sendrecv_generic_if(gpg_helper_t)
Chris PeBenito 668b30
corenet_raw_sendrecv_generic_if(gpg_helper_t)
Chris PeBenito 668b30
corenet_udp_sendrecv_generic_if(gpg_helper_t)
Chris PeBenito c12621
corenet_tcp_sendrecv_generic_node(gpg_helper_t)
Chris PeBenito c12621
corenet_udp_sendrecv_generic_node(gpg_helper_t)
Chris PeBenito c12621
corenet_raw_sendrecv_generic_node(gpg_helper_t)
Chris PeBenito 296273
corenet_tcp_sendrecv_all_ports(gpg_helper_t)
Chris PeBenito 296273
corenet_udp_sendrecv_all_ports(gpg_helper_t)
Chris PeBenito c12621
corenet_tcp_bind_generic_node(gpg_helper_t)
Chris PeBenito c12621
corenet_udp_bind_generic_node(gpg_helper_t)
Chris PeBenito 296273
corenet_tcp_connect_all_ports(gpg_helper_t)
Chris PeBenito 296273
Chris PeBenito 296273
dev_read_urand(gpg_helper_t)
Chris PeBenito 296273
Chris PeBenito 296273
files_read_etc_files(gpg_helper_t)
Chris PeBenito 296273
# for nscd
Chris PeBenito 296273
files_dontaudit_search_var(gpg_helper_t)
Chris PeBenito 296273
Chris PeBenito 296273
sysnet_read_config(gpg_helper_t)
Chris PeBenito 296273
Chris PeBenito 296273
tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 296273
	fs_dontaudit_rw_nfs_files(gpg_helper_t)
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 296273
	fs_dontaudit_rw_cifs_files(gpg_helper_t)
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
optional_policy(`
Chris PeBenito 296273
	xserver_use_xdm_fds(gpg_t)
Chris PeBenito 296273
	xserver_rw_xdm_pipes(gpg_t)
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
########################################
Chris PeBenito 296273
#
Chris PeBenito 296273
# GPG agent local policy
Chris PeBenito 296273
#
Chris PeBenito 296273
Chris PeBenito 296273
# rlimit: gpg-agent wants to prevent coredumps
Chris PeBenito 296273
allow gpg_agent_t self:process setrlimit;
Chris PeBenito 296273
Chris PeBenito 296273
allow gpg_agent_t self:unix_stream_socket create_stream_socket_perms ;
Chris PeBenito 296273
allow gpg_agent_t self:fifo_file rw_fifo_file_perms;
Chris PeBenito 296273
Chris PeBenito 296273
# read and write ~/.gnupg (gpg-agent stores secret keys in ~/.gnupg/private-keys-v1.d )
Chris PeBenito 296273
manage_dirs_pattern(gpg_agent_t, gpg_secret_t, gpg_secret_t)
Chris PeBenito 296273
manage_files_pattern(gpg_agent_t, gpg_secret_t, gpg_secret_t)
Chris PeBenito 296273
manage_lnk_files_pattern(gpg_agent_t, gpg_secret_t, gpg_secret_t)
Chris PeBenito 296273
Chris PeBenito 296273
# Allow the gpg-agent to manage its tmp files (socket)
Chris PeBenito 296273
manage_dirs_pattern(gpg_agent_t, gpg_agent_tmp_t, gpg_agent_tmp_t)
Chris PeBenito 296273
manage_files_pattern(gpg_agent_t, gpg_agent_tmp_t, gpg_agent_tmp_t)
Chris PeBenito 296273
manage_sock_files_pattern(gpg_agent_t, gpg_agent_tmp_t, gpg_agent_tmp_t)
Chris PeBenito 296273
files_tmp_filetrans(gpg_agent_t, gpg_agent_tmp_t, { file sock_file dir })
Chris PeBenito 296273
Chris PeBenito 296273
# allow gpg to connect to the gpg agent
Chris PeBenito 296273
stream_connect_pattern(gpg_t, gpg_agent_tmp_t, gpg_agent_tmp_t, gpg_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
corecmd_search_bin(gpg_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
domain_use_interactive_fds(gpg_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
miscfiles_read_localization(gpg_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
# Write to the user domain tty.
Chris PeBenito 296273
userdom_use_user_terminals(gpg_agent_t)
Chris PeBenito 296273
# read and write ~/.gnupg (gpg-agent stores secret keys in ~/.gnupg/private-keys-v1.d )
Chris PeBenito 296273
userdom_search_user_home_dirs(gpg_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
tunable_policy(`gpg_agent_env_file',`
Chris PeBenito 296273
	# write ~/.gpg-agent-info or a similar to the users home dir
Chris PeBenito 296273
	# or subdir (gpg-agent --write-env-file option)
Chris PeBenito 296273
	#
Chris PeBenito 296273
	userdom_user_home_dir_filetrans_user_home_content(gpg_agent_t, file)
Chris PeBenito 296273
	userdom_manage_user_home_content_dirs(gpg_agent_t)
Chris PeBenito 296273
	userdom_manage_user_home_content_files(gpg_agent_t)
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 296273
	fs_manage_nfs_dirs(gpg_agent_t)
Chris PeBenito 296273
	fs_manage_nfs_files(gpg_agent_t)
Chris PeBenito 296273
	fs_manage_nfs_symlinks(gpg_agent_t)
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 296273
	fs_manage_cifs_dirs(gpg_agent_t)
Chris PeBenito 296273
	fs_manage_cifs_files(gpg_agent_t)
Chris PeBenito 296273
	fs_manage_cifs_symlinks(gpg_agent_t)
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
##############################
Chris PeBenito 296273
#
Chris PeBenito 296273
# Pinentry local policy
Chris PeBenito 296273
#
Chris PeBenito 296273
Chris PeBenito 296273
allow gpg_pinentry_t self:unix_stream_socket { connect create getattr read shutdown write };
Chris PeBenito 296273
allow gpg_pinentry_t self:fifo_file rw_fifo_file_perms;
Chris PeBenito 296273
Chris PeBenito 296273
# we need to allow gpg-agent to call pinentry so it can get the passphrase 
Chris PeBenito 296273
# from the user.
Chris PeBenito 296273
domtrans_pattern(gpg_agent_t, pinentry_exec_t, gpg_pinentry_t)
Chris PeBenito 296273
Chris PeBenito 296273
# read /proc/meminfo
Chris PeBenito 296273
kernel_read_system_state(gpg_pinentry_t)
Chris PeBenito 296273
Chris PeBenito 296273
files_read_usr_files(gpg_pinentry_t)
Chris PeBenito 296273
# read /etc/X11/qtrc
Chris PeBenito 296273
files_read_etc_files(gpg_pinentry_t)
Chris PeBenito 296273
Chris PeBenito 296273
miscfiles_read_fonts(gpg_pinentry_t)
Chris PeBenito 296273
miscfiles_read_localization(gpg_pinentry_t)
Chris PeBenito 296273
Chris PeBenito 296273
# for .Xauthority
Chris PeBenito 296273
userdom_read_user_home_content_files(gpg_pinentry_t)
Chris PeBenito 296273
Chris PeBenito 296273
tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 296273
	fs_read_nfs_files(gpg_pinentry_t)
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 296273
	fs_read_cifs_files(gpg_pinentry_t)
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
optional_policy(`
Chris PeBenito 296273
	xserver_stream_connect(gpg_pinentry_t)
Chris PeBenito 296273
')