aboutsummaryrefslogtreecommitdiff
blob: 0b9a8143fb4221c65795651b5fd6bae23ea2f6b3 (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
policy_module(locallogin, 1.19.0)

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

type local_login_t;
domain_interactive_fd(local_login_t)
auth_login_pgm_domain(local_login_t)
auth_login_entry_type(local_login_t)

type local_login_lock_t;
files_lock_file(local_login_lock_t)

type local_login_tmp_t;
files_tmp_file(local_login_tmp_t)
files_poly_parent(local_login_tmp_t)

type sulogin_t;
type sulogin_exec_t;
domain_obj_id_change_exemption(sulogin_t)
domain_subj_id_change_exemption(sulogin_t)
domain_role_change_exemption(sulogin_t)
domain_interactive_fd(sulogin_t)
init_domain(sulogin_t, sulogin_exec_t)
init_system_domain(sulogin_t, sulogin_exec_t)
role system_r types sulogin_t;

########################################
#
# Local login local policy
#

allow local_login_t self:capability { chown dac_read_search dac_override fowner fsetid kill setgid setuid sys_nice sys_resource sys_tty_config };
dontaudit local_login_t self:capability net_admin;
allow local_login_t self:process { getcap setcap setexec setrlimit setsched };
allow local_login_t self:fd use;
allow local_login_t self:fifo_file rw_fifo_file_perms;
allow local_login_t self:sock_file read_sock_file_perms;
allow local_login_t self:unix_dgram_socket create_socket_perms;
allow local_login_t self:unix_stream_socket create_stream_socket_perms;
allow local_login_t self:unix_dgram_socket sendto;
allow local_login_t self:unix_stream_socket connectto;
allow local_login_t self:shm create_shm_perms;
allow local_login_t self:sem create_sem_perms;
allow local_login_t self:msgq create_msgq_perms;
allow local_login_t self:msg { send receive };
allow local_login_t self:key { search write link };

allow local_login_t local_login_lock_t:file manage_file_perms;
files_lock_filetrans(local_login_t, local_login_lock_t, file)

allow local_login_t local_login_tmp_t:dir manage_dir_perms;
allow local_login_t local_login_tmp_t:file manage_file_perms;
files_tmp_filetrans(local_login_t, local_login_tmp_t, { file dir })

kernel_read_system_state(local_login_t)
kernel_read_kernel_sysctls(local_login_t)
kernel_search_key(local_login_t)
kernel_link_key(local_login_t)

corecmd_list_bin(local_login_t)
# cjp: these are probably not needed:
corecmd_read_bin_files(local_login_t)
corecmd_read_bin_pipes(local_login_t)
corecmd_read_bin_sockets(local_login_t)

dev_setattr_mouse_dev(local_login_t)
dev_getattr_mouse_dev(local_login_t)
dev_getattr_power_mgmt_dev(local_login_t)
dev_setattr_power_mgmt_dev(local_login_t)
dev_getattr_sound_dev(local_login_t)
dev_setattr_sound_dev(local_login_t)
dev_dontaudit_getattr_acpi_bios_dev(local_login_t)
dev_dontaudit_setattr_acpi_bios_dev(local_login_t)
dev_dontaudit_read_framebuffer(local_login_t)
dev_dontaudit_setattr_framebuffer_dev(local_login_t)
dev_dontaudit_getattr_generic_blk_files(local_login_t)
dev_dontaudit_setattr_generic_blk_files(local_login_t)
dev_dontaudit_getattr_generic_chr_files(local_login_t)
dev_dontaudit_setattr_generic_chr_files(local_login_t)
dev_dontaudit_setattr_generic_symlinks(local_login_t)
dev_dontaudit_getattr_misc_dev(local_login_t)
dev_dontaudit_setattr_misc_dev(local_login_t)
dev_dontaudit_getattr_scanner_dev(local_login_t)
dev_dontaudit_setattr_scanner_dev(local_login_t)
dev_dontaudit_search_sysfs(local_login_t)
dev_dontaudit_getattr_video_dev(local_login_t)
dev_dontaudit_setattr_video_dev(local_login_t)

domain_read_all_entry_files(local_login_t)

files_read_etc_files(local_login_t)
files_read_etc_runtime_files(local_login_t)
files_read_usr_files(local_login_t)
files_list_mnt(local_login_t)
files_list_world_readable(local_login_t)
files_read_world_readable_files(local_login_t)
files_read_world_readable_symlinks(local_login_t)
files_read_world_readable_pipes(local_login_t)
files_read_world_readable_sockets(local_login_t)
# for when /var/mail is a symlink
files_read_var_symlinks(local_login_t)

fs_search_auto_mountpoints(local_login_t)

storage_dontaudit_getattr_fixed_disk_dev(local_login_t)
storage_dontaudit_setattr_fixed_disk_dev(local_login_t)
storage_dontaudit_getattr_removable_dev(local_login_t)
storage_dontaudit_setattr_removable_dev(local_login_t)

term_use_all_ttys(local_login_t)
term_use_unallocated_ttys(local_login_t)
term_relabel_unallocated_ttys(local_login_t)
term_relabel_all_ttys(local_login_t)
term_setattr_all_ttys(local_login_t)
term_setattr_unallocated_ttys(local_login_t)

auth_rw_login_records(local_login_t)
auth_rw_faillog(local_login_t)
auth_manage_pam_pid(local_login_t)
auth_manage_pam_console_data(local_login_t)
auth_domtrans_pam_console(local_login_t)

init_dontaudit_use_fds(local_login_t)

miscfiles_read_localization(local_login_t)

userdom_manage_all_users_keys(local_login_t)
userdom_spec_domtrans_all_users(local_login_t)
userdom_signal_all_users(local_login_t)
userdom_search_user_home_content(local_login_t)
userdom_use_unpriv_users_fds(local_login_t)
userdom_sigchld_all_users(local_login_t)
userdom_create_all_users_keys(local_login_t)

ifdef(`init_systemd',`
	auth_manage_faillog(local_login_t)

	init_dbus_chat(local_login_t)
	systemd_dbus_chat_logind(local_login_t)
	systemd_use_logind_fds(local_login_t)
	systemd_manage_logind_pid_pipes(local_login_t)
')

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

tunable_policy(`console_login',`
	# Able to relabel /dev/console to user tty types.
	term_relabel_console(local_login_t)
')

tunable_policy(`use_nfs_home_dirs',`
	fs_read_nfs_files(local_login_t)
	fs_read_nfs_symlinks(local_login_t)
')

tunable_policy(`use_samba_home_dirs',`
	fs_read_cifs_files(local_login_t)
	fs_read_cifs_symlinks(local_login_t)
')

optional_policy(`
	alsa_domtrans(local_login_t)
')

optional_policy(`
	dbus_system_bus_client(local_login_t)

	optional_policy(`
		consolekit_dbus_chat(local_login_t)
	')
')

optional_policy(`
	gpm_getattr_gpmctl(local_login_t)
	gpm_setattr_gpmctl(local_login_t)
')

optional_policy(`
	# Search for mail spool file.
	mta_getattr_spool(local_login_t)
')

optional_policy(`
	nis_use_ypbind(local_login_t)
')

optional_policy(`
	nscd_use(local_login_t)
')

optional_policy(`
	systemd_dbus_chat_logind(local_login_t)
	systemd_write_inherited_logind_sessions_pipes(local_login_t)
')

optional_policy(`
	unconfined_shell_domtrans(local_login_t)
')

optional_policy(`
	usermanage_read_crack_db(local_login_t)
')

optional_policy(`
	xserver_link_xdm_keys(local_login_t)
	xserver_read_xdm_tmp_files(local_login_t)
	xserver_rw_xdm_tmp_files(local_login_t)
	xserver_rw_xdm_keys(local_login_t)
')

#################################
#
# Sulogin local policy
#

allow sulogin_t self:capability { dac_read_search sys_admin sys_tty_config };
dontaudit sulogin_t self:capability dac_override;
allow sulogin_t self:process setexec;
allow sulogin_t self:fd use;
allow sulogin_t self:fifo_file rw_fifo_file_perms;
allow sulogin_t self:unix_dgram_socket create_socket_perms;
allow sulogin_t self:unix_stream_socket create_stream_socket_perms;
allow sulogin_t self:unix_dgram_socket sendto;
allow sulogin_t self:unix_stream_socket connectto;
allow sulogin_t self:shm create_shm_perms;
allow sulogin_t self:sem create_sem_perms;
allow sulogin_t self:msgq create_msgq_perms;
allow sulogin_t self:msg { send receive };

kernel_read_system_state(sulogin_t)
kernel_read_crypto_sysctls(sulogin_t)
kernel_stream_connect(sulogin_t)
kernel_use_fds(sulogin_t)
# because file systems are not mounted:
kernel_dontaudit_search_unlabeled(sulogin_t)

fs_search_auto_mountpoints(sulogin_t)
fs_rw_tmpfs_chr_files(sulogin_t)

files_read_etc_files(sulogin_t)

term_use_console(sulogin_t)
term_use_unallocated_ttys(sulogin_t)

auth_read_shadow(sulogin_t)

init_getpgid(sulogin_t)
init_getpgid_script(sulogin_t)

logging_send_syslog_msg(sulogin_t)

miscfiles_read_localization(sulogin_t)

seutil_read_config(sulogin_t)
seutil_read_default_contexts(sulogin_t)

userdom_use_unpriv_users_fds(sulogin_t)

userdom_search_user_home_dirs(sulogin_t)
userdom_use_user_ptys(sulogin_t)

sysadm_shell_domtrans(sulogin_t)

# by default, sulogin does not use pam...
# sulogin_pam might need to be defined otherwise
ifdef(`sulogin_pam', `
	selinux_get_fs_mount(sulogin_t)
	selinux_validate_context(sulogin_t)
	selinux_compute_access_vector(sulogin_t)
	selinux_compute_create_context(sulogin_t)
	selinux_compute_relabel_context(sulogin_t)
	selinux_compute_user_contexts(sulogin_t)
')

optional_policy(`
	nis_use_ypbind(sulogin_t)
')

optional_policy(`
	nscd_use(sulogin_t)
')

ifdef(`distro_gentoo',`

	# Enable polyinstantiation of directories
	tunable_policy(`allow_polyinstantiation',`
		# Execute /etc/security/namespace.init
		corecmd_exec_bin(local_login_t)
	')

	optional_policy(`
		cgmanager_stream_connect(local_login_t)
	')
')