Manage a clamav milter whitelist file.

This commit is contained in:
Andrea Dell'Amico 2026-05-28 17:34:29 +02:00
parent e7f3323ada
commit 72bbdc4d17
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
3 changed files with 24 additions and 3 deletions

View File

@ -194,6 +194,9 @@ clamav_freshclam_custom_urls: []
clamav_milter_socket: 'local:/run/clamav-milter/clamav-milter.socket'
clamav_milter_use_whitelist_file: false
clamav_milter_whitelist_file: '/etc/mail/clamav-whitelist'
# List of POSIX BRE patterns, one per line, optionally prefixed with "From:" or "To:".
# Example: 'From:^.*@example\.org$'
clamav_milter_whitelist: []
clamav_milter_use_skip_authenticated_file: false
clamav_milter_skip_authenticated_file: '/etc/mail/clamav-skip-authenticated'
clamav_milter_onclean_action: 'Accept'

View File

@ -130,17 +130,28 @@
tags: [ 'clamav', 'clamav_urlhaus' ]
- name: Configure the clamav milter
when: clamav_milter_install | bool
tags: ['clamav', 'clamav_clamd', 'clamav_config', 'clamav_milter']
block:
- name: Install the clamav milter configuration
template: src=clamav-milter.conf.j2 dest=/etc/mail/clamav-milter.conf owner=root group=root mode=0444
notify: Restart clamav-milter
- name: Install the clamav milter whitelist file
template: src=clamav-milter-whitelist.j2 dest={{ clamav_milter_whitelist_file }} owner=root group=root mode=0444
notify: Restart clamav-milter
when: clamav_milter_use_whitelist_file | bool and clamav_milter_whitelist | length > 0
tags: [ 'clamav', 'clamav_clamd', 'clamav_config', 'clamav_whitelist' ]
- name: Remove the clamav milter whitelist file when not in use
file: dest={{ clamav_milter_whitelist_file }} state=absent
notify: Restart clamav-milter
when: not (clamav_milter_use_whitelist_file | bool) or clamav_milter_whitelist | length == 0
tags: [ 'clamav', 'clamav_clamd', 'clamav_config', 'clamav_whitelist' ]
- name: Ensure that clamav milter is running and enabled
service: name=clamav-milter state=started enabled=yes
when: clamav_milter_install | bool
tags: [ 'clamav', 'clamav_clamd', 'clamav_config' ]
- name: Configure the clamd service used by spamassassin
block:
- name: Install the clamd configuration for the spamassassin service

View File

@ -0,0 +1,7 @@
# {{ ansible_managed }}
# clamav-milter Whitelist file.
# Each line is a POSIX BRE; optionally prefixed with "From:" or "To:".
# If the prefix is missing "To:" is assumed.
{% for entry in clamav_milter_whitelist %}
{{ entry }}
{% endfor %}