aboutsummaryrefslogtreecommitdiff
blob: 572b84c00571ee910592680743ae8d4f893d18f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
policy_module(dbus)

gen_require(`
	class dbus all_dbus_perms;
')

########################################
#
# Declarations
#

## <desc>
## <p>
## Determine whether the dbus server
## can use the network (insecure
## except than in the case of the
## loopback interface).
## </p>
## </desc>
gen_tunable(dbus_can_network, false)

## <desc>
## <p>
## Allow dbus-daemon system bus to access /dev/net/tun
## which is needed to pass tun/tap device file descriptors
## over D-Bus.  This is needed by openvpn3-linux.
## </p>
## </desc>
gen_tunable(dbus_pass_tuntap_fd, false)

## <desc>
## <p>
## Allow dbus-daemon system bus to to run systemd transient
## units. This is used by dbus-broker for dbus-activated
## services when the unit file for the service does not exist.
## </p>
## </desc>
gen_tunable(dbus_broker_run_transient_units, false)

## <desc>
## <p>
## Enable additional rules to support using dbus-broker
## as the dbus-daemon system bus.
## </p>
## </desc>
gen_tunable(dbus_broker_system_bus, false)

attribute dbusd_unconfined;
attribute session_bus_type;

attribute dbusd_system_bus_client;
attribute dbusd_session_bus_client;

type dbusd_etc_t;
files_config_file(dbusd_etc_t)

type dbusd_exec_t;
corecmd_executable_file(dbusd_exec_t)

type dbusd_unit_t;
init_unit_file(dbusd_unit_t)

type session_dbusd_home_t;
userdom_user_home_content(session_dbusd_home_t)

type session_dbusd_runtime_t;
files_runtime_file(session_dbusd_runtime_t)
userdom_user_runtime_content(session_dbusd_runtime_t)

type session_dbusd_tmp_t;
userdom_user_tmp_file(session_dbusd_tmp_t)

type system_dbusd_t;
init_system_domain(system_dbusd_t, dbusd_exec_t)
init_named_socket_activation(system_dbusd_t, system_dbusd_runtime_t)

type system_dbusd_runtime_t alias system_dbusd_var_run_t;
files_runtime_file(system_dbusd_runtime_t)
init_daemon_runtime_file(system_dbusd_runtime_t, dir, "dbus")
init_mountpoint(system_dbusd_runtime_t)

type system_dbusd_tmp_t;
files_tmp_file(system_dbusd_tmp_t)

type system_dbusd_tmpfs_t;
files_tmpfs_file(system_dbusd_tmpfs_t)

type system_dbusd_var_lib_t;
files_type(system_dbusd_var_lib_t)

ifdef(`enable_mls',`
	init_ranged_system_domain(system_dbusd_t, dbusd_exec_t, s0 - mls_systemhigh)
')

########################################
#
# Local policy
#

allow system_dbusd_t self:capability { dac_override setgid setpcap setuid sys_resource };
# net_admin for changing buffer sizes
dontaudit system_dbusd_t self:capability { net_admin sys_tty_config };
allow system_dbusd_t self:process { getattr getcap getsched setcap setpgid setrlimit signal_perms };
allow system_dbusd_t self:fifo_file rw_fifo_file_perms;
allow system_dbusd_t self:dbus { acquire_svc send_msg };
allow system_dbusd_t self:unix_stream_socket { connectto create_stream_socket_perms };
allow system_dbusd_t self:netlink_selinux_socket { bind create read };

allow system_dbusd_t dbusd_etc_t:dir { list_dir_perms watch };
read_files_pattern(system_dbusd_t, dbusd_etc_t, dbusd_etc_t)
read_lnk_files_pattern(system_dbusd_t, dbusd_etc_t, dbusd_etc_t)

manage_dirs_pattern(system_dbusd_t, system_dbusd_tmp_t, system_dbusd_tmp_t)
manage_files_pattern(system_dbusd_t, system_dbusd_tmp_t, system_dbusd_tmp_t)
files_tmp_filetrans(system_dbusd_t, system_dbusd_tmp_t, { dir file sock_file })

manage_files_pattern(system_dbusd_t, system_dbusd_tmpfs_t, system_dbusd_tmpfs_t)
fs_tmpfs_filetrans(system_dbusd_t, system_dbusd_tmpfs_t, file)
allow system_dbusd_t system_dbusd_tmpfs_t:file map;

read_files_pattern(system_dbusd_t, system_dbusd_var_lib_t, system_dbusd_var_lib_t)

manage_dirs_pattern(system_dbusd_t, system_dbusd_runtime_t, system_dbusd_runtime_t)
manage_files_pattern(system_dbusd_t, system_dbusd_runtime_t, system_dbusd_runtime_t)
manage_sock_files_pattern(system_dbusd_t, system_dbusd_runtime_t, system_dbusd_runtime_t)
files_runtime_filetrans(system_dbusd_t, system_dbusd_runtime_t, { dir file sock_file })

can_exec(system_dbusd_t, dbusd_exec_t)

kernel_read_system_state(system_dbusd_t)
kernel_read_kernel_sysctls(system_dbusd_t)

corecmd_list_bin(system_dbusd_t)
corecmd_read_bin_pipes(system_dbusd_t)
corecmd_read_bin_sockets(system_dbusd_t)
corecmd_exec_shell(system_dbusd_t)

dev_read_urand(system_dbusd_t)
dev_read_sysfs(system_dbusd_t)

domain_use_interactive_fds(system_dbusd_t)
domain_read_all_domains_state(system_dbusd_t)

files_list_home(system_dbusd_t)
files_read_usr_files(system_dbusd_t)
files_watch_usr_dirs(system_dbusd_t)

fs_getattr_all_fs(system_dbusd_t)
fs_list_inotifyfs(system_dbusd_t)
fs_search_auto_mountpoints(system_dbusd_t)
fs_search_cgroup_dirs(system_dbusd_t)
fs_dontaudit_list_nfs(system_dbusd_t)

mls_fd_use_all_levels(system_dbusd_t)
mls_rangetrans_target(system_dbusd_t)
mls_file_read_all_levels(system_dbusd_t)
mls_socket_write_all_levels(system_dbusd_t)
mls_socket_read_to_clearance(system_dbusd_t)
mls_dbus_recv_all_levels(system_dbusd_t)

selinux_get_fs_mount(system_dbusd_t)
selinux_use_status_page(system_dbusd_t)
selinux_validate_context(system_dbusd_t)
selinux_compute_access_vector(system_dbusd_t)
selinux_compute_create_context(system_dbusd_t)
selinux_compute_relabel_context(system_dbusd_t)
selinux_compute_user_contexts(system_dbusd_t)

term_dontaudit_use_console(system_dbusd_t)

auth_use_nsswitch(system_dbusd_t)
auth_read_pam_console_data(system_dbusd_t)

init_use_fds(system_dbusd_t)
init_use_script_ptys(system_dbusd_t)
init_all_labeled_script_domtrans(system_dbusd_t)

# for powerdevil /usr/lib/x86_64-linux-gnu/libexec/kauth/*
libs_exec_lib_files(system_dbusd_t)

logging_send_audit_msgs(system_dbusd_t)
logging_send_syslog_msg(system_dbusd_t)

miscfiles_read_localization(system_dbusd_t)
miscfiles_read_generic_certs(system_dbusd_t)

seutil_read_config(system_dbusd_t)
seutil_read_default_contexts(system_dbusd_t)

# for machinectl shell
term_use_ptmx(system_dbusd_t)

userdom_dontaudit_use_unpriv_user_fds(system_dbusd_t)
userdom_dontaudit_search_user_home_dirs(system_dbusd_t)
# read a file in ~/.local/share
userdom_read_user_home_content_files(system_dbusd_t)

ifdef(`distro_gentoo',`
	optional_policy(`
		cpufreqselector_dbus_chat(system_dbusd_t)
	')
')

ifdef(`init_systemd', `
	# gdm3 causes system_dbusd_t to want this access
	dev_rw_dri(system_dbusd_t)
	dev_rw_input_dev(system_dbusd_t)

	files_read_etc_runtime_files(system_dbusd_t)

	# for /run/systemd/dynamic-uid/
	init_list_runtime(system_dbusd_t)
	init_read_runtime_symlinks(system_dbusd_t)

	init_start_system(system_dbusd_t) # needed by dbus-broker

	# dbus-broker checks the status of systemd-logind
	init_get_generic_units_status(system_dbusd_t)

	# for system dbus daemon to start/stop units
	init_start_all_units(system_dbusd_t)
	init_stop_all_units(system_dbusd_t)

	# Recent versions of dbus are started as Type=notify
	systemd_write_notify_socket(system_dbusd_t)

	tunable_policy(`dbus_broker_system_bus',`
		init_get_system_status(system_dbusd_t)
	')
')

tunable_policy(`dbus_pass_tuntap_fd',`
        corenet_rw_tun_tap_dev(system_dbusd_t)
')

tunable_policy(`dbus_broker_run_transient_units',`
	init_start_transient_units(system_dbusd_t)
	init_stop_transient_units(system_dbusd_t)
')

# the below duplicated tunable blocks are due to
# optionals within tunables not being supported
optional_policy(`
	tunable_policy(`dbus_broker_system_bus',`
		policykit_get_unit_status(system_dbusd_t)
		policykit_start_unit(system_dbusd_t)
		policykit_stop_unit(system_dbusd_t)
		policykit_reload_unit(system_dbusd_t)
	')
')

optional_policy(`
	tunable_policy(`dbus_broker_system_bus',`
		networkmanager_startstop(system_dbusd_t)
		networkmanager_status(system_dbusd_t)
	')
')

optional_policy(`
	# for /run/systemd/users/*
	systemd_read_logind_runtime_files(system_dbusd_t)
	systemd_write_inherited_logind_inhibit_pipes(system_dbusd_t)
	systemd_write_inherited_logind_sessions_pipes(system_dbusd_t)

	systemd_connect_machined(system_dbusd_t)
	# for passing around terminal file handles for machinectl shell
	systemd_use_inherited_machined_ptys(system_dbusd_t)

	# allow populating of /var/lib/dbus by systemd-tmpfilesd
	systemd_tmpfilesd_managed(system_dbusd_var_lib_t)
')

optional_policy(`
	bluetooth_use(system_dbusd_t)
')

optional_policy(`
	policykit_read_lib(system_dbusd_t)
')

optional_policy(`
	seutil_sigchld_newrole(system_dbusd_t)
')

optional_policy(`
	tpm2_rw_abrmd_pipes(system_dbusd_t)
')

optional_policy(`
	unconfined_dbus_send(system_dbusd_t)
')

optional_policy(`
	xserver_read_xdm_lib_files(system_dbusd_t)
	xserver_use_xdm_fds(system_dbusd_t)
')

########################################
#
# Common session bus local policy
#

dontaudit session_bus_type self:capability sys_resource;
allow session_bus_type self:process { getattr sigkill signal };
dontaudit session_bus_type self:process { ptrace setrlimit };
allow session_bus_type self:file rw_inherited_file_perms;
allow session_bus_type self:fifo_file rw_fifo_file_perms;
allow session_bus_type self:dbus { acquire_svc send_msg };
allow session_bus_type self:unix_stream_socket { accept listen };
allow session_bus_type self:netlink_selinux_socket create_socket_perms;

allow session_bus_type dbusd_etc_t:dir list_dir_perms;
read_files_pattern(session_bus_type, dbusd_etc_t, dbusd_etc_t)
read_lnk_files_pattern(session_bus_type, dbusd_etc_t, dbusd_etc_t)
allow session_bus_type dbusd_etc_t:dir watch;

manage_dirs_pattern(session_bus_type, session_dbusd_home_t, session_dbusd_home_t)
manage_files_pattern(session_bus_type, session_dbusd_home_t, session_dbusd_home_t)
userdom_user_home_dir_filetrans(session_bus_type, session_dbusd_home_t, dir, ".dbus")

manage_dirs_pattern(session_bus_type, session_dbusd_tmp_t, session_dbusd_tmp_t)
manage_files_pattern(session_bus_type, session_dbusd_tmp_t, session_dbusd_tmp_t)
manage_sock_files_pattern(session_bus_type, session_dbusd_tmp_t, session_dbusd_tmp_t)
files_tmp_filetrans(session_bus_type, session_dbusd_tmp_t, { dir file sock_file })

manage_dirs_pattern(session_bus_type, session_dbusd_runtime_t, session_dbusd_runtime_t)
manage_files_pattern(session_bus_type, session_dbusd_runtime_t, session_dbusd_runtime_t)
manage_sock_files_pattern(session_bus_type, session_dbusd_runtime_t, session_dbusd_runtime_t)
userdom_user_runtime_filetrans(session_bus_type, session_dbusd_runtime_t, { dir file sock_file })

kernel_read_system_state(session_bus_type)
kernel_read_kernel_sysctls(session_bus_type)

corecmd_list_bin(session_bus_type)
corecmd_read_bin_files(session_bus_type)
corecmd_read_bin_pipes(session_bus_type)
corecmd_read_bin_sockets(session_bus_type)

dev_read_urand(session_bus_type)

domain_read_all_domains_state(session_bus_type)
domain_use_interactive_fds(session_bus_type)

files_list_home(session_bus_type)
files_read_usr_files(session_bus_type)
files_watch_usr_dirs(session_bus_type)
files_dontaudit_search_var(session_bus_type)

fs_getattr_cgroup(session_bus_type)
fs_getattr_romfs(session_bus_type)
fs_getattr_xattr_fs(session_bus_type)
fs_list_inotifyfs(session_bus_type)
fs_dontaudit_list_nfs(session_bus_type)

kernel_getattr_proc(session_bus_type)

selinux_get_fs_mount(session_bus_type)
selinux_validate_context(session_bus_type)
selinux_compute_access_vector(session_bus_type)
selinux_compute_create_context(session_bus_type)
selinux_compute_relabel_context(session_bus_type)
selinux_compute_user_contexts(session_bus_type)

auth_read_pam_console_data(session_bus_type)

logging_send_audit_msgs(session_bus_type)
logging_send_syslog_msg(session_bus_type)

miscfiles_read_localization(session_bus_type)

seutil_read_config(session_bus_type)
seutil_read_default_contexts(session_bus_type)

term_use_all_terms(session_bus_type)

tunable_policy(`dbus_can_network',`
	allow session_bus_type self:tcp_socket { accept listen };

	corenet_all_recvfrom_netlabel(session_bus_type)
	corenet_tcp_sendrecv_generic_if(session_bus_type)
	corenet_tcp_sendrecv_generic_node(session_bus_type)
	corenet_tcp_bind_generic_node(session_bus_type)

	corenet_sendrecv_all_server_packets(session_bus_type)
	corenet_tcp_bind_reserved_port(session_bus_type)
')

optional_policy(`
	xserver_rw_xsession_log(session_bus_type)
	xserver_use_xdm_fds(session_bus_type)
	xserver_rw_xdm_pipes(session_bus_type)
')

########################################
#
# Unconfined access to this module
#

allow dbusd_unconfined { dbusd_session_bus_client dbusd_system_bus_client }:dbus send_msg;
allow dbusd_unconfined { system_dbusd_t session_bus_type }:dbus all_dbus_perms;