summaryrefslogtreecommitdiff
path: root/zabbix.te
blob: 4ff1bb74e6c2ad5743615564d1a18a14ed8ea64b (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
policy_module(zabbix, 1.7.0)

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

## <desc>
##  <p>
##	Determine whether zabbix can
##	connect to all TCP ports
##	</p>
## </desc>
gen_tunable(zabbix_can_network, false)


## <desc>
## <p>
## Allow Zabbix to run su/sudo.
## </p>
## </desc>
gen_tunable(zabbix_run_sudo, false)

gen_require(`
    class passwd rootok;
    class passwd passwd;
')

attribute zabbix_domain;

type zabbix_t, zabbix_domain;
type zabbix_exec_t;
init_daemon_domain(zabbix_t, zabbix_exec_t)

type zabbix_initrc_exec_t;
init_script_file(zabbix_initrc_exec_t)

type zabbix_agent_t, zabbix_domain;
type zabbix_agent_exec_t;
init_daemon_domain(zabbix_agent_t, zabbix_agent_exec_t)

type zabbix_agent_initrc_exec_t;
init_script_file(zabbix_agent_initrc_exec_t)

type zabbixd_var_lib_t;
files_type(zabbixd_var_lib_t)

type zabbix_log_t;
logging_log_file(zabbix_log_t)

type zabbix_tmp_t;
files_tmp_file(zabbix_tmp_t)

type zabbix_tmpfs_t;
files_tmpfs_file(zabbix_tmpfs_t)

type zabbix_var_lib_t;
files_type(zabbix_var_lib_t)

type zabbix_var_run_t;
files_pid_file(zabbix_var_run_t)

type zabbix_script_t;
type zabbix_script_exec_t;
domain_type(zabbix_script_t)
domain_entry_file(zabbix_script_t, zabbix_script_exec_t)
application_executable_file(zabbix_script_exec_t)
role system_r types zabbix_script_t;

########################################
#
# zabbix domain local policy
#

allow zabbix_domain self:capability { setgid setuid };
allow zabbix_domain self:process { getsched setpgid setsched signal_perms };
allow zabbix_domain self:fifo_file rw_fifo_file_perms;
allow zabbix_domain self:sem create_sem_perms;
allow zabbix_domain self:shm create_shm_perms;
allow zabbix_domain self:tcp_socket { accept listen };
allow zabbix_domain self:unix_stream_socket create_stream_socket_perms;

kernel_read_all_sysctls(zabbix_domain)
kernel_read_network_state(zabbix_domain)

corenet_tcp_sendrecv_generic_if(zabbix_domain)
corenet_tcp_sendrecv_generic_node(zabbix_domain)
corenet_tcp_bind_generic_node(zabbix_domain)

corecmd_exec_shell(zabbix_domain)
corecmd_exec_bin(zabbix_domain)

dev_read_sysfs(zabbix_domain)
dev_read_urand(zabbix_domain)

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

allow zabbix_t self:capability { dac_read_search  };
allow zabbix_t self:process { setrlimit };
allow zabbix_t self:unix_stream_socket connectto;

manage_dirs_pattern(zabbix_t, zabbix_var_lib_t, zabbix_var_lib_t)
manage_files_pattern(zabbix_t, zabbix_var_lib_t, zabbix_var_lib_t)
manage_lnk_files_pattern(zabbix_t, zabbix_var_lib_t, zabbix_var_lib_t)
manage_sock_files_pattern(zabbix_t, zabbix_var_lib_t, zabbix_var_lib_t)
files_var_lib_filetrans(zabbix_t, zabbix_var_lib_t, dir, "zabbixsrv")

manage_dirs_pattern(zabbix_t, zabbix_log_t, zabbix_log_t)
manage_files_pattern(zabbix_t, zabbix_log_t, zabbix_log_t)
manage_lnk_files_pattern(zabbix_t, zabbix_log_t, zabbix_log_t)
logging_log_filetrans(zabbix_t, zabbix_log_t, { dir file })

manage_dirs_pattern(zabbix_t, zabbix_tmp_t, zabbix_tmp_t)
manage_files_pattern(zabbix_t, zabbix_tmp_t, zabbix_tmp_t)
manage_sock_files_pattern(zabbix_t, zabbix_tmp_t, zabbix_tmp_t)
files_tmp_filetrans(zabbix_t, zabbix_tmp_t, { dir file sock_file })

rw_files_pattern(zabbix_t, zabbix_tmpfs_t, zabbix_tmpfs_t)
fs_tmpfs_filetrans(zabbix_t, zabbix_tmpfs_t, file)

manage_dirs_pattern(zabbix_t, zabbix_var_run_t, zabbix_var_run_t)
manage_files_pattern(zabbix_t, zabbix_var_run_t, zabbix_var_run_t)
manage_sock_files_pattern(zabbix_t, zabbix_var_run_t, zabbix_var_run_t)
files_pid_filetrans(zabbix_t, zabbix_var_run_t, { dir file sock_file })

kernel_read_system_state(zabbix_t)

corenet_all_recvfrom_unlabeled(zabbix_t)
corenet_all_recvfrom_netlabel(zabbix_t)

corenet_sendrecv_ftp_client_packets(zabbix_t)
corenet_tcp_connect_ftp_port(zabbix_t)
corenet_tcp_sendrecv_ftp_port(zabbix_t)

corenet_sendrecv_http_client_packets(zabbix_t)
corenet_tcp_connect_http_port(zabbix_t)
corenet_tcp_sendrecv_http_port(zabbix_t)
corenet_tcp_connect_smtp_port(zabbix_t)

corenet_sendrecv_zabbix_server_packets(zabbix_t)
corenet_tcp_bind_zabbix_port(zabbix_t)
corenet_tcp_sendrecv_zabbix_port(zabbix_t)

auth_use_nsswitch(zabbix_t)

zabbix_agent_tcp_connect(zabbix_t)

logging_send_syslog_msg(zabbix_t)

tunable_policy(`zabbix_can_network',`
	corenet_sendrecv_all_client_packets(zabbix_t)
	corenet_tcp_connect_all_ports(zabbix_t)
	corenet_tcp_sendrecv_all_ports(zabbix_t)
')

tunable_policy(`zabbix_run_sudo',`
    allow zabbix_t self:capability { setgid setuid sys_resource };
    allow zabbix_t self:process { setrlimit setsched };
    allow zabbix_t self:key write;
    allow zabbix_t self:passwd { passwd rootok };

    auth_rw_lastlog(zabbix_t)
    auth_rw_faillog(zabbix_t)
    auth_exec_chkpwd(zabbix_t)

    selinux_compute_access_vector(zabbix_t)

    systemd_write_inherited_logind_sessions_pipes(zabbix_t)
    systemd_dbus_chat_logind(zabbix_t)

    xserver_exec_xauth(zabbix_t)
')

optional_policy(`
    tunable_policy(`zabbix_run_sudo',`
        sudo_exec(zabbix_t)
        su_exec(zabbix_t)
    ')
')

optional_policy(`
	mysql_stream_connect(zabbix_t)
')

optional_policy(`
	netutils_domtrans_ping(zabbix_t)
')

optional_policy(`
	postgresql_stream_connect(zabbix_t)
	postgresql_tcp_connect(zabbix_t)
')

optional_policy(`
	snmp_read_snmp_var_lib_files(zabbix_t)
	snmp_read_snmp_var_lib_dirs(zabbix_t)
')

########################################
#
# Agent local policy
#

allow zabbix_agent_t self:process { setrlimit };

manage_files_pattern(zabbix_agent_t, zabbix_log_t, zabbix_log_t)

rw_files_pattern(zabbix_agent_t, zabbix_tmpfs_t, zabbix_tmpfs_t)
fs_tmpfs_filetrans(zabbix_agent_t, zabbix_tmpfs_t, file)

manage_files_pattern(zabbix_agent_t, zabbix_var_run_t, zabbix_var_run_t)
files_pid_filetrans(zabbix_agent_t, zabbix_var_run_t, file)

kernel_read_system_state(zabbix_agent_t)
kernel_read_network_state(zabbix_agent_t)

corenet_all_recvfrom_unlabeled(zabbix_agent_t)
corenet_all_recvfrom_netlabel(zabbix_agent_t)

corecmd_read_all_executables(zabbix_agent_t)

corenet_sendrecv_zabbix_agent_server_packets(zabbix_agent_t)
corenet_tcp_bind_zabbix_agent_port(zabbix_agent_t)
corenet_tcp_sendrecv_zabbix_agent_port(zabbix_agent_t)

corenet_sendrecv_ssh_client_packets(zabbix_agent_t)
corenet_tcp_connect_ssh_port(zabbix_agent_t)
corenet_tcp_sendrecv_ssh_port(zabbix_agent_t)

corenet_sendrecv_ftp_client_packets(zabbix_agent_t)
corenet_tcp_connect_ftp_port(zabbix_agent_t)
corenet_tcp_sendrecv_ftp_port(zabbix_agent_t)

corenet_sendrecv_http_client_packets(zabbix_agent_t)
corenet_tcp_connect_http_port(zabbix_agent_t)
corenet_tcp_sendrecv_http_port(zabbix_agent_t)

corenet_sendrecv_innd_client_packets(zabbix_agent_t)
corenet_tcp_connect_innd_port(zabbix_agent_t)
corenet_tcp_sendrecv_innd_port(zabbix_agent_t)

corenet_sendrecv_pop_client_packets(zabbix_agent_t)
corenet_tcp_connect_pop_port(zabbix_agent_t)
corenet_tcp_sendrecv_pop_port(zabbix_agent_t)

corenet_sendrecv_postgresql_client_packets(zabbix_agent_t)
corenet_tcp_connect_postgresql_port(zabbix_agent_t)
corenet_tcp_sendrecv_postgresql_port(zabbix_agent_t)

corenet_sendrecv_smtp_client_packets(zabbix_agent_t)
corenet_tcp_connect_smtp_port(zabbix_agent_t)
corenet_tcp_sendrecv_smtp_port(zabbix_agent_t)

corenet_sendrecv_zabbix_client_packets(zabbix_agent_t)
corenet_tcp_connect_zabbix_port(zabbix_agent_t)
corenet_tcp_sendrecv_zabbix_port(zabbix_agent_t)

corenet_tcp_connect_redis_port(zabbix_agent_t)
corenet_tcp_sendrecv_redis_port(zabbix_agent_t)

dev_getattr_all_blk_files(zabbix_agent_t)
dev_getattr_all_chr_files(zabbix_agent_t)

domain_read_all_domains_state(zabbix_agent_t)

files_getattr_all_dirs(zabbix_agent_t)
files_getattr_all_files(zabbix_agent_t)
files_read_all_symlinks(zabbix_agent_t)

fs_getattr_all_fs(zabbix_agent_t)

auth_use_nsswitch(zabbix_agent_t)

init_read_utmp(zabbix_agent_t)

logging_search_logs(zabbix_agent_t)

sysnet_dns_name_resolve(zabbix_agent_t)

zabbix_tcp_connect(zabbix_agent_t)

zabbix_script_domtrans(zabbix_agent_t)

# These are triggered by vfs.dev.discovery enumerating everyting in /dev
gen_require(`
    type devlog_t;
')
dontaudit zabbix_agent_t devlog_t:sock_file getattr;
init_dontaudit_getattr_initctl(zabbix_agent_t)
kernel_dontaudit_getattr_core_if(zabbix_agent_t)

gen_require(`
    type kernel_t, sudo_log_t;
')
tunable_policy(`zabbix_run_sudo',`
    allow zabbix_agent_t self:capability { chown dac_read_search setgid setuid sys_resource };
    allow zabbix_agent_t self:process { setrlimit setsched };
    allow zabbix_agent_t self:key write;
    allow zabbix_agent_t self:passwd { passwd rootok };

    allow zabbix_agent_t sudo_log_t:dir { add_name create setattr write };
    allow zabbix_agent_t sudo_log_t:file { create open read setattr write };

    allow zabbix_agent_t devlog_t:sock_file write;
    allow zabbix_agent_t kernel_t:unix_dgram_socket sendto;
    allow zabbix_agent_t self:unix_dgram_socket { connect create };

    auth_domtrans_chkpwd(zabbix_agent_t)
    auth_rw_lastlog(zabbix_agent_t)
    auth_rw_faillog(zabbix_agent_t)

    logging_send_audit_msgs(zabbix_agent_t)

    selinux_compute_access_vector(zabbix_agent_t)

    sssd_read_config(zabbix_agent_t)

    systemd_write_inherited_logind_sessions_pipes(zabbix_agent_t)
    systemd_dbus_chat_logind(zabbix_agent_t)

    xserver_exec_xauth(zabbix_agent_t)

    # Conceivably this could be under a separate boolean, but the reason to allow sudo
    # is to allow check like this
    lvm_domtrans(zabbix_agent_t)
')

optional_policy(`
    rpm_exec(zabbix_agent_t)
    rpm_read_db(zabbix_agent_t)
')

optional_policy(`
    tunable_policy(`zabbix_run_sudo',`
        sudo_exec(zabbix_agent_t)
        su_exec(zabbix_agent_t)
    ')
')

optional_policy(`
	dmidecode_domtrans(zabbix_agent_t)
')

optional_policy(`
	hostname_exec(zabbix_agent_t)
')

########################################
#
# zabbix_script_t local policy
#

domtrans_pattern(zabbix_t, zabbix_script_exec_t, zabbix_script_t)

allow zabbix_t zabbix_script_exec_t:dir list_dir_perms;
allow zabbix_t zabbix_script_exec_t:file ioctl;
allow zabbix_t zabbix_script_t:process signal;

init_domtrans_script(zabbix_script_t)

optional_policy(`
	chronyd_domtrans_chronyc(zabbix_script_t)
')

optional_policy(`
    mta_send_mail(zabbix_script_t)
')

optional_policy(`
    unconfined_domain(zabbix_script_t)
')