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