aboutsummaryrefslogtreecommitdiff
blob: 7ead10a368ff6375b38d693f7637e45bcf9f0a20 (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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
policy_module(selinuxutil, 1.24.5)

gen_require(`
	bool secure_mode;
')

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

attribute can_write_binary_policy;
attribute can_relabelto_binary_policy;

attribute_role newrole_roles;

attribute_role run_init_roles;
role system_r types run_init_t;

attribute_role semanage_roles;
roleattribute system_r semanage_roles;

#
# selinux_config_t is the type applied to
# /etc/selinux/config
#
# cjp: this is out of order due to rules
# in the domain_type interface
# (fix dup decl)
type selinux_config_t;
files_security_file(selinux_config_t)

type checkpolicy_t, can_write_binary_policy;
type checkpolicy_exec_t;
application_domain(checkpolicy_t, checkpolicy_exec_t)
role system_r types checkpolicy_t;

#
# default_context_t is the type applied to
# /etc/selinux/*/contexts/*
#
type default_context_t;
files_security_file(default_context_t)

#
# file_context_t is the type applied to
# /etc/selinux/*/contexts/files
#
type file_context_t;
files_security_file(file_context_t)

type load_policy_t;
type load_policy_exec_t;
application_domain(load_policy_t, load_policy_exec_t)
role system_r types load_policy_t;

type newrole_t;
type newrole_exec_t;
application_domain(newrole_t, newrole_exec_t)
domain_role_change_exemption(newrole_t)
domain_obj_id_change_exemption(newrole_t)
domain_interactive_fd(newrole_t)
role newrole_roles types newrole_t;

#
# policy_config_t is the type of /etc/security/selinux/*
# the security server policy configuration.
#
type policy_config_t;
files_security_file(policy_config_t)

neverallow ~can_relabelto_binary_policy policy_config_t:file relabelto;
#neverallow ~can_write_binary_policy policy_config_t:file { write append };

#
# policy_src_t is the type of the policy source
# files.
#
type policy_src_t;
files_type(policy_src_t)

type restorecond_t;
type restorecond_exec_t;
init_daemon_domain(restorecond_t, restorecond_exec_t)
domain_obj_id_change_exemption(restorecond_t)
role system_r types restorecond_t;

type restorecond_unit_t;
init_unit_file(restorecond_unit_t)

type restorecond_run_t;
typealias restorecond_run_t alias restorecond_var_run_t;
files_pid_file(restorecond_run_t)

type run_init_t;
type run_init_exec_t;
application_domain(run_init_t, run_init_exec_t)
domain_system_change_exemption(run_init_t)
role run_init_roles types run_init_t;

type semanage_t;
type semanage_exec_t;
application_domain(semanage_t, semanage_exec_t)
domain_interactive_fd(semanage_t)
role semanage_roles types semanage_t;

type semanage_store_t alias semanage_var_lib_t;
files_type(semanage_store_t)

type semanage_read_lock_t;
files_type(semanage_read_lock_t)

type semanage_tmp_t;
files_tmp_file(semanage_tmp_t)

type semanage_trans_lock_t;
files_type(semanage_trans_lock_t)

type setfiles_t alias restorecon_t, can_relabelto_binary_policy;
type setfiles_exec_t alias restorecon_exec_t;
init_system_domain(setfiles_t, setfiles_exec_t)
domain_obj_id_change_exemption(setfiles_t)

########################################
#
# Checkpolicy local policy
#

allow checkpolicy_t self:capability dac_override;

# able to create and modify binary policy files
manage_files_pattern(checkpolicy_t, policy_config_t, policy_config_t)

# allow test policies to be created in src directories
filetrans_add_pattern(checkpolicy_t, policy_src_t, policy_config_t, file)

# only allow read of policy source files
read_files_pattern(checkpolicy_t, policy_src_t, policy_src_t)
read_lnk_files_pattern(checkpolicy_t, policy_src_t, policy_src_t)
allow checkpolicy_t selinux_config_t:dir search_dir_perms;

domain_use_interactive_fds(checkpolicy_t)

files_list_usr(checkpolicy_t)
# directory search permissions for path to source and binary policy files
files_search_etc(checkpolicy_t)

fs_getattr_xattr_fs(checkpolicy_t)

term_use_console(checkpolicy_t)

init_use_fds(checkpolicy_t)
init_use_script_ptys(checkpolicy_t)

userdom_use_user_terminals(checkpolicy_t)
userdom_use_all_users_fds(checkpolicy_t)

ifdef(`distro_ubuntu',`
	optional_policy(`
		unconfined_domain(checkpolicy_t)
	')
')

########################################
#
# Load_policy local policy
#

allow load_policy_t self:capability dac_override;

# only allow read of policy config files
read_files_pattern(load_policy_t, { policy_src_t policy_config_t }, policy_config_t)
allow load_policy_t policy_config_t:file map;

dev_read_urand(load_policy_t)

domain_use_interactive_fds(load_policy_t)

# for mcs.conf
files_read_etc_files(load_policy_t)
files_read_etc_runtime_files(load_policy_t)

fs_getattr_xattr_fs(load_policy_t)

mls_file_read_all_levels(load_policy_t)

selinux_load_policy(load_policy_t)
selinux_set_all_booleans(load_policy_t)

term_use_console(load_policy_t)
term_list_ptys(load_policy_t)

init_use_script_fds(load_policy_t)
init_use_script_ptys(load_policy_t)

miscfiles_read_localization(load_policy_t)

seutil_libselinux_linked(load_policy_t)

userdom_use_user_terminals(load_policy_t)
userdom_use_all_users_fds(load_policy_t)

ifdef(`distro_ubuntu',`
	optional_policy(`
		unconfined_domain(load_policy_t)
	')
')

ifdef(`hide_broken_symptoms',`
	# cjp: cover up stray file descriptors.
	dontaudit load_policy_t selinux_config_t:file write;

	optional_policy(`
		unconfined_dontaudit_read_pipes(load_policy_t)
	')
')

optional_policy(`
	portage_dontaudit_use_fds(load_policy_t)
')

########################################
#
# Newrole local policy
#

dontaudit newrole_t self:capability net_admin;
allow newrole_t self:capability { dac_override fowner setgid setuid };
allow newrole_t self:process setexec;
allow newrole_t self:fd use;
allow newrole_t self:fifo_file rw_fifo_file_perms;
allow newrole_t self:sock_file read_sock_file_perms;
allow newrole_t self:shm create_shm_perms;
allow newrole_t self:sem create_sem_perms;
allow newrole_t self:msgq create_msgq_perms;
allow newrole_t self:msg { send receive };
allow newrole_t self:unix_dgram_socket sendto;
allow newrole_t self:unix_stream_socket { create_stream_socket_perms connectto };
allow newrole_t self:netlink_audit_socket { create_netlink_socket_perms nlmsg_relay };

dontaudit newrole_t self:capability dac_read_search;

read_files_pattern(newrole_t, default_context_t, default_context_t)
read_lnk_files_pattern(newrole_t, default_context_t, default_context_t)

kernel_read_system_state(newrole_t)
kernel_read_kernel_sysctls(newrole_t)

corecmd_list_bin(newrole_t)

dev_read_urand(newrole_t)

domain_use_interactive_fds(newrole_t)
# for when the user types "exec newrole" at the command line:
domain_sigchld_interactive_fds(newrole_t)

files_read_etc_files(newrole_t)
files_read_var_files(newrole_t)
files_read_var_symlinks(newrole_t)

fs_getattr_xattr_fs(newrole_t)
fs_search_auto_mountpoints(newrole_t)

mls_file_read_all_levels(newrole_t)
mls_file_write_all_levels(newrole_t)
mls_file_upgrade(newrole_t)
mls_file_downgrade(newrole_t)
mls_process_set_level(newrole_t)
mls_fd_share_all_levels(newrole_t)

selinux_validate_context(newrole_t)
selinux_compute_access_vector(newrole_t)
selinux_compute_create_context(newrole_t)
selinux_compute_relabel_context(newrole_t)
selinux_compute_user_contexts(newrole_t)

term_use_all_ttys(newrole_t)
term_use_all_ptys(newrole_t)
term_relabel_all_ttys(newrole_t)
term_relabel_all_ptys(newrole_t)
term_getattr_unallocated_ttys(newrole_t)
term_dontaudit_use_unallocated_ttys(newrole_t)

auth_use_nsswitch(newrole_t)
auth_run_chk_passwd(newrole_t, newrole_roles)
auth_run_upd_passwd(newrole_t, newrole_roles)
auth_rw_faillog(newrole_t)

# Write to utmp.
init_rw_utmp(newrole_t)
init_use_fds(newrole_t)

logging_send_syslog_msg(newrole_t)

miscfiles_read_localization(newrole_t)

seutil_libselinux_linked(newrole_t)

# for some PAM modules and for cwd
userdom_dontaudit_search_user_home_content(newrole_t)
userdom_search_user_home_dirs(newrole_t)

ifdef(`distro_ubuntu',`
	optional_policy(`
		unconfined_domain(newrole_t)
	')
')

ifdef(`init_systemd',`
	optional_policy(`
		systemd_use_logind_fds(newrole_t)
		systemd_dbus_chat_logind(newrole_t)
	')
')

optional_policy(`
	auth_use_pam_systemd(newrole_t)
')

optional_policy(`
	dbus_system_bus_client(newrole_t)

	optional_policy(`
		consolekit_dbus_chat(newrole_t)
	')
')

# if secure mode is enabled, then newrole
# can only transition to unprivileged users
if(secure_mode) {
	userdom_spec_domtrans_unpriv_users(newrole_t)
} else {
	userdom_spec_domtrans_all_users(newrole_t)
}

tunable_policy(`allow_polyinstantiation',`
	files_polyinstantiate_all(newrole_t)
')

optional_policy(`
	systemd_use_logind_fds(newrole_t)
')

########################################
#
# Restorecond local policy
#

allow restorecond_t self:capability { dac_override dac_read_search fowner };
allow restorecond_t self:fifo_file rw_fifo_file_perms;

allow restorecond_t restorecond_run_t:file manage_file_perms;
files_pid_filetrans(restorecond_t, restorecond_run_t, file)

kernel_getattr_debugfs(restorecond_t)
kernel_read_system_state(restorecond_t)
kernel_rw_pipes(restorecond_t)
kernel_use_fds(restorecond_t)

fs_dontaudit_list_nfs(restorecond_t)
fs_getattr_all_xattr_fs(restorecond_t)
fs_getattr_cgroup(restorecond_t)
fs_getattr_pstore_dirs(restorecond_t)
fs_getattr_tracefs(restorecond_t)
fs_list_inotifyfs(restorecond_t)
fs_relabelfrom_noxattr_fs(restorecond_t)
fs_getattr_pstorefs(restorecond_t)

selinux_validate_context(restorecond_t)
selinux_compute_access_vector(restorecond_t)
selinux_compute_create_context(restorecond_t)
selinux_compute_relabel_context(restorecond_t)
selinux_compute_user_contexts(restorecond_t)

files_relabel_non_auth_files(restorecond_t )
files_read_non_auth_files(restorecond_t)
files_dontaudit_read_all_symlinks(restorecond_t)
auth_use_nsswitch(restorecond_t)

logging_send_syslog_msg(restorecond_t)

miscfiles_read_localization(restorecond_t)

seutil_libselinux_linked(restorecond_t)

ifdef(`distro_ubuntu',`
	optional_policy(`
		unconfined_domain(restorecond_t)
	')
')

optional_policy(`
	locallogin_dontaudit_use_fds(restorecond_t)
')

optional_policy(`
	rpm_use_script_fds(restorecond_t)
')

#################################
#
# Run_init local policy
#

allow run_init_roles system_r;

allow run_init_t self:process setexec;
allow run_init_t self:capability setuid;
allow run_init_t self:fifo_file rw_file_perms;
allow run_init_t self:netlink_audit_socket { create_netlink_socket_perms nlmsg_relay };

# often the administrator runs such programs from a directory that is owned
# by a different user or has restrictive SE permissions, do not want to audit
# the failed access to the current directory
dontaudit run_init_t self:capability { dac_override dac_read_search };

corecmd_exec_bin(run_init_t)
corecmd_exec_shell(run_init_t)

dev_dontaudit_list_all_dev_nodes(run_init_t)

domain_use_interactive_fds(run_init_t)

files_read_etc_files(run_init_t)
files_dontaudit_search_all_dirs(run_init_t)

fs_getattr_xattr_fs(run_init_t)

mls_rangetrans_source(run_init_t)

selinux_validate_context(run_init_t)
selinux_compute_access_vector(run_init_t)
selinux_compute_create_context(run_init_t)
selinux_compute_relabel_context(run_init_t)
selinux_compute_user_contexts(run_init_t)

auth_use_nsswitch(run_init_t)
auth_run_chk_passwd(run_init_t, run_init_roles)
auth_run_upd_passwd(run_init_t, run_init_roles)
auth_dontaudit_read_shadow(run_init_t)

init_spec_domtrans_script(run_init_t)
# for utmp
init_rw_utmp(run_init_t)

logging_send_syslog_msg(run_init_t)

miscfiles_read_localization(run_init_t)

seutil_libselinux_linked(run_init_t)
seutil_read_default_contexts(run_init_t)

userdom_use_user_terminals(run_init_t)

ifndef(`direct_sysadm_daemon',`
	ifdef(`distro_gentoo',`
		# Gentoo integrated run_init:
		# Bug 554514
		init_read_all_script_files(run_init_t)	
		init_script_file_entry_type(run_init_t)

		init_exec_rc(run_init_t)
	')
')

ifdef(`distro_ubuntu',`
	optional_policy(`
		unconfined_domain(run_init_t)
	')
')

optional_policy(`
	daemontools_domtrans_start(run_init_t)
')

########################################
#
# semodule local policy
#

allow semanage_t self:capability { audit_write dac_override };
allow semanage_t self:unix_stream_socket create_stream_socket_perms;
allow semanage_t self:unix_dgram_socket create_socket_perms;
allow semanage_t self:netlink_audit_socket { create_netlink_socket_perms nlmsg_relay };
allow semanage_t self:fifo_file rw_fifo_file_perms;

allow semanage_t policy_config_t:file rw_file_perms;

allow semanage_t policy_src_t:dir search;

filetrans_pattern(semanage_t, selinux_config_t, semanage_store_t, dir, "modules")

allow semanage_t semanage_tmp_t:dir manage_dir_perms;
allow semanage_t semanage_tmp_t:file { manage_file_perms mmap_exec_file_perms };
files_tmp_filetrans(semanage_t, semanage_tmp_t, { file dir })

kernel_read_system_state(semanage_t)
kernel_read_kernel_sysctls(semanage_t)

corecmd_exec_bin(semanage_t)
corecmd_exec_shell(semanage_t)

dev_read_urand(semanage_t)

domain_use_interactive_fds(semanage_t)

files_read_etc_files(semanage_t)
files_read_etc_runtime_files(semanage_t)
files_map_usr_files(semanage_t)
files_read_usr_files(semanage_t)
files_list_pids(semanage_t)

mls_file_write_all_levels(semanage_t)
mls_file_read_all_levels(semanage_t)

selinux_validate_context(semanage_t)
selinux_get_enforce_mode(semanage_t)
selinux_getattr_fs(semanage_t)
# for setsebool:
selinux_set_all_booleans(semanage_t)

term_use_all_terms(semanage_t)

# Running genhomedircon requires this for finding all users
auth_use_nsswitch(semanage_t)

logging_send_syslog_msg(semanage_t)

miscfiles_read_localization(semanage_t)

seutil_libselinux_linked(semanage_t)
seutil_manage_file_contexts(semanage_t)
seutil_manage_config(semanage_t)
seutil_run_setfiles(semanage_t, semanage_roles)
seutil_run_loadpolicy(semanage_t, semanage_roles)
seutil_manage_bin_policy(semanage_t)
seutil_use_newrole_fds(semanage_t)
seutil_manage_module_store(semanage_t)
seutil_get_semanage_trans_lock(semanage_t)
seutil_get_semanage_read_lock(semanage_t)
# netfilter_contexts:
seutil_manage_default_contexts(semanage_t)

# Handle pp files created in homedir and /tmp
userdom_read_user_home_content_files(semanage_t)
userdom_map_user_home_content_files(semanage_t)
userdom_read_user_tmp_files(semanage_t)
userdom_map_user_tmp_files(semanage_t)

ifdef(`distro_debian',`
	files_read_var_lib_files(semanage_t)
	files_read_var_lib_symlinks(semanage_t)
')

ifdef(`distro_ubuntu',`
	optional_policy(`
		unconfined_domain(semanage_t)
	')
')

optional_policy(`
	portage_eselect_module(semanage_t)
')

ifdef(`init_systemd',`
	optional_policy(`
		init_dbus_chat(semanage_t)
		dbus_system_bus_client(semanage_t)
	')
')

optional_policy(`
	locallogin_use_fds(semanage_t)
')

########################################
#
# Setfiles local policy
#

allow setfiles_t self:capability { dac_override dac_read_search fowner };
dontaudit setfiles_t self:capability sys_tty_config;
allow setfiles_t self:fifo_file rw_file_perms;

allow setfiles_t { policy_src_t policy_config_t file_context_t default_context_t }:dir list_dir_perms;
allow setfiles_t { policy_src_t policy_config_t file_context_t default_context_t }:file read_file_perms;
allow setfiles_t { policy_src_t policy_config_t file_context_t default_context_t }:lnk_file { read_lnk_file_perms ioctl lock };
allow setfiles_t file_context_t:file map;

kernel_read_system_state(setfiles_t)
kernel_relabelfrom_unlabeled_dirs(setfiles_t)
kernel_relabelfrom_unlabeled_files(setfiles_t)
kernel_relabelfrom_unlabeled_symlinks(setfiles_t)
kernel_relabelfrom_unlabeled_pipes(setfiles_t)
kernel_relabelfrom_unlabeled_sockets(setfiles_t)
kernel_use_fds(setfiles_t)
kernel_rw_pipes(setfiles_t)
kernel_rw_unix_dgram_sockets(setfiles_t)
kernel_dontaudit_list_all_proc(setfiles_t)
kernel_dontaudit_list_all_sysctls(setfiles_t)
kernel_getattr_debugfs(setfiles_t)

dev_read_urand(setfiles_t)
dev_relabel_all_dev_nodes(setfiles_t)
# to handle when /dev/console needs to be relabeled
dev_rw_generic_chr_files(setfiles_t)

domain_use_interactive_fds(setfiles_t)
domain_dontaudit_search_all_domains_state(setfiles_t)

files_read_etc_runtime_files(setfiles_t)
files_read_etc_files(setfiles_t)
files_list_all(setfiles_t)
files_relabel_all_files(setfiles_t)
files_read_usr_symlinks(setfiles_t)
files_dontaudit_read_all_symlinks(setfiles_t)

fs_getattr_all_xattr_fs(setfiles_t)
fs_getattr_cgroup(setfiles_t)
fs_getattr_nfs(setfiles_t)
fs_getattr_pstore_dirs(setfiles_t)
fs_getattr_pstorefs(setfiles_t)
fs_getattr_tracefs(setfiles_t)
fs_getattr_tracefs_files(setfiles_t)
fs_list_all(setfiles_t)
fs_relabelfrom_noxattr_fs(setfiles_t)
fs_search_auto_mountpoints(setfiles_t)

mls_file_read_all_levels(setfiles_t)
mls_file_write_all_levels(setfiles_t)
mls_file_upgrade(setfiles_t)
mls_file_downgrade(setfiles_t)

selinux_validate_context(setfiles_t)
selinux_compute_access_vector(setfiles_t)
selinux_compute_create_context(setfiles_t)
selinux_compute_relabel_context(setfiles_t)
selinux_compute_user_contexts(setfiles_t)

term_use_all_ttys(setfiles_t)
term_use_all_ptys(setfiles_t)
term_use_unallocated_ttys(setfiles_t)

# this is to satisfy the assertion:
auth_relabelto_shadow(setfiles_t)

init_use_fds(setfiles_t)
init_use_script_fds(setfiles_t)
init_use_script_ptys(setfiles_t)
init_exec_script_files(setfiles_t)

logging_send_audit_msgs(setfiles_t)
logging_send_syslog_msg(setfiles_t)

miscfiles_read_localization(setfiles_t)

seutil_libselinux_linked(setfiles_t)
seutil_read_module_store(setfiles_t)

userdom_use_all_users_fds(setfiles_t)
# for config files in a home directory
userdom_read_user_home_content_files(setfiles_t)

ifdef(`distro_debian',`
	# udev tmpfs is populated with static device nodes
	# and then relabeled afterwards; thus
	# /dev/console has the tmpfs type
	fs_rw_tmpfs_chr_files(setfiles_t)
')

ifdef(`distro_redhat', `
	fs_rw_tmpfs_chr_files(setfiles_t)
	fs_rw_tmpfs_blk_files(setfiles_t)
	fs_relabel_tmpfs_blk_file(setfiles_t)
	fs_relabel_tmpfs_chr_file(setfiles_t)
')

ifdef(`distro_ubuntu',`
	optional_policy(`
		unconfined_domain(setfiles_t)
	')
')

ifdef(`hide_broken_symptoms',`
	optional_policy(`
		udev_dontaudit_rw_dgram_sockets(setfiles_t)
	')

	# cjp: cover up stray file descriptors.
	optional_policy(`
		unconfined_dontaudit_read_pipes(setfiles_t)
		unconfined_dontaudit_rw_tcp_sockets(setfiles_t)
	')
')

optional_policy(`
	apt_use_fds(setfiles_t)
')

optional_policy(`
	hotplug_use_fds(setfiles_t)
')

ifdef(`distro_gentoo',`
	###########################################
	#
	# setfiles local policy
	#
	gen_require(`
		class passwd { passwd chfn chsh rootok };
	')

	# Needed to support pam_rootok.so even with integrated run_init support in openrc
	allow run_init_t self:passwd { passwd rootok };

	# Fix bug #512676
	allow run_init_t self:process signal;
	allow run_init_t self:netlink_selinux_socket { create bind };

	# Needed to support openrc with USE="-pam"
	# TODO can we make this optional? is this a bad thing?
	auth_read_shadow(run_init_t)

	# Denials upon loading policy
	fs_getattr_tmpfs(setfiles_t)
	dev_getattr_fs(setfiles_t)
	term_getattr_pty_fs(setfiles_t)

	files_read_all_symlinks(setfiles_t)

	########################################
	#
	# restorecond local policy
	#

	# Moved out of files_relabel_non_auth_files as it cannot be used in tunable_policy otherwise
	seutil_relabelto_bin_policy(restorecond_t)

	##########################################
	#
	# semanage local policy
	#

	# Fix bug #541990 - Grant setfscreate privilege to allow semanage_migrate_store to work properly
	allow semanage_t self:process { setfscreate };
')