Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clamd Permissions Fix for Debian AppArmor #74

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
clamav_cron_frequency: weekly

apparmor_clamd_configuration_path: /etc/apparmor.d/usr.sbin.clamd
apparmor_freshclam_configuration_path: /etc/apparmor.d/usr.bin.freshclam
apparmor_complain: true
krimsonkla marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparmor_complain, at least, needs to be specified as a role variable in README.md.


# A dictionary of values to be configured in the clamd and freshclam configuration files.
# Multivalued keys are specified as lists.
# A Nonetype value means that the key will be removed from the file.
Expand Down
30 changes: 30 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@
name: "{{ package_names }}"
state: present

- name: Configure AppArmor for Clamd
when: "ansible_apparmor.status == 'enabled' and apparmor_complain"
krimsonkla marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

@jsf9k jsf9k Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these changes only apply to Debian, or more specifically Debian 11? We should probably also check that the apparmor.service SystemD service is running before attempting to apply these changes, since that service is not enabled by default on Debian.

block:
- name: Configure clamd in apparmor
ansible.builtin.lineinfile:
firstmatch: true
line: "/usr/sbin/clamd flags=(complain) {"
path: "{{ apparmor_clamd_configuration_path }}"
search_string: "/usr/sbin/clamd {"
state: present

- name: Configure freshclam in apparmor
ansible.builtin.lineinfile:
firstmatch: true
line: "/usr/bin/freshclam flags=(attach_disconnected,complain) {"
path: "{{ apparmor_freshclam_configuration_path }}"
search_string: "/usr/bin/freshclam flags=(attach_disconnected) {"
krimsonkla marked this conversation as resolved.
Show resolved Hide resolved
state: present

- name: Reload AppArmor profiles
ansible.builtin.service:
name: 'apparmor'
state: 'reloaded'
krimsonkla marked this conversation as resolved.
Show resolved Hide resolved

- name: Reload AppArmor all profiles
ansible.builtin.service:
name: 'apparmor'
state: 'reloaded'

krimsonkla marked this conversation as resolved.
Show resolved Hide resolved

krimsonkla marked this conversation as resolved.
Show resolved Hide resolved
- name: Install virus_scan cron job
ansible.builtin.template:
dest: /etc/cron.{{ clamav_cron_frequency }}/virus_scan
Expand Down
Loading