How to disable clamav antivirus

Discussion in 'Installation/Configuration' started by martinhe, Apr 18, 2023.

  1. martinhe

    martinhe Member

    Hello, please, how to disable clamav antivirus?

    Requirements:
    - Turns off only email antivirus checks, leaves amavis, spamassasin, etc. on.
    - Does it apply to all current and future emails of all domains, all mailboxes globally?
    - The configuration will be persistent (permanent), i.e. it will not be deleted, for example, when ISPConfig is upgraded.

    From the top, the highest preferred solution priority:
    1. Use the global settings in the ISPConfig web administration panel.
    2. Using the service configuration file.
    3. Using a one-time SQL query.

    I've tried all kinds of options, but I'm getting errors in journalctl:

    Apr 18 09:01:04 server amavis[2325]: (02325-03) (!)connect to /var/run/clamd.amavisd/clamd.sock failed, attempt #1: Can't connect to a UNIX socket /var/run/clamd.amavisd/clamd.sock: No such file or directory
    Apr 18 09:01:05 server amavis[2325]: (02325-03) (!)connect to /var/run/clamd.amavisd/clamd.sock failed, attempt #1: Can't connect to a UNIX socket /var/run/clamd.amavisd/clamd.sock: No such file or directory
    Apr 18 09:01:05 server amavis[2325]: (02325-03) (!)ClamAV-clamd: All attempts (1) failed connecting to /var/run/clamd.amavisd/clamd.sock, retrying (2)
    Apr 18 09:01:11 server amavis[2325]: (02325-03) (!)connect to /var/run/clamd.amavisd/clamd.sock failed, attempt #1: Can't connect to a UNIX socket /var/run/clamd.amavisd/clamd.sock: No such file or directory
    Apr 18 09:01:11 server amavis[2325]: (02325-03) (!)ClamAV-clamd av-scanner FAILED: run_av error: Too many retries to talk to /var/run/clamd.amavisd/clamd.sock (All attempts (1) failed connecting to /var/run/clamd.amavisd/clamd>
    Apr 18 09:01:11 server amavis[2325]: (02325-03) (!)WARN: all primary virus scanners failed, considering backups
    Apr 18 09:01:11 server amavis[2325]: (02325-03) (!!)AV: ALL VIRUS SCANNERS FAILED
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

  3. martinhe

    martinhe Member

    I tried to write what I need as clearly as possible and yet you send me an assignment that does not meet my assignment.

    I remind you that I definitely do not want to turn off amavis. I don't want to turn off the content filter either, I just want to turn off the antivirus check, nothing more.
     
  4. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Don't be rude. To me @Taleman was trying to help and was directing you to the right way and page.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Amavis expects that clamav is there and tries to use it. You'll probably have to manually edit amavis config files and remove clamav there.
     
  6. martinhe

    martinhe Member

    I've seen a million instructions and I've commented in amavis on the requests that the instructions recommended to me, but amavis is trying to run the antivirus. I don't know what to do with it, it seems to me that there is no proper functional instruction that would not generate error messages in journactl.

    I try the following, but it just keeps generating error messages in the journal:

    - name: "Antivirus | Editing Amavis configuration 1/2 ..."
    lineinfile:
    dest: /etc/amavisd/amavisd.conf
    regexp: "^@bypass_virus_checks_maps = (.*)$"
    line: "# @bypass_virus_checks_maps = ("
    backrefs: yes
    notify:
    - Restarting service amavis...

    - name: "Antivirus | Editing Amavis configuration 2/2 ..."
    lineinfile:
    dest: /etc/amavisd/amavisd.conf
    regexp: "^# @bypass_virus_checks_maps = (.*)$"
    line: "@bypass_virus_checks_maps = (1); # controls running of anti-virus code"
    backrefs: yes
    notify:
    - Restarting service amavis...

    - name: "Antivirus | Removing packages clam*"
    yum:
    name: "{{ packages }}"
    state: absent
    vars:
    packages:
    - clamd
    - clamav-data
    - clamav-update
    - clamav
    - clamav-scanner-systemd
    - clamav-devel
    - clamav-lib
    - clamav-server-systemd
    notify:
    - Restarting service amavis...

    Please, does anyone have a tried and tested solution to turn it off properly? Thank you very much.
     
  7. martinhe

    martinhe Member

    Done. I final sove with this tasks, thanks you:

    - name: Change amavis configuration
    lineinfile:
    path: /etc/amavisd/amavisd.conf
    state: present
    insertbefore: '^1;.*'
    line: "include_config_files('/etc/amavisd/90-md_changes');"
    notify:
    - restart_service_amavisd
    - name: Create conf file
    blockinfile:
    path: /etc/amavisd/90-md_changes
    create: yes
    block: |
    @bypass_virus_checks_maps = (1); # controls running of anti-virus code
    #@bypass_spam_checks_maps = (1); # controls running of anti-spam code
    $bypass_decode_parts = 1; # controls running of decoders&dearchivers
    notify:
    - restart_service_amavisd

    - name: "Antivirus | Removing packages clam*"
    yum:
    name: "{{ packages }}"
    state: absent
    vars:
    packages:
    - clamd
    - clamav-data
    - clamav-update
    - clamav
    - clamav-scanner-systemd
    - clamav-devel
    - clamav-lib
    - clamav-server-systemd
    notify:
    - restart_service_amavisd
     
    ahrasis likes this.
  8. mockingbird

    mockingbird New Member

    Sorry to necro this thread, but how do I execute the script in the above post please? I want to implement the same thing as the OP. Thanks
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Do you talk about a recent ISPConfig system? All recent systems use Rspamd, so nothing in this thread applies to them as this thread is about Amavisd.
     
  10. mockingbird

    mockingbird New Member

    Yes, in fact, almost the latest ISPConfig. Thanks for the quick response. I ask this then: Is it possible to disable just ClamAV and leave Rspamd? My poor server with 1GB RAM is choking when it is scanning incoming emails.

    Thanks
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    1GB RAM is not enough. Have you added a SWAP file or partition?
     
  12. mockingbird

    mockingbird New Member

    Yes, indeed:
    Code:
    Filename                                Type            Size            Used            Priority
    /dev/vda3                               partition       998396          232524          -2
    
    When I manually disable the ClamAV service, everything is fine... So I would like to delete it and make that persistent throughout software updates but not lose the spam functionality.
     
  13. Strontium

    Strontium New Member

    Snipaste_2024-12-09_20-01-32.png
    Just go to "Email | Domain | Spamfilter | not enabled"
     
  14. till

    till Super Moderator Staff Member ISPConfig Developer

    Take a look at this guide. It contains the steps to make a custom rspamd config update-safe in ISPConfig:

    https://www.allerstorfer.at/clamav-with-rspamd-and-ispconfig-on-ubuntu/
     
    ahrasis and Strontium like this.

Share This Page