summaryrefslogtreecommitdiff
path: root/policy/modules/services/clamav.te
blob: 14f06d6b67768307ed18317d8ead27d4341de8b0 (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

policy_module(clamav,1.0.4)

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

# Main clamd domain
type clamd_t;
type clamd_exec_t;
init_daemon_domain(clamd_t, clamd_exec_t)

# configuration files
type clamd_etc_t;
files_type(clamd_etc_t)

# named socket type
type clamd_sock_t;
files_type(clamd_sock_t)

# tmp files
type clamd_tmp_t;
files_tmp_file(clamd_tmp_t)

# log files
type clamd_var_log_t;
logging_log_file(clamd_var_log_t)

# var/lib files
type clamd_var_lib_t;
files_type(clamd_var_lib_t)

# pid files
type clamd_var_run_t;
files_pid_file(clamd_var_run_t)

type clamscan_t;
type clamscan_exec_t;
init_daemon_domain(clamscan_t, clamscan_exec_t)

# tmp files
type clamscan_tmp_t;
files_tmp_file(clamscan_tmp_t)

type freshclam_t;
type freshclam_exec_t;
init_daemon_domain(freshclam_t, freshclam_exec_t)

# log files
type freshclam_var_log_t;
logging_log_file(freshclam_var_log_t)

########################################
#
# clamd local policy
#

allow clamd_t self:capability { kill setgid setuid dac_override };
allow clamd_t self:fifo_file rw_file_perms;
allow clamd_t self:unix_stream_socket create_stream_socket_perms;
allow clamd_t self:unix_dgram_socket create_socket_perms;
allow clamd_t self:tcp_socket { listen accept };

# configuration files
allow clamd_t clamd_etc_t:dir r_dir_perms;
allow clamd_t clamd_etc_t:file r_file_perms;
allow clamd_t clamd_etc_t:lnk_file { getattr read };

# socket file
allow clamd_t clamd_sock_t:file manage_file_perms;
allow clamd_t clamd_sock_t:sock_file manage_file_perms;
allow clamd_t clamd_sock_t:dir rw_dir_perms;
files_pid_filetrans(clamd_t,clamd_sock_t,sock_file)

# tmp files
allow clamd_t clamd_tmp_t:file create_file_perms;
allow clamd_t clamd_tmp_t:dir create_dir_perms;
files_tmp_filetrans(clamd_t,clamd_tmp_t,{ file dir })

# var/lib files for clamd
allow clamd_t clamd_var_lib_t:file create_file_perms;
allow clamd_t clamd_var_lib_t:sock_file create_file_perms;
allow clamd_t clamd_var_lib_t:dir create_dir_perms;
files_var_filetrans(clamd_t,clamd_var_lib_t,{ file dir sock_file })
files_var_lib_filetrans(clamd_t,clamd_var_lib_t,file)

# log files
allow clamd_t clamd_var_log_t:file create_file_perms;
allow clamd_t clamd_var_log_t:sock_file create_file_perms;
allow clamd_t clamd_var_log_t:dir { rw_dir_perms setattr };
logging_log_filetrans(clamd_t,clamd_var_log_t,file)

# pid file
allow clamd_t clamd_var_run_t:file manage_file_perms;
allow clamd_t clamd_var_run_t:sock_file manage_file_perms;
allow clamd_t clamd_var_run_t:dir rw_dir_perms;
files_pid_filetrans(clamd_t,clamd_var_run_t,file)

kernel_dontaudit_list_proc(clamd_t)

corenet_non_ipsec_sendrecv(clamd_t)
corenet_tcp_sendrecv_all_if(clamd_t)
corenet_tcp_sendrecv_all_nodes(clamd_t)
corenet_tcp_sendrecv_all_ports(clamd_t)
corenet_tcp_sendrecv_clamd_port(clamd_t)
corenet_tcp_bind_all_nodes(clamd_t)
corenet_tcp_bind_clamd_port(clamd_t)
corenet_sendrecv_clamd_server_packets(clamd_t)

dev_read_rand(clamd_t)
dev_read_urand(clamd_t)

domain_use_interactive_fds(clamd_t)

files_read_etc_files(clamd_t)
files_read_etc_runtime_files(clamd_t)
files_search_spool(clamd_t)

init_use_fds(clamd_t)
init_use_script_ptys(clamd_t)

libs_use_ld_so(clamd_t)
libs_use_shared_libs(clamd_t)

logging_send_syslog_msg(clamd_t)

miscfiles_read_localization(clamd_t)

sysnet_dns_name_resolve(clamd_t)

cron_use_fds(clamd_t)
cron_use_system_job_fds(clamd_t)
cron_rw_pipes(clamd_t)

ifdef(`targeted_policy',`
	term_dontaudit_use_generic_ptys(clamd_t)
')

optional_policy(`
	amavis_read_lib_files(clamd_t)
	amavis_read_spool_files(clamd_t)
	amavis_spool_filetrans(clamd_t,clamd_var_run_t,sock_file)
')

########################################
#
# Freshclam local policy
#

allow freshclam_t self:capability { setgid setuid dac_override };
allow freshclam_t self:fifo_file rw_file_perms;
allow freshclam_t self:unix_stream_socket create_stream_socket_perms;
allow freshclam_t self:unix_dgram_socket create_socket_perms;
allow freshclam_t self:tcp_socket { listen accept };

# configuration files
allow freshclam_t clamd_etc_t:dir r_dir_perms;
allow freshclam_t clamd_etc_t:file r_file_perms;
allow freshclam_t clamd_etc_t:lnk_file { getattr read };

# var/lib files together with clamd
allow freshclam_t clamd_var_lib_t:file create_file_perms;
allow freshclam_t clamd_var_lib_t:sock_file create_file_perms;
allow freshclam_t clamd_var_lib_t:dir create_dir_perms;
files_var_filetrans(freshclam_t,clamd_var_lib_t,{ file dir sock_file })
files_var_lib_filetrans(freshclam_t,clamd_var_lib_t,file)

# pidfiles- var/run together with clamd
allow freshclam_t clamd_var_run_t:file manage_file_perms;
allow freshclam_t clamd_var_run_t:sock_file manage_file_perms;
allow freshclam_t clamd_var_run_t:dir rw_dir_perms;
files_pid_filetrans(freshclam_t,clamd_var_run_t,file)

# log files (own logfiles only)
allow freshclam_t freshclam_var_log_t:file create_file_perms;
allow freshclam_t freshclam_var_log_t:sock_file create_file_perms;
allow freshclam_t freshclam_var_log_t:dir { rw_dir_perms setattr };
allow freshclam_t clamd_var_log_t:dir search;
logging_log_filetrans(freshclam_t,freshclam_var_log_t,file)

corenet_non_ipsec_sendrecv(freshclam_t)
corenet_tcp_sendrecv_all_if(freshclam_t)
corenet_tcp_sendrecv_all_nodes(freshclam_t)
corenet_tcp_sendrecv_all_ports(freshclam_t)
corenet_tcp_sendrecv_clamd_port(freshclam_t)
corenet_tcp_connect_http_port(freshclam_t)
corenet_sendrecv_http_client_packets(freshclam_t)

dev_read_rand(freshclam_t)
dev_read_urand(freshclam_t)

domain_use_interactive_fds(freshclam_t)

files_read_etc_files(freshclam_t)
files_read_etc_runtime_files(freshclam_t)

init_use_fds(freshclam_t)
init_use_script_ptys(freshclam_t)

libs_use_ld_so(freshclam_t)
libs_use_shared_libs(freshclam_t)

miscfiles_read_localization(freshclam_t)

sysnet_dns_name_resolve(freshclam_t)

clamav_stream_connect(freshclam_t)

cron_use_fds(freshclam_t)
cron_use_system_job_fds(freshclam_t)
cron_rw_pipes(freshclam_t)

########################################
#
# clamscam local policy
#

allow clamscan_t self:capability { setgid setuid dac_override };
allow clamscan_t self:fifo_file rw_file_perms;
allow clamscan_t self:unix_stream_socket create_stream_socket_perms;
allow clamscan_t self:unix_dgram_socket create_socket_perms;
allow clamscan_t self:tcp_socket { listen accept };

# configuration files
allow clamscan_t clamd_etc_t:dir r_dir_perms;
allow clamscan_t clamd_etc_t:file r_file_perms;
allow clamscan_t clamd_etc_t:lnk_file { getattr read };

# tmp files
allow clamscan_t clamscan_tmp_t:file manage_file_perms;
allow clamscan_t clamscan_tmp_t:dir manage_dir_perms;
files_tmp_filetrans(clamscan_t,clamscan_tmp_t,{ file dir })

# var/lib files together with clamd
allow clamscan_t clamd_var_lib_t:file r_file_perms;
allow clamscan_t clamd_var_lib_t:sock_file rw_file_perms;
allow clamscan_t clamd_var_lib_t:dir r_dir_perms;

kernel_read_kernel_sysctls(clamscan_t)

files_read_etc_files(clamscan_t)
files_read_etc_runtime_files(clamscan_t)
files_search_var_lib(clamscan_t)

libs_use_ld_so(clamscan_t)
libs_use_shared_libs(clamscan_t)

miscfiles_read_localization(clamscan_t)
miscfiles_read_public_files(clamscan_t)

clamav_stream_connect(clamscan_t)

optional_policy(`
	apache_read_sys_content(clamscan_t)
')