summaryrefslogtreecommitdiffstats
path: root/base/selinux/src/pki.if
blob: 5264271eb6c212de8d567b22d4374c1db23661d2 (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

## <summary>policy for pki</summary>

########################################
## <summary>
##	Execute pki_ra server in the pki_ra domain.
## </summary>
## <param name="domain">
##	<summary>
##	The type of the process performing this action.
##	</summary>
## </param>
#
interface(`pki_ra_script_domtrans',`
	gen_require(`
		attribute pki_ra_script;
	')

	init_script_domtrans_spec($1,pki_ra_script)
')

########################################
## <summary>
##	Create a set of derived types for apache
##	web content.
## </summary>
## <param name="prefix">
##	<summary>
##	The prefix to be used for deriving type names.
##	</summary>
## </param>
#
template(`pki_tps_template',`
	gen_require(`
		attribute pki_tps_process;
		attribute pki_tps_config, pki_tps_var_lib, pki_tps_var_run;
		attribute pki_tps_executable, pki_tps_script, pki_tps_var_log;
	')
	########################################
	#
	# Declarations
	#

	type $1_t, pki_tps_process;
	type $1_exec_t, pki_tps_executable;
	domain_type($1_t)
	init_daemon_domain($1_t, $1_exec_t)

	type $1_script_exec_t, pki_tps_script;
	init_script_file($1_script_exec_t)

	type $1_etc_rw_t, pki_tps_config;
	files_type($1_etc_rw_t)

	type $1_var_run_t, pki_tps_var_run;
	files_pid_file($1_var_run_t)

	type $1_var_lib_t, pki_tps_var_lib;
	files_type($1_var_lib_t)

	type $1_log_t, pki_tps_var_log;
	logging_log_file($1_log_t)

	########################################
	#
	# $1 local policy
	#

	## internal communication is often done using fifo and unix sockets.
	allow $1_t self:fifo_file rw_file_perms;
	allow $1_t self:unix_stream_socket create_stream_socket_perms;

	# Init script handling
	domain_use_interactive_fds($1_t)

	files_read_etc_files($1_t)
        allow pki_tps_t pki_tps_etc_rw_t:lnk_file read;

	manage_dirs_pattern($1_t, $1_etc_rw_t, $1_etc_rw_t)
	manage_files_pattern($1_t, $1_etc_rw_t, $1_etc_rw_t)
	files_etc_filetrans($1_t,$1_etc_rw_t, { file dir })

	manage_dirs_pattern($1_t, $1_var_run_t,  $1_var_run_t)
	manage_files_pattern($1_t, $1_var_run_t,  $1_var_run_t)
	files_pid_filetrans($1_t,$1_var_run_t, { file dir })

	manage_dirs_pattern($1_t, $1_var_lib_t,  $1_var_lib_t)
	manage_files_pattern($1_t, $1_var_lib_t,  $1_var_lib_t)
	read_lnk_files_pattern($1_t, $1_var_lib_t, $1_var_lib_t)
	files_var_lib_filetrans($1_t, $1_var_lib_t, { file dir } )

	manage_dirs_pattern($1_t, $1_log_t,  $1_log_t)
	manage_files_pattern($1_t, $1_log_t,  $1_log_t)
	logging_log_filetrans($1_t, $1_log_t, { file dir } )

	init_dontaudit_write_utmp($1_t)

	libs_use_ld_so($1_t)
	libs_use_shared_libs($1_t)

	miscfiles_read_localization($1_t)

	ifdef(`targeted_policy',`
		term_dontaudit_use_unallocated_ttys($1_t)
		term_dontaudit_use_generic_ptys($1_t)
	')

	gen_require(`
		type httpd_t;
                type httpd_exec_t;
                type httpd_suexec_exec_t;
	')

	#============= httpd_t ==============
	allow httpd_t $1_var_run_t:dir search;
	allow httpd_t $1_var_run_t:file read_file_perms;

')

template(`pki_ra_template',`
	gen_require(`
		attribute pki_ra_process;
		attribute pki_ra_config, pki_ra_var_lib, pki_ra_var_run;
		attribute pki_ra_executable, pki_ra_script, pki_ra_var_log;
	')
	########################################
	#
	# Declarations
	#

	type $1_t, pki_ra_process;
	type $1_exec_t, pki_ra_executable;
	domain_type($1_t)
	init_daemon_domain($1_t, $1_exec_t)

	type $1_script_exec_t, pki_ra_script;
	init_script_file($1_script_exec_t)

	type $1_etc_rw_t, pki_ra_config;
	files_type($1_etc_rw_t)

	type $1_var_run_t, pki_ra_var_run;
	files_pid_file($1_var_run_t)

	type $1_var_lib_t, pki_ra_var_lib;
	files_type($1_var_lib_t)

	type $1_log_t, pki_ra_var_log;
	logging_log_file($1_log_t)

	########################################
	#
	# $1 local policy
	#

	## internal communication is often done using fifo and unix sockets.
	allow $1_t self:fifo_file rw_file_perms;
	allow $1_t self:unix_stream_socket create_stream_socket_perms;

	# Init script handling
	domain_use_interactive_fds($1_t)

	files_read_etc_files($1_t)

	manage_dirs_pattern($1_t, $1_etc_rw_t, $1_etc_rw_t)
	manage_files_pattern($1_t, $1_etc_rw_t, $1_etc_rw_t)
	files_etc_filetrans($1_t,$1_etc_rw_t, { file dir })

	manage_dirs_pattern($1_t, $1_var_run_t,  $1_var_run_t)
	manage_files_pattern($1_t, $1_var_run_t,  $1_var_run_t)
	files_pid_filetrans($1_t,$1_var_run_t, { file dir })

	manage_dirs_pattern($1_t, $1_var_lib_t,  $1_var_lib_t)
	manage_files_pattern($1_t, $1_var_lib_t,  $1_var_lib_t)
	read_lnk_files_pattern($1_t, $1_var_lib_t, $1_var_lib_t)
	files_var_lib_filetrans($1_t, $1_var_lib_t, { file dir } )

	manage_dirs_pattern($1_t, $1_log_t,  $1_log_t)
	manage_files_pattern($1_t, $1_log_t,  $1_log_t)
	logging_log_filetrans($1_t, $1_log_t, { file dir } )

	init_dontaudit_write_utmp($1_t)

	libs_use_ld_so($1_t)
	libs_use_shared_libs($1_t)

	miscfiles_read_localization($1_t)

	ifdef(`targeted_policy',`
		term_dontaudit_use_unallocated_ttys($1_t)
		term_dontaudit_use_generic_ptys($1_t)
	')

	gen_require(`
		type httpd_t;
                type devlog_t;
                type syslogd_t;
                type httpd_exec_t;
                type httpd_suexec_exec_t;
	')

	#============= httpd_t ==============
	allow httpd_t $1_var_run_t:dir search;
	allow httpd_t $1_var_run_t:file read_file_perms;
')

########################################
## <summary>
##	All of the rules required to administrate 
##	an pki_ra environment
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
########################################
## <summary>
##	All of the rules required to administrate 
##	an pki_ra environment
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
## <param name="role">
##	<summary>
##	The role to be allowed to manage the syslog domain.
##	</summary>
## </param>
## <param name="terminal">
##	<summary>
##	The type of the user terminal.
##	</summary>
## </param>
## <rolecap/>
#
interface(`pki_ra_admin',`
	gen_require(`
		attribute pki_ra_process;
		attribute pki_ra_config;
		attribute pki_ra_executable;
		attribute pki_ra_var_lib;
		attribute pki_ra_var_log;
		attribute pki_ra_var_run;
		attribute pki_ra_script;
	')

	allow $1 pki_ra_process:process { ptrace signal_perms };
	ps_process_pattern($1, pki_ra_t)

	# Allow pki_ra_t to restart the service
	pki_ra_script_domtrans($1)
	domain_system_change_exemption($1)
	role_transition $2 pki_ra_script system_r;
	allow $2 system_r;

	manage_all_pattern($1, pki_ra_config)
	manage_all_pattern($1, pki_ra_var_run)
	manage_all_pattern($1, pki_ra_var_lib)
	manage_all_pattern($1, pki_ra_var_log)
	manage_all_pattern($1, pki_ra_config)
')

########################################
## <summary>
##	Execute pki_tps server in the pki_tps domain.
## </summary>
## <param name="domain">
##	<summary>
##	The type of the process performing this action.
##	</summary>
## </param>
#
interface(`pki_tps_script_domtrans',`
	gen_require(`
		attribute pki_tps_script;
	')

	init_script_domtrans_spec($1,pki_tps_script)
')


########################################
## <summary>
##	All of the rules required to administrate 
##	an pki_tps environment
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
## <param name="role">
##	<summary>
##	The role to be allowed to manage the syslog domain.
##	</summary>
## </param>
## <param name="terminal">
##	<summary>
##	The type of the user terminal.
##	</summary>
## </param>
## <rolecap/>
#
interface(`pki_tps_admin',`
	gen_require(`
		attribute pki_tps_process;
		attribute pki_tps_config;
		attribute pki_tps_executable;
		attribute pki_tps_var_lib;
		attribute pki_tps_var_log;
		attribute pki_tps_var_run;
		attribute pki_tps_script;
	')

	allow $1 pki_tps_process:process { ptrace signal_perms };
	ps_process_pattern($1, pki_tps_t)

	# Allow pki_tps_t to restart the service
	pki_tps_script_domtrans($1)
	domain_system_change_exemption($1)
	role_transition $2 pki_tps_script system_r;
	allow $2 system_r;

	manage_all_pattern($1, pki_tps_config)
	manage_all_pattern($1, pki_tps_var_run)
	manage_all_pattern($1, pki_tps_var_lib)
	manage_all_pattern($1, pki_tps_var_log)
	manage_all_pattern($1, pki_tps_config)
')