forked from OwlCyberDefense/refpolicy-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrhcs.if
496 lines (431 loc) · 10.5 KB
/
rhcs.if
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
## <summary>Red Hat Cluster Suite.</summary>
#######################################
## <summary>
## The template to define a rhcs domain.
## </summary>
## <param name="domain_prefix">
## <summary>
## Domain prefix to be used.
## </summary>
## </param>
#
template(`rhcs_domain_template',`
gen_require(`
attribute cluster_domain, cluster_pid, cluster_tmpfs;
attribute cluster_log;
')
##############################
#
# Declarations
#
type $1_t, cluster_domain;
type $1_exec_t;
init_daemon_domain($1_t, $1_exec_t)
type $1_tmpfs_t, cluster_tmpfs;
files_tmpfs_file($1_tmpfs_t)
type $1_var_log_t, cluster_log;
logging_log_file($1_var_log_t)
type $1_var_run_t, cluster_pid;
files_pid_file($1_var_run_t)
##############################
#
# Local policy
#
manage_dirs_pattern($1_t, $1_tmpfs_t, $1_tmpfs_t)
manage_files_pattern($1_t, $1_tmpfs_t, $1_tmpfs_t)
fs_tmpfs_filetrans($1_t, $1_tmpfs_t, { dir file })
manage_dirs_pattern($1_t, $1_var_log_t, $1_var_log_t)
append_files_pattern($1_t, $1_var_log_t, $1_var_log_t)
create_files_pattern($1_t, $1_var_log_t, $1_var_log_t)
setattr_files_pattern($1_t, $1_var_log_t, $1_var_log_t)
manage_sock_files_pattern($1_t, $1_var_log_t, $1_var_log_t)
logging_log_filetrans($1_t, $1_var_log_t, { dir file sock_file })
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)
manage_fifo_files_pattern($1_t, $1_var_run_t, $1_var_run_t)
manage_sock_files_pattern($1_t, $1_var_run_t, $1_var_run_t)
files_pid_filetrans($1_t, $1_var_run_t, { dir file sock_file fifo_file })
optional_policy(`
dbus_system_bus_client($1_t)
')
')
######################################
## <summary>
## Execute a domain transition to
## run dlm_controld.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
#
interface(`rhcs_domtrans_dlm_controld',`
gen_require(`
type dlm_controld_t, dlm_controld_exec_t;
')
corecmd_search_bin($1)
domtrans_pattern($1, dlm_controld_exec_t, dlm_controld_t)
')
#####################################
## <summary>
## Get attributes of fenced
## executable files.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_getattr_fenced_exec_files',`
gen_require(`
type fenced_exec_t;
')
allow $1 fenced_exec_t:file getattr_file_perms;
')
#####################################
## <summary>
## Connect to dlm_controld with a
## unix domain stream socket.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_stream_connect_dlm_controld',`
gen_require(`
type dlm_controld_t, dlm_controld_var_run_t;
')
files_search_pids($1)
stream_connect_pattern($1, dlm_controld_var_run_t, dlm_controld_var_run_t, dlm_controld_t)
')
#####################################
## <summary>
## Read and write dlm_controld semaphores.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_rw_dlm_controld_semaphores',`
gen_require(`
type dlm_controld_t, dlm_controld_tmpfs_t;
')
allow $1 dlm_controld_t:sem { rw_sem_perms destroy };
fs_search_tmpfs($1)
manage_files_pattern($1, dlm_controld_tmpfs_t, dlm_controld_tmpfs_t)
')
######################################
## <summary>
## Execute a domain transition to run fenced.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
#
interface(`rhcs_domtrans_fenced',`
gen_require(`
type fenced_t, fenced_exec_t;
')
corecmd_search_bin($1)
domtrans_pattern($1, fenced_exec_t, fenced_t)
')
######################################
## <summary>
## Read and write fenced semaphores.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_rw_fenced_semaphores',`
gen_require(`
type fenced_t, fenced_tmpfs_t;
')
allow $1 fenced_t:sem { rw_sem_perms destroy };
fs_search_tmpfs($1)
manage_files_pattern($1, fenced_tmpfs_t, fenced_tmpfs_t)
')
####################################
## <summary>
## Connect to all cluster domains
## with a unix domain stream socket.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_stream_connect_cluster',`
gen_require(`
attribute cluster_domain, cluster_pid;
')
files_search_pids($1)
stream_connect_pattern($1, cluster_pid, cluster_pid, cluster_domain)
')
######################################
## <summary>
## Connect to fenced with an unix
## domain stream socket.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_stream_connect_fenced',`
gen_require(`
type fenced_var_run_t, fenced_t;
')
files_search_pids($1)
stream_connect_pattern($1, fenced_var_run_t, fenced_var_run_t, fenced_t)
')
#####################################
## <summary>
## Execute a domain transition
## to run gfs_controld.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
#
interface(`rhcs_domtrans_gfs_controld',`
gen_require(`
type gfs_controld_t, gfs_controld_exec_t;
')
corecmd_search_bin($1)
domtrans_pattern($1, gfs_controld_exec_t, gfs_controld_t)
')
####################################
## <summary>
## Read and write gfs_controld semaphores.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_rw_gfs_controld_semaphores',`
gen_require(`
type gfs_controld_t, gfs_controld_tmpfs_t;
')
allow $1 gfs_controld_t:sem { rw_sem_perms destroy };
fs_search_tmpfs($1)
manage_files_pattern($1, gfs_controld_tmpfs_t, gfs_controld_tmpfs_t)
')
########################################
## <summary>
## Read and write gfs_controld_t shared memory.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_rw_gfs_controld_shm',`
gen_require(`
type gfs_controld_t, gfs_controld_tmpfs_t;
')
allow $1 gfs_controld_t:shm { rw_shm_perms destroy };
fs_search_tmpfs($1)
manage_files_pattern($1, gfs_controld_tmpfs_t, gfs_controld_tmpfs_t)
')
#####################################
## <summary>
## Connect to gfs_controld_t with
## a unix domain stream socket.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_stream_connect_gfs_controld',`
gen_require(`
type gfs_controld_t, gfs_controld_var_run_t;
')
files_search_pids($1)
stream_connect_pattern($1, gfs_controld_var_run_t, gfs_controld_var_run_t, gfs_controld_t)
')
######################################
## <summary>
## Execute a domain transition to run groupd.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
#
interface(`rhcs_domtrans_groupd',`
gen_require(`
type groupd_t, groupd_exec_t;
')
corecmd_search_bin($1)
domtrans_pattern($1, groupd_exec_t, groupd_t)
')
#####################################
## <summary>
## Connect to groupd with a unix
## domain stream socket.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_stream_connect_groupd',`
gen_require(`
type groupd_t, groupd_var_run_t;
')
files_search_pids($1)
stream_connect_pattern($1, groupd_var_run_t, groupd_var_run_t, groupd_t)
')
########################################
## <summary>
## Read and write all cluster domains
## shared memory.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_rw_cluster_shm',`
gen_require(`
attribute cluster_domain, cluster_tmpfs;
')
allow $1 cluster_domain:shm { rw_shm_perms destroy };
fs_search_tmpfs($1)
manage_files_pattern($1, cluster_tmpfs, cluster_tmpfs)
')
####################################
## <summary>
## Read and write all cluster
## domains semaphores.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_rw_cluster_semaphores',`
gen_require(`
attribute cluster_domain;
')
allow $1 cluster_domain:sem { rw_sem_perms destroy };
')
#####################################
## <summary>
## Read and write groupd semaphores.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_rw_groupd_semaphores',`
gen_require(`
type groupd_t, groupd_tmpfs_t;
')
allow $1 groupd_t:sem { rw_sem_perms destroy };
fs_search_tmpfs($1)
manage_files_pattern($1, groupd_tmpfs_t, groupd_tmpfs_t)
')
########################################
## <summary>
## Read and write groupd shared memory.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`rhcs_rw_groupd_shm',`
gen_require(`
type groupd_t, groupd_tmpfs_t;
')
allow $1 groupd_t:shm { rw_shm_perms destroy };
fs_search_tmpfs($1)
manage_files_pattern($1, groupd_tmpfs_t, groupd_tmpfs_t)
')
######################################
## <summary>
## Execute a domain transition to run qdiskd.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
#
interface(`rhcs_domtrans_qdiskd',`
gen_require(`
type qdiskd_t, qdiskd_exec_t;
')
corecmd_search_bin($1)
domtrans_pattern($1, qdiskd_exec_t, qdiskd_t)
')
########################################
## <summary>
## All of the rules required to
## administrate an rhcs environment.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
## <param name="role">
## <summary>
## Role allowed access.
## </summary>
## </param>
## <rolecap/>
#
interface(`rhcs_admin',`
gen_require(`
attribute cluster_domain, cluster_pid, cluster_tmpfs;
attribute cluster_log;
type dlm_controld_initrc_exec_t, foghorn_initrc_exec_t, fenced_lock_t;
type fenced_tmp_t, qdiskd_var_lib_t;
type dlm_controld_t, foghorn_t;
')
allow $1 cluster_domain:process { ptrace signal_perms };
ps_process_pattern($1, cluster_domain)
init_startstop_service($1, $2, dlm_controld_t, dlm_controld_initrc_exec_t)
init_startstop_service($1, $2, foghorn_t, foghorn_initrc_exec_t)
files_search_pids($1)
admin_pattern($1, cluster_pid)
files_search_locks($1)
admin_pattern($1, fenced_lock_t)
files_search_tmp($1)
admin_pattern($1, fenced_tmp_t)
files_search_var_lib($1)
admin_pattern($1, qdiskd_var_lib_t)
fs_search_tmpfs($1)
admin_pattern($1, cluster_tmpfs)
logging_search_logs($1)
admin_pattern($1, cluster_log)
')