]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - policy/modules/apps/gpg.te
GPG patch from Dan Walsh.
[people/stevee/selinux-policy.git] / policy / modules / apps / gpg.te
CommitLineData
a3b0dc5b 1policy_module(gpg, 2.3.1)
b2b38c78
CP
2
3########################################
4#
5# Declarations
6#
7
a42ce93a
CP
8## <desc>
9## <p>
10## Allow usage of the gpg-agent --write-env-file option.
11## This also allows gpg-agent to manage user files.
12## </p>
13## </desc>
14gen_tunable(gpg_agent_env_file, false)
15
296273a7 16type gpg_t;
b2b38c78 17type gpg_exec_t;
296273a7
CP
18typealias gpg_t alias { user_gpg_t staff_gpg_t sysadm_gpg_t };
19typealias gpg_t alias { auditadm_gpg_t secadm_gpg_t };
20application_domain(gpg_t, gpg_exec_t)
21ubac_constrained(gpg_t)
857d37e8 22role system_r types gpg_t;
b2b38c78 23
296273a7 24type gpg_agent_t;
b2b38c78 25type gpg_agent_exec_t;
296273a7
CP
26typealias gpg_agent_t alias { user_gpg_agent_t staff_gpg_agent_t sysadm_gpg_agent_t };
27typealias gpg_agent_t alias { auditadm_gpg_agent_t secadm_gpg_agent_t };
28application_domain(gpg_agent_t, gpg_agent_exec_t)
29ubac_constrained(gpg_agent_t)
30
31type gpg_agent_tmp_t;
32typealias gpg_agent_tmp_t alias { user_gpg_agent_tmp_t staff_gpg_agent_tmp_t sysadm_gpg_agent_tmp_t };
33typealias gpg_agent_tmp_t alias { auditadm_gpg_agent_tmp_t secadm_gpg_agent_tmp_t };
34files_tmp_file(gpg_agent_tmp_t)
35ubac_constrained(gpg_agent_tmp_t)
36
37type gpg_secret_t;
38typealias gpg_secret_t alias { user_gpg_secret_t staff_gpg_secret_t sysadm_gpg_secret_t };
39typealias gpg_secret_t alias { auditadm_gpg_secret_t secadm_gpg_secret_t };
40userdom_user_home_content(gpg_secret_t)
41
42type gpg_helper_t;
43type gpg_helper_exec_t;
44typealias gpg_helper_t alias { user_gpg_helper_t staff_gpg_helper_t sysadm_gpg_helper_t };
45typealias gpg_helper_t alias { auditadm_gpg_helper_t secadm_gpg_helper_t };
46application_domain(gpg_helper_t, gpg_helper_exec_t)
47ubac_constrained(gpg_helper_t)
857d37e8 48role system_r types gpg_helper_t;
b2b38c78 49
296273a7 50type gpg_pinentry_t;
b2b38c78 51type pinentry_exec_t;
296273a7
CP
52typealias gpg_pinentry_t alias { user_gpg_pinentry_t staff_gpg_pinentry_t sysadm_gpg_pinentry_t };
53typealias gpg_pinentry_t alias { auditadm_gpg_pinentry_t secadm_gpg_pinentry_t };
54application_domain(gpg_pinentry_t, pinentry_exec_t)
55ubac_constrained(gpg_pinentry_t)
56
857d37e8
CP
57type gpg_pinentry_tmp_t;
58files_tmp_file(gpg_pinentry_tmp_t)
59ubac_constrained(gpg_pinentry_tmp_t)
60
61type gpg_pinentry_tmpfs_t;
62files_tmpfs_file(gpg_pinentry_tmpfs_t)
63ubac_constrained(gpg_pinentry_tmpfs_t)
64
296273a7
CP
65########################################
66#
67# GPG local policy
68#
69
70allow gpg_t self:capability { ipc_lock setuid };
71# setrlimit is for ulimit -c 0
857d37e8 72allow gpg_t self:process { signal signull setrlimit getcap setcap setpgid };
296273a7
CP
73
74allow gpg_t self:fifo_file rw_fifo_file_perms;
75allow gpg_t self:tcp_socket create_stream_socket_perms;
76
e4f73afb
CP
77manage_dirs_pattern(gpg_t, gpg_agent_tmp_t, gpg_agent_tmp_t)
78manage_files_pattern(gpg_t, gpg_agent_tmp_t, gpg_agent_tmp_t)
79files_tmp_filetrans(gpg_t, gpg_agent_tmp_t, { dir file })
80
857d37e8
CP
81domtrans_pattern(gpg_t, gpg_agent_exec_t, gpg_agent_t)
82
296273a7
CP
83# transition from the gpg domain to the helper domain
84domtrans_pattern(gpg_t, gpg_helper_exec_t, gpg_helper_t)
85
86allow gpg_t gpg_secret_t:dir create_dir_perms;
87manage_files_pattern(gpg_t, gpg_secret_t, gpg_secret_t)
88manage_lnk_files_pattern(gpg_t, gpg_secret_t, gpg_secret_t)
89userdom_user_home_dir_filetrans(gpg_t, gpg_secret_t, dir)
90
e4f73afb
CP
91kernel_read_sysctl(gpg_t)
92
857d37e8
CP
93corecmd_exec_shell(gpg_t)
94corecmd_exec_bin(gpg_t)
95
296273a7
CP
96corenet_all_recvfrom_unlabeled(gpg_t)
97corenet_all_recvfrom_netlabel(gpg_t)
668b3093
CP
98corenet_tcp_sendrecv_generic_if(gpg_t)
99corenet_udp_sendrecv_generic_if(gpg_t)
c1262146
CP
100corenet_tcp_sendrecv_generic_node(gpg_t)
101corenet_udp_sendrecv_generic_node(gpg_t)
296273a7
CP
102corenet_tcp_sendrecv_all_ports(gpg_t)
103corenet_udp_sendrecv_all_ports(gpg_t)
104corenet_tcp_connect_all_ports(gpg_t)
105corenet_sendrecv_all_client_packets(gpg_t)
106
107dev_read_rand(gpg_t)
108dev_read_urand(gpg_t)
ca7fa520 109dev_read_generic_usb_dev(gpg_t)
296273a7
CP
110
111fs_getattr_xattr_fs(gpg_t)
857d37e8 112fs_list_inotifyfs(gpg_t)
296273a7
CP
113
114domain_use_interactive_fds(gpg_t)
115
116files_read_etc_files(gpg_t)
117files_read_usr_files(gpg_t)
118files_dontaudit_search_var(gpg_t)
119
e4f73afb
CP
120auth_use_nsswitch(gpg_t)
121
296273a7
CP
122logging_send_syslog_msg(gpg_t)
123
36ded4bd
CP
124miscfiles_read_localization(gpg_t)
125
296273a7 126userdom_use_user_terminals(gpg_t)
36ded4bd
CP
127# sign/encrypt user files
128userdom_manage_user_tmp_files(gpg_t)
129userdom_manage_user_home_content_files(gpg_t)
857d37e8 130userdom_user_home_dir_filetrans_user_home_content(gpg_t, file)
36ded4bd
CP
131
132mta_write_config(gpg_t)
133
134tunable_policy(`use_nfs_home_dirs',`
135 fs_manage_nfs_dirs(gpg_t)
136 fs_manage_nfs_files(gpg_t)
137')
138
139tunable_policy(`use_samba_home_dirs',`
140 fs_manage_cifs_dirs(gpg_t)
141 fs_manage_cifs_files(gpg_t)
142')
143
857d37e8
CP
144optional_policy(`
145 mozilla_read_user_home_files(gpg_t)
146 mozilla_write_user_home_files(gpg_t)
147')
148
36ded4bd
CP
149optional_policy(`
150 xserver_use_xdm_fds(gpg_t)
151 xserver_rw_xdm_pipes(gpg_t)
152')
153
154optional_policy(`
155 cron_system_entry(gpg_t, gpg_exec_t)
156 cron_read_system_job_tmp_files(gpg_t)
157')
296273a7 158
296273a7
CP
159########################################
160#
161# GPG helper local policy
162#
163
e4f73afb
CP
164allow gpg_helper_t self:process { getsched setsched };
165
296273a7 166# for helper programs (which automatically fetch keys)
857d37e8 167# Note: this is only tested with the hkp interface. If you use eg the
296273a7
CP
168# mail interface you will likely need additional permissions.
169
170allow gpg_helper_t self:unix_stream_socket create_stream_socket_perms;
171allow gpg_helper_t self:tcp_socket { connect connected_socket_perms };
172allow gpg_helper_t self:udp_socket { connect connected_socket_perms };
173
174dontaudit gpg_helper_t gpg_secret_t:file read;
175
176corenet_all_recvfrom_unlabeled(gpg_helper_t)
177corenet_all_recvfrom_netlabel(gpg_helper_t)
668b3093
CP
178corenet_tcp_sendrecv_generic_if(gpg_helper_t)
179corenet_raw_sendrecv_generic_if(gpg_helper_t)
180corenet_udp_sendrecv_generic_if(gpg_helper_t)
c1262146
CP
181corenet_tcp_sendrecv_generic_node(gpg_helper_t)
182corenet_udp_sendrecv_generic_node(gpg_helper_t)
183corenet_raw_sendrecv_generic_node(gpg_helper_t)
296273a7
CP
184corenet_tcp_sendrecv_all_ports(gpg_helper_t)
185corenet_udp_sendrecv_all_ports(gpg_helper_t)
c1262146
CP
186corenet_tcp_bind_generic_node(gpg_helper_t)
187corenet_udp_bind_generic_node(gpg_helper_t)
296273a7
CP
188corenet_tcp_connect_all_ports(gpg_helper_t)
189
296273a7 190files_read_etc_files(gpg_helper_t)
296273a7 191
e4f73afb
CP
192auth_use_nsswitch(gpg_helper_t)
193
194userdom_use_user_terminals(gpg_helper_t)
296273a7
CP
195
196tunable_policy(`use_nfs_home_dirs',`
36ded4bd 197 fs_dontaudit_rw_nfs_files(gpg_helper_t)
296273a7
CP
198')
199
200tunable_policy(`use_samba_home_dirs',`
36ded4bd 201 fs_dontaudit_rw_cifs_files(gpg_helper_t)
296273a7
CP
202')
203
204########################################
205#
206# GPG agent local policy
207#
208
209# rlimit: gpg-agent wants to prevent coredumps
210allow gpg_agent_t self:process setrlimit;
211
212allow gpg_agent_t self:unix_stream_socket create_stream_socket_perms ;
213allow gpg_agent_t self:fifo_file rw_fifo_file_perms;
214
215# read and write ~/.gnupg (gpg-agent stores secret keys in ~/.gnupg/private-keys-v1.d )
216manage_dirs_pattern(gpg_agent_t, gpg_secret_t, gpg_secret_t)
217manage_files_pattern(gpg_agent_t, gpg_secret_t, gpg_secret_t)
218manage_lnk_files_pattern(gpg_agent_t, gpg_secret_t, gpg_secret_t)
219
220# Allow the gpg-agent to manage its tmp files (socket)
221manage_dirs_pattern(gpg_agent_t, gpg_agent_tmp_t, gpg_agent_tmp_t)
222manage_files_pattern(gpg_agent_t, gpg_agent_tmp_t, gpg_agent_tmp_t)
223manage_sock_files_pattern(gpg_agent_t, gpg_agent_tmp_t, gpg_agent_tmp_t)
224files_tmp_filetrans(gpg_agent_t, gpg_agent_tmp_t, { file sock_file dir })
225
226# allow gpg to connect to the gpg agent
227stream_connect_pattern(gpg_t, gpg_agent_tmp_t, gpg_agent_tmp_t, gpg_agent_t)
228
a3b0dc5b 229corecmd_read_bin_symlinks(gpg_agent_t)
296273a7 230corecmd_search_bin(gpg_agent_t)
857d37e8 231corecmd_exec_shell(gpg_agent_t)
296273a7 232
a3b0dc5b
CP
233dev_read_urand(gpg_agent_t)
234
296273a7
CP
235domain_use_interactive_fds(gpg_agent_t)
236
a3b0dc5b
CP
237fs_dontaudit_list_inotifyfs(gpg_agent_t)
238
296273a7
CP
239miscfiles_read_localization(gpg_agent_t)
240
241# Write to the user domain tty.
242userdom_use_user_terminals(gpg_agent_t)
243# read and write ~/.gnupg (gpg-agent stores secret keys in ~/.gnupg/private-keys-v1.d )
244userdom_search_user_home_dirs(gpg_agent_t)
245
a3b0dc5b
CP
246ifdef(`hide_broken_symptoms',`
247 userdom_dontaudit_read_user_tmp_files(gpg_agent_t)
248')
249
296273a7
CP
250tunable_policy(`gpg_agent_env_file',`
251 # write ~/.gpg-agent-info or a similar to the users home dir
252 # or subdir (gpg-agent --write-env-file option)
253 #
254 userdom_user_home_dir_filetrans_user_home_content(gpg_agent_t, file)
255 userdom_manage_user_home_content_dirs(gpg_agent_t)
256 userdom_manage_user_home_content_files(gpg_agent_t)
257')
258
259tunable_policy(`use_nfs_home_dirs',`
260 fs_manage_nfs_dirs(gpg_agent_t)
261 fs_manage_nfs_files(gpg_agent_t)
262 fs_manage_nfs_symlinks(gpg_agent_t)
263')
264
265tunable_policy(`use_samba_home_dirs',`
266 fs_manage_cifs_dirs(gpg_agent_t)
267 fs_manage_cifs_files(gpg_agent_t)
268 fs_manage_cifs_symlinks(gpg_agent_t)
269')
270
a3b0dc5b
CP
271optional_policy(`
272 mozilla_dontaudit_rw_user_home_files(gpg_agent_t)
273')
274
296273a7
CP
275##############################
276#
277# Pinentry local policy
278#
279
857d37e8 280allow gpg_pinentry_t self:process { getcap getsched setsched signal };
296273a7 281allow gpg_pinentry_t self:fifo_file rw_fifo_file_perms;
857d37e8
CP
282allow gpg_pinentry_t self:netlink_route_socket create_netlink_socket_perms;
283allow gpg_pinentry_t self:shm create_shm_perms;
284allow gpg_pinentry_t self:tcp_socket create_stream_socket_perms;
285allow gpg_pinentry_t self:unix_dgram_socket sendto;
286allow gpg_pinentry_t self:unix_stream_socket { connect create getattr read shutdown write };
296273a7 287
857d37e8
CP
288can_exec(gpg_pinentry_t, pinentry_exec_t)
289
290# we need to allow gpg-agent to call pinentry so it can get the passphrase
296273a7
CP
291# from the user.
292domtrans_pattern(gpg_agent_t, pinentry_exec_t, gpg_pinentry_t)
293
857d37e8
CP
294manage_sock_files_pattern(gpg_pinentry_t, gpg_pinentry_tmp_t, gpg_pinentry_tmp_t)
295userdom_user_tmp_filetrans(gpg_pinentry_t, gpg_pinentry_tmp_t, sock_file)
296
297manage_dirs_pattern(gpg_pinentry_t, gpg_pinentry_tmpfs_t, gpg_pinentry_tmpfs_t)
298manage_files_pattern(gpg_pinentry_t, gpg_pinentry_tmpfs_t, gpg_pinentry_tmpfs_t)
299fs_tmpfs_filetrans(gpg_pinentry_t, gpg_pinentry_tmpfs_t, { file dir })
857d37e8 300
296273a7
CP
301# read /proc/meminfo
302kernel_read_system_state(gpg_pinentry_t)
303
857d37e8
CP
304corecmd_exec_bin(gpg_pinentry_t)
305
306corenet_all_recvfrom_netlabel(gpg_pinentry_t)
307corenet_all_recvfrom_unlabeled(gpg_pinentry_t)
308corenet_sendrecv_pulseaudio_client_packets(gpg_pinentry_t)
309corenet_tcp_bind_generic_node(gpg_pinentry_t)
310corenet_tcp_connect_pulseaudio_port(gpg_pinentry_t)
311corenet_tcp_sendrecv_generic_if(gpg_pinentry_t)
312corenet_tcp_sendrecv_generic_node(gpg_pinentry_t)
313corenet_tcp_sendrecv_generic_port(gpg_pinentry_t)
314
315dev_read_urand(gpg_pinentry_t)
316dev_read_rand(gpg_pinentry_t)
317
296273a7
CP
318files_read_usr_files(gpg_pinentry_t)
319# read /etc/X11/qtrc
320files_read_etc_files(gpg_pinentry_t)
321
a3b0dc5b
CP
322fs_dontaudit_list_inotifyfs(gpg_pinentry_t)
323fs_getattr_tmpfs(gpg_pinentry_t)
324
325auth_use_nsswitch(gpg_pinentry_t)
326
857d37e8
CP
327logging_send_syslog_msg(gpg_pinentry_t)
328
296273a7
CP
329miscfiles_read_fonts(gpg_pinentry_t)
330miscfiles_read_localization(gpg_pinentry_t)
331
332# for .Xauthority
333userdom_read_user_home_content_files(gpg_pinentry_t)
857d37e8 334userdom_read_user_tmpfs_files(gpg_pinentry_t)
296273a7
CP
335
336tunable_policy(`use_nfs_home_dirs',`
337 fs_read_nfs_files(gpg_pinentry_t)
338')
339
340tunable_policy(`use_samba_home_dirs',`
341 fs_read_cifs_files(gpg_pinentry_t)
342')
343
344optional_policy(`
857d37e8
CP
345 dbus_session_bus_client(gpg_pinentry_t)
346 dbus_system_bus_client(gpg_pinentry_t)
347')
348
349optional_policy(`
350 pulseaudio_exec(gpg_pinentry_t)
a3b0dc5b 351 pulseaudio_rw_home_files(gpg_pinentry_t)
857d37e8
CP
352 pulseaudio_setattr_home_dir(gpg_pinentry_t)
353 pulseaudio_stream_connect(gpg_pinentry_t)
a3b0dc5b 354 pulseaudio_signull(gpg_pinentry_t)
857d37e8
CP
355')
356
357optional_policy(`
358 xserver_user_x_domain_template(gpg_pinentry, gpg_pinentry_t, gpg_pinentry_tmpfs_t)
296273a7 359')