Chris PeBenito b2b38c
Chris PeBenito 857d37
policy_module(gpg, 2.2.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 857d37
role system_r types 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 857d37
role system_r types 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 857d37
type gpg_pinentry_tmp_t;
Chris PeBenito 857d37
files_tmp_file(gpg_pinentry_tmp_t)
Chris PeBenito 857d37
ubac_constrained(gpg_pinentry_tmp_t)
Chris PeBenito 857d37
Chris PeBenito 857d37
type gpg_pinentry_tmpfs_t;
Chris PeBenito 857d37
files_tmpfs_file(gpg_pinentry_tmpfs_t)
Chris PeBenito 857d37
ubac_constrained(gpg_pinentry_tmpfs_t)
Chris PeBenito 857d37
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 857d37
allow gpg_t self:process { signal signull setrlimit getcap 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 e4f73a
manage_dirs_pattern(gpg_t, gpg_agent_tmp_t, gpg_agent_tmp_t)
Chris PeBenito e4f73a
manage_files_pattern(gpg_t, gpg_agent_tmp_t, gpg_agent_tmp_t)
Chris PeBenito e4f73a
files_tmp_filetrans(gpg_t, gpg_agent_tmp_t, { dir file })
Chris PeBenito e4f73a
Chris PeBenito 857d37
domtrans_pattern(gpg_t, gpg_agent_exec_t, gpg_agent_t)
Chris PeBenito 857d37
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 e4f73a
kernel_read_sysctl(gpg_t)
Chris PeBenito e4f73a
Chris PeBenito 857d37
corecmd_exec_shell(gpg_t)
Chris PeBenito 857d37
corecmd_exec_bin(gpg_t)
Chris PeBenito 857d37
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 ca7fa5
dev_read_generic_usb_dev(gpg_t)
Chris PeBenito 296273
Chris PeBenito 296273
fs_getattr_xattr_fs(gpg_t)
Chris PeBenito 857d37
fs_list_inotifyfs(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 e4f73a
auth_use_nsswitch(gpg_t)
Chris PeBenito e4f73a
Chris PeBenito 296273
logging_send_syslog_msg(gpg_t)
Chris PeBenito 296273
Chris PeBenito 36ded4
miscfiles_read_localization(gpg_t)
Chris PeBenito 36ded4
Chris PeBenito 296273
userdom_use_user_terminals(gpg_t)
Chris PeBenito 36ded4
# sign/encrypt user files
Chris PeBenito 36ded4
userdom_manage_user_tmp_files(gpg_t)
Chris PeBenito 36ded4
userdom_manage_user_home_content_files(gpg_t)
Chris PeBenito 857d37
userdom_user_home_dir_filetrans_user_home_content(gpg_t, file)
Chris PeBenito 36ded4
Chris PeBenito 36ded4
mta_write_config(gpg_t)
Chris PeBenito 36ded4
Chris PeBenito 36ded4
tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 36ded4
	fs_manage_nfs_dirs(gpg_t)
Chris PeBenito 36ded4
	fs_manage_nfs_files(gpg_t)
Chris PeBenito 36ded4
')
Chris PeBenito 36ded4
Chris PeBenito 36ded4
tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 36ded4
	fs_manage_cifs_dirs(gpg_t)
Chris PeBenito 36ded4
	fs_manage_cifs_files(gpg_t)
Chris PeBenito 36ded4
')
Chris PeBenito 36ded4
Chris PeBenito 36ded4
optional_policy(`
Chris PeBenito 857d37
	mozilla_read_user_home_files(gpg_t)
Chris PeBenito 857d37
	mozilla_write_user_home_files(gpg_t)
Chris PeBenito 857d37
')
Chris PeBenito 857d37
Chris PeBenito 857d37
optional_policy(`
Chris PeBenito 36ded4
	xserver_use_xdm_fds(gpg_t)
Chris PeBenito 36ded4
	xserver_rw_xdm_pipes(gpg_t)
Chris PeBenito 36ded4
')
Chris PeBenito 36ded4
Chris PeBenito 36ded4
optional_policy(`
Chris PeBenito 36ded4
	cron_system_entry(gpg_t, gpg_exec_t)
Chris PeBenito 36ded4
	cron_read_system_job_tmp_files(gpg_t)
Chris PeBenito 36ded4
')
Chris PeBenito 296273
Chris PeBenito 296273
########################################
Chris PeBenito 296273
#
Chris PeBenito 296273
# GPG helper local policy
Chris PeBenito 296273
#
Chris PeBenito 296273
Chris PeBenito e4f73a
allow gpg_helper_t self:process { getsched setsched };
Chris PeBenito e4f73a
Chris PeBenito 296273
# for helper programs (which automatically fetch keys)
Chris PeBenito 857d37
# 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
files_read_etc_files(gpg_helper_t)
Chris PeBenito 296273
Chris PeBenito e4f73a
auth_use_nsswitch(gpg_helper_t)
Chris PeBenito e4f73a
Chris PeBenito e4f73a
userdom_use_user_terminals(gpg_helper_t)
Chris PeBenito 296273
Chris PeBenito 296273
tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 36ded4
	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 36ded4
	fs_dontaudit_rw_cifs_files(gpg_helper_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 857d37
corecmd_exec_shell(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 857d37
allow gpg_pinentry_t self:process { getcap getsched setsched signal };
Chris PeBenito 296273
allow gpg_pinentry_t self:fifo_file rw_fifo_file_perms;
Chris PeBenito 857d37
allow gpg_pinentry_t self:netlink_route_socket create_netlink_socket_perms;
Chris PeBenito 857d37
allow gpg_pinentry_t self:shm create_shm_perms;
Chris PeBenito 857d37
allow gpg_pinentry_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito 857d37
allow gpg_pinentry_t self:unix_dgram_socket sendto;
Chris PeBenito 857d37
allow gpg_pinentry_t self:unix_stream_socket { connect create getattr read shutdown write };
Chris PeBenito 296273
Chris PeBenito 857d37
can_exec(gpg_pinentry_t, pinentry_exec_t)
Chris PeBenito 857d37
Chris PeBenito 857d37
# 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 857d37
manage_sock_files_pattern(gpg_pinentry_t, gpg_pinentry_tmp_t, gpg_pinentry_tmp_t)
Chris PeBenito 857d37
userdom_user_tmp_filetrans(gpg_pinentry_t, gpg_pinentry_tmp_t, sock_file)
Chris PeBenito 857d37
Chris PeBenito 857d37
manage_dirs_pattern(gpg_pinentry_t, gpg_pinentry_tmpfs_t, gpg_pinentry_tmpfs_t)
Chris PeBenito 857d37
manage_files_pattern(gpg_pinentry_t, gpg_pinentry_tmpfs_t, gpg_pinentry_tmpfs_t)
Chris PeBenito 857d37
fs_tmpfs_filetrans(gpg_pinentry_t, gpg_pinentry_tmpfs_t, { file dir })
Chris PeBenito 857d37
fs_getattr_tmpfs(gpg_pinentry_t)
Chris PeBenito 857d37
Chris PeBenito 296273
# read /proc/meminfo
Chris PeBenito 296273
kernel_read_system_state(gpg_pinentry_t)
Chris PeBenito 296273
Chris PeBenito 857d37
corecmd_exec_bin(gpg_pinentry_t)
Chris PeBenito 857d37
Chris PeBenito 857d37
corenet_all_recvfrom_netlabel(gpg_pinentry_t)
Chris PeBenito 857d37
corenet_all_recvfrom_unlabeled(gpg_pinentry_t)
Chris PeBenito 857d37
corenet_sendrecv_pulseaudio_client_packets(gpg_pinentry_t)
Chris PeBenito 857d37
corenet_tcp_bind_generic_node(gpg_pinentry_t)
Chris PeBenito 857d37
corenet_tcp_connect_pulseaudio_port(gpg_pinentry_t)
Chris PeBenito 857d37
corenet_tcp_sendrecv_generic_if(gpg_pinentry_t)
Chris PeBenito 857d37
corenet_tcp_sendrecv_generic_node(gpg_pinentry_t)
Chris PeBenito 857d37
corenet_tcp_sendrecv_generic_port(gpg_pinentry_t)
Chris PeBenito 857d37
Chris PeBenito 857d37
dev_read_urand(gpg_pinentry_t)
Chris PeBenito 857d37
dev_read_rand(gpg_pinentry_t)
Chris PeBenito 857d37
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 857d37
logging_send_syslog_msg(gpg_pinentry_t)
Chris PeBenito 857d37
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 857d37
userdom_read_user_tmpfs_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 857d37
	dbus_session_bus_client(gpg_pinentry_t)
Chris PeBenito 857d37
	dbus_system_bus_client(gpg_pinentry_t)
Chris PeBenito 857d37
')
Chris PeBenito 857d37
Chris PeBenito 857d37
optional_policy(`
Chris PeBenito 857d37
	pulseaudio_exec(gpg_pinentry_t)
Chris PeBenito 857d37
	pulseaudio_setattr_home_dir(gpg_pinentry_t)
Chris PeBenito 857d37
	pulseaudio_stream_connect(gpg_pinentry_t)
Chris PeBenito 857d37
')
Chris PeBenito 857d37
Chris PeBenito 857d37
optional_policy(`
Chris PeBenito 857d37
	xserver_user_x_domain_template(gpg_pinentry, gpg_pinentry_t, gpg_pinentry_tmpfs_t)
Chris PeBenito 296273
')