1ec3d1a
## <summary>Policy for GNU Privacy Guard and related programs.</summary>
1ec3d1a
1ec3d1a
############################################################
1ec3d1a
## <summary>
1ec3d1a
##	Role access for gpg
1ec3d1a
## </summary>
1ec3d1a
## <param name="role">
1ec3d1a
##	<summary>
1ec3d1a
##	Role allowed access
1ec3d1a
##	</summary>
1ec3d1a
## </param>
1ec3d1a
## <param name="domain">
1ec3d1a
##	<summary>
1ec3d1a
##	User domain for the role
1ec3d1a
##	</summary>
1ec3d1a
## </param>
1ec3d1a
#
1ec3d1a
interface(`gpg_role',`
1ec3d1a
	gen_require(`
1ec3d1a
		type gpg_t, gpg_exec_t;
1ec3d1a
		type gpg_agent_t, gpg_agent_exec_t;
1ec3d1a
		type gpg_agent_tmp_t;
1ec3d1a
		type gpg_helper_t, gpg_pinentry_t;
1ec3d1a
		type gpg_pinentry_tmp_t;
1ec3d1a
	')
1ec3d1a
1ec3d1a
	role $1 types { gpg_t gpg_agent_t gpg_helper_t gpg_pinentry_t };
1ec3d1a
1ec3d1a
	# transition from the userdomain to the derived domain
1ec3d1a
	domtrans_pattern($2, gpg_exec_t, gpg_t)
1ec3d1a
1ec3d1a
	# allow ps to show gpg
1ec3d1a
	ps_process_pattern($2, gpg_t)
1ec3d1a
	allow $2 gpg_t:process { signull sigstop signal sigkill };
1ec3d1a
1ec3d1a
	# communicate with the user
1ec3d1a
	allow gpg_helper_t $2:fd use;
1ec3d1a
	allow gpg_helper_t $2:fifo_file write;
1ec3d1a
1ec3d1a
	# allow ps to show gpg-agent
1ec3d1a
	ps_process_pattern($2, gpg_agent_t)
1ec3d1a
1ec3d1a
	# Allow the user shell to signal the gpg-agent program.
1ec3d1a
	allow $2 gpg_agent_t:process { signal sigkill };
1ec3d1a
1ec3d1a
	manage_dirs_pattern($2, gpg_agent_tmp_t, gpg_agent_tmp_t)
1ec3d1a
	manage_files_pattern($2, gpg_agent_tmp_t, gpg_agent_tmp_t)
1ec3d1a
	manage_sock_files_pattern($2, gpg_agent_tmp_t, gpg_agent_tmp_t)
1ec3d1a
	files_tmp_filetrans(gpg_agent_t, gpg_agent_tmp_t, { file sock_file dir })
1ec3d1a
1ec3d1a
	# Transition from the user domain to the agent domain.
1ec3d1a
	domtrans_pattern($2, gpg_agent_exec_t, gpg_agent_t)
1ec3d1a
1ec3d1a
	manage_sock_files_pattern($2, gpg_pinentry_tmp_t, gpg_pinentry_tmp_t)
1ec3d1a
	relabel_sock_files_pattern($2, gpg_pinentry_tmp_t, gpg_pinentry_tmp_t)
1ec3d1a
1ec3d1a
	allow gpg_pinentry_t $2:fifo_file { read write };
1ec3d1a
1ec3d1a
	optional_policy(`
1ec3d1a
		gpg_pinentry_dbus_chat($2)
1ec3d1a
	')
1ec3d1a
1ec3d1a
	allow $2 gpg_agent_t:unix_stream_socket { rw_socket_perms connectto };
1ec3d1a
	ifdef(`hide_broken_symptoms',`
1ec3d1a
		#Leaked File Descriptors
1ec3d1a
		dontaudit gpg_t $2:fifo_file rw_fifo_file_perms;
1ec3d1a
		dontaudit gpg_agent_t $2:fifo_file rw_fifo_file_perms;
1ec3d1a
	')
1ec3d1a
')
1ec3d1a
1ec3d1a
########################################
1ec3d1a
## <summary>
1ec3d1a
##	Transition to a user gpg domain.
1ec3d1a
## </summary>
1ec3d1a
## <param name="domain">
1ec3d1a
##	<summary>
1ec3d1a
##	Domain allowed to transition.
1ec3d1a
##	</summary>
1ec3d1a
## </param>
1ec3d1a
#
1ec3d1a
interface(`gpg_domtrans',`
1ec3d1a
	gen_require(`
1ec3d1a
		type gpg_t, gpg_exec_t;
1ec3d1a
	')
1ec3d1a
1ec3d1a
	domtrans_pattern($1, gpg_exec_t, gpg_t)
1ec3d1a
')
1ec3d1a
1ec3d1a
######################################
1ec3d1a
## <summary>
1ec3d1a
##	Execute gpg in the caller domain.
1ec3d1a
## </summary>
1ec3d1a
## <param name="domain">
1ec3d1a
##	<summary>
1ec3d1a
##	Domain allowed access.
1ec3d1a
##	</summary>
1ec3d1a
## </param>
1ec3d1a
#
1ec3d1a
interface(`gpg_exec',`
1ec3d1a
	gen_require(`
1ec3d1a
		type gpg_exec_t;
1ec3d1a
	')
1ec3d1a
1ec3d1a
	corecmd_search_bin($1)
1ec3d1a
	can_exec($1, gpg_exec_t)
1ec3d1a
')
1ec3d1a
1ec3d1a
######################################
1ec3d1a
## <summary>
1ec3d1a
##  Transition to a gpg web domain.
1ec3d1a
## </summary>
1ec3d1a
## <param name="domain">
1ec3d1a
##  <summary>
1ec3d1a
##  Domain allowed access.
1ec3d1a
##  </summary>
1ec3d1a
## </param>
1ec3d1a
#
1ec3d1a
interface(`gpg_domtrans_web',`
1ec3d1a
    gen_require(`
1ec3d1a
        type gpg_web_t, gpg_exec_t;
1ec3d1a
    ')
1ec3d1a
1ec3d1a
    domtrans_pattern($1, gpg_exec_t, gpg_web_t)
1ec3d1a
')
1ec3d1a
1ec3d1a
######################################
1ec3d1a
## <summary>
1ec3d1a
##  Make gpg an entrypoint for
1ec3d1a
##  the specified domain.
1ec3d1a
## </summary>
1ec3d1a
## <param name="domain">
1ec3d1a
##  <summary>
1ec3d1a
##  The domain for which cifs_t is an entrypoint.
1ec3d1a
##  </summary>
1ec3d1a
## </param>
1ec3d1a
#
1ec3d1a
interface(`gpg_entry_type',`
1ec3d1a
    gen_require(`
1ec3d1a
        type gpg_exec_t;
1ec3d1a
    ')
1ec3d1a
1ec3d1a
    domain_entry_file($1, gpg_exec_t)
1ec3d1a
')
1ec3d1a
1ec3d1a
########################################
1ec3d1a
## <summary>
1ec3d1a
##	Send generic signals to user gpg processes.
1ec3d1a
## </summary>
1ec3d1a
## <param name="domain">
1ec3d1a
##	<summary>
1ec3d1a
##	Domain allowed access.
1ec3d1a
##	</summary>
1ec3d1a
## </param>
1ec3d1a
#
1ec3d1a
interface(`gpg_signal',`
1ec3d1a
	gen_require(`
1ec3d1a
		type gpg_t;
1ec3d1a
	')
1ec3d1a
1ec3d1a
	allow $1 gpg_t:process signal;
1ec3d1a
')
1ec3d1a
1ec3d1a
########################################
1ec3d1a
## <summary>
1ec3d1a
##	Read and write GPG agent pipes.
1ec3d1a
## </summary>
1ec3d1a
## <param name="domain">
1ec3d1a
##	<summary>
1ec3d1a
##	Domain allowed access.
1ec3d1a
##	</summary>
1ec3d1a
## </param>
1ec3d1a
#
1ec3d1a
interface(`gpg_rw_agent_pipes',`
1ec3d1a
	# Just wants read/write could this be a leak?
1ec3d1a
	gen_require(`
1ec3d1a
		type gpg_agent_t;
1ec3d1a
	')
1ec3d1a
1ec3d1a
	allow $1 gpg_agent_t:fifo_file rw_fifo_file_perms;
1ec3d1a
')
1ec3d1a
1ec3d1a
########################################
1ec3d1a
## <summary>
1ec3d1a
##	Send messages to and from GPG
1ec3d1a
##	Pinentry over DBUS.
1ec3d1a
## </summary>
1ec3d1a
## <param name="domain">
1ec3d1a
##	<summary>
1ec3d1a
##	Domain allowed access.
1ec3d1a
##	</summary>
1ec3d1a
## </param>
1ec3d1a
#
1ec3d1a
interface(`gpg_pinentry_dbus_chat',`
1ec3d1a
	gen_require(`
1ec3d1a
		type gpg_pinentry_t;
1ec3d1a
		class dbus send_msg;
1ec3d1a
	')
1ec3d1a
1ec3d1a
	allow $1 gpg_pinentry_t:dbus send_msg;
1ec3d1a
	allow gpg_pinentry_t $1:dbus send_msg;
1ec3d1a
')
1ec3d1a
1ec3d1a
########################################
1ec3d1a
## <summary>
1ec3d1a
##	List Gnu Privacy Guard user secrets.
1ec3d1a
## </summary>
1ec3d1a
## <param name="domain">
1ec3d1a
##	<summary>
1ec3d1a
##	Domain allowed access.
1ec3d1a
##	</summary>
1ec3d1a
## </param>
1ec3d1a
#
1ec3d1a
interface(`gpg_list_user_secrets',`
1ec3d1a
	gen_require(`
1ec3d1a
		type gpg_secret_t;
1ec3d1a
	')
1ec3d1a
1ec3d1a
	list_dirs_pattern($1, gpg_secret_t, gpg_secret_t)
1ec3d1a
	userdom_search_user_home_dirs($1)
1ec3d1a
')
a14ab5e
###########################
a14ab5e
## <summary>
a14ab5e
##	Allow to manage gpg named home content
a14ab5e
## </summary>
a14ab5e
## <param name="domain">
a14ab5e
##	<summary>
a14ab5e
##      Domain allowed access.
a14ab5e
##	</summary>
a14ab5e
## </param>
a14ab5e
#
a14ab5e
interface(`gpg_manage_home_content',`
a14ab5e
	gen_require(`
a14ab5e
		type gpg_secret_t;
a14ab5e
	')
20f7d02
a14ab5e
	manage_files_pattern($1, gpg_secret_t, gpg_secret_t)
a14ab5e
	manage_dirs_pattern($1, gpg_secret_t, gpg_secret_t)
a14ab5e
	userdom_user_home_dir_filetrans($1, gpg_secret_t, dir, ".gnupg")
a14ab5e
')
20f7d02
########################################
20f7d02
## <summary>
20f7d02
##	Transition to gpg named home content
20f7d02
## </summary>
20f7d02
## <param name="domain">
20f7d02
##	<summary>
20f7d02
##      Domain allowed access.
20f7d02
##	</summary>
20f7d02
## </param>
20f7d02
#
20f7d02
interface(`gpg_filetrans_home_content',`
20f7d02
	gen_require(`
20f7d02
		type gpg_secret_t;
20f7d02
	')
20f7d02
20f7d02
	userdom_user_home_dir_filetrans($1, gpg_secret_t, dir, ".gnupg")
20f7d02
')