]> git.ipfire.org Git - people/stevee/selinux-policy.git/blob - policy/modules/services/clamav.te
Bump module versions for release.
[people/stevee/selinux-policy.git] / policy / modules / services / clamav.te
1
2 policy_module(clamav, 1.8.0)
3
4 ## <desc>
5 ## <p>
6 ## Allow clamd to use JIT compiler
7 ## </p>
8 ## </desc>
9 gen_tunable(clamd_use_jit, false)
10
11 ########################################
12 #
13 # Declarations
14 #
15
16 # Main clamd domain
17 type clamd_t;
18 type clamd_exec_t;
19 init_daemon_domain(clamd_t, clamd_exec_t)
20
21 # configuration files
22 type clamd_etc_t;
23 files_config_file(clamd_etc_t)
24
25 type clamd_initrc_exec_t;
26 init_script_file(clamd_initrc_exec_t)
27
28 # tmp files
29 type clamd_tmp_t;
30 files_tmp_file(clamd_tmp_t)
31
32 # log files
33 type clamd_var_log_t;
34 logging_log_file(clamd_var_log_t)
35
36 # var/lib files
37 type clamd_var_lib_t;
38 files_type(clamd_var_lib_t)
39
40 # pid files
41 type clamd_var_run_t;
42 files_pid_file(clamd_var_run_t)
43 typealias clamd_var_run_t alias clamd_sock_t;
44
45 type clamscan_t;
46 type clamscan_exec_t;
47 init_daemon_domain(clamscan_t, clamscan_exec_t)
48
49 # tmp files
50 type clamscan_tmp_t;
51 files_tmp_file(clamscan_tmp_t)
52
53 type freshclam_t;
54 type freshclam_exec_t;
55 init_daemon_domain(freshclam_t, freshclam_exec_t)
56
57 # log files
58 type freshclam_var_log_t;
59 logging_log_file(freshclam_var_log_t)
60
61 ########################################
62 #
63 # clamd local policy
64 #
65
66 allow clamd_t self:capability { kill setgid setuid dac_override };
67 dontaudit clamd_t self:capability sys_tty_config;
68 allow clamd_t self:fifo_file rw_fifo_file_perms;
69 allow clamd_t self:unix_stream_socket { create_stream_socket_perms connectto };
70 allow clamd_t self:unix_dgram_socket create_socket_perms;
71 allow clamd_t self:tcp_socket { listen accept };
72
73 # configuration files
74 allow clamd_t clamd_etc_t:dir list_dir_perms;
75 read_files_pattern(clamd_t, clamd_etc_t, clamd_etc_t)
76 read_lnk_files_pattern(clamd_t, clamd_etc_t, clamd_etc_t)
77
78 # tmp files
79 manage_dirs_pattern(clamd_t, clamd_tmp_t, clamd_tmp_t)
80 manage_files_pattern(clamd_t, clamd_tmp_t, clamd_tmp_t)
81 files_tmp_filetrans(clamd_t, clamd_tmp_t, { file dir })
82
83 # var/lib files for clamd
84 manage_dirs_pattern(clamd_t, clamd_var_lib_t, clamd_var_lib_t)
85 manage_files_pattern(clamd_t, clamd_var_lib_t, clamd_var_lib_t)
86
87 # log files
88 manage_dirs_pattern(clamd_t, clamd_var_log_t, clamd_var_log_t)
89 manage_files_pattern(clamd_t, clamd_var_log_t, clamd_var_log_t)
90 logging_log_filetrans(clamd_t, clamd_var_log_t, { dir file })
91
92 # pid file
93 manage_dirs_pattern(clamd_t, clamd_var_log_t, clamd_var_log_t)
94 manage_files_pattern(clamd_t, clamd_var_run_t, clamd_var_run_t)
95 manage_sock_files_pattern(clamd_t, clamd_var_run_t, clamd_var_run_t)
96 files_pid_filetrans(clamd_t, clamd_var_run_t, { file dir })
97
98 kernel_dontaudit_list_proc(clamd_t)
99 kernel_read_sysctl(clamd_t)
100 kernel_read_kernel_sysctls(clamd_t)
101 kernel_read_system_state(clamd_t)
102
103 corecmd_exec_shell(clamd_t)
104
105 corenet_all_recvfrom_unlabeled(clamd_t)
106 corenet_all_recvfrom_netlabel(clamd_t)
107 corenet_tcp_sendrecv_generic_if(clamd_t)
108 corenet_tcp_sendrecv_generic_node(clamd_t)
109 corenet_tcp_sendrecv_all_ports(clamd_t)
110 corenet_tcp_sendrecv_clamd_port(clamd_t)
111 corenet_tcp_bind_generic_node(clamd_t)
112 corenet_tcp_bind_clamd_port(clamd_t)
113 corenet_tcp_bind_generic_port(clamd_t)
114 corenet_tcp_connect_generic_port(clamd_t)
115 corenet_sendrecv_clamd_server_packets(clamd_t)
116
117 dev_read_rand(clamd_t)
118 dev_read_urand(clamd_t)
119
120 domain_use_interactive_fds(clamd_t)
121
122 files_read_etc_files(clamd_t)
123 files_read_etc_runtime_files(clamd_t)
124 files_search_spool(clamd_t)
125
126 auth_use_nsswitch(clamd_t)
127
128 logging_send_syslog_msg(clamd_t)
129
130 miscfiles_read_localization(clamd_t)
131
132 cron_use_fds(clamd_t)
133 cron_use_system_job_fds(clamd_t)
134 cron_rw_pipes(clamd_t)
135
136 mta_read_config(clamd_t)
137 mta_send_mail(clamd_t)
138
139 optional_policy(`
140 amavis_read_lib_files(clamd_t)
141 amavis_read_spool_files(clamd_t)
142 amavis_spool_filetrans(clamd_t, clamd_var_run_t, sock_file)
143 amavis_create_pid_files(clamd_t)
144 ')
145
146 optional_policy(`
147 exim_read_spool_files(clamd_t)
148 ')
149
150 ########################################
151 #
152 # Freshclam local policy
153 #
154
155 allow freshclam_t self:capability { setgid setuid dac_override };
156 allow freshclam_t self:fifo_file rw_fifo_file_perms;
157 allow freshclam_t self:unix_stream_socket create_stream_socket_perms;
158 allow freshclam_t self:unix_dgram_socket create_socket_perms;
159 allow freshclam_t self:tcp_socket { listen accept };
160
161 # configuration files
162 allow freshclam_t clamd_etc_t:dir list_dir_perms;
163 read_files_pattern(freshclam_t, clamd_etc_t, clamd_etc_t)
164 read_lnk_files_pattern(freshclam_t, clamd_etc_t, clamd_etc_t)
165
166 # var/lib files together with clamd
167 manage_dirs_pattern(freshclam_t, clamd_var_lib_t, clamd_var_lib_t)
168 manage_files_pattern(freshclam_t, clamd_var_lib_t, clamd_var_lib_t)
169
170 # pidfiles- var/run together with clamd
171 manage_files_pattern(freshclam_t, clamd_var_run_t, clamd_var_run_t)
172 manage_sock_files_pattern(freshclam_t, clamd_var_run_t, clamd_var_run_t)
173 files_pid_filetrans(freshclam_t, clamd_var_run_t, file)
174
175 # log files (own logfiles only)
176 manage_files_pattern(freshclam_t, freshclam_var_log_t, freshclam_var_log_t)
177 allow freshclam_t freshclam_var_log_t:dir setattr;
178 allow freshclam_t clamd_var_log_t:dir search_dir_perms;
179 logging_log_filetrans(freshclam_t, freshclam_var_log_t, file)
180
181 corenet_all_recvfrom_unlabeled(freshclam_t)
182 corenet_all_recvfrom_netlabel(freshclam_t)
183 corenet_tcp_sendrecv_generic_if(freshclam_t)
184 corenet_tcp_sendrecv_generic_node(freshclam_t)
185 corenet_tcp_sendrecv_all_ports(freshclam_t)
186 corenet_tcp_sendrecv_clamd_port(freshclam_t)
187 corenet_tcp_connect_http_port(freshclam_t)
188 corenet_sendrecv_http_client_packets(freshclam_t)
189
190 dev_read_rand(freshclam_t)
191 dev_read_urand(freshclam_t)
192
193 domain_use_interactive_fds(freshclam_t)
194
195 files_read_etc_files(freshclam_t)
196 files_read_etc_runtime_files(freshclam_t)
197
198 auth_use_nsswitch(freshclam_t)
199
200 logging_send_syslog_msg(freshclam_t)
201
202 miscfiles_read_localization(freshclam_t)
203
204 clamav_stream_connect(freshclam_t)
205
206 optional_policy(`
207 cron_system_entry(freshclam_t, freshclam_exec_t)
208 ')
209
210 ########################################
211 #
212 # clamscam local policy
213 #
214
215 allow clamscan_t self:capability { setgid setuid dac_override };
216 allow clamscan_t self:fifo_file rw_file_perms;
217 allow clamscan_t self:unix_stream_socket create_stream_socket_perms;
218 allow clamscan_t self:unix_dgram_socket create_socket_perms;
219 allow clamscan_t self:tcp_socket create_stream_socket_perms;
220
221 # configuration files
222 allow clamscan_t clamd_etc_t:dir list_dir_perms;
223 read_files_pattern(clamscan_t, clamd_etc_t, clamd_etc_t)
224 read_lnk_files_pattern(clamscan_t, clamd_etc_t, clamd_etc_t)
225
226 # tmp files
227 manage_dirs_pattern(clamscan_t, clamscan_tmp_t, clamscan_tmp_t)
228 manage_files_pattern(clamscan_t, clamscan_tmp_t, clamscan_tmp_t)
229 files_tmp_filetrans(clamscan_t, clamscan_tmp_t, { file dir })
230
231 # var/lib files together with clamd
232 manage_files_pattern(clamscan_t, clamd_var_lib_t, clamd_var_lib_t)
233 allow clamscan_t clamd_var_lib_t:dir list_dir_perms;
234
235 corenet_all_recvfrom_unlabeled(clamscan_t)
236 corenet_all_recvfrom_netlabel(clamscan_t)
237 corenet_tcp_sendrecv_generic_if(clamscan_t)
238 corenet_tcp_sendrecv_generic_node(clamscan_t)
239 corenet_tcp_sendrecv_all_ports(clamscan_t)
240 corenet_tcp_sendrecv_clamd_port(clamscan_t)
241 corenet_tcp_connect_clamd_port(clamscan_t)
242
243 kernel_read_kernel_sysctls(clamscan_t)
244
245 files_read_etc_files(clamscan_t)
246 files_read_etc_runtime_files(clamscan_t)
247 files_search_var_lib(clamscan_t)
248
249 init_read_utmp(clamscan_t)
250 init_dontaudit_write_utmp(clamscan_t)
251
252 miscfiles_read_localization(clamscan_t)
253 miscfiles_read_public_files(clamscan_t)
254
255 clamav_stream_connect(clamscan_t)
256
257 mta_send_mail(clamscan_t)
258
259 tunable_policy(`clamd_use_jit',`
260 allow clamd_t self:process execmem;
261 ', `
262 dontaudit clamd_t self:process execmem;
263 ')
264
265 optional_policy(`
266 amavis_read_spool_files(clamscan_t)
267 ')
268
269 optional_policy(`
270 apache_read_sys_content(clamscan_t)
271 ')