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