Skip to content

Clamav freshclam fails when /var/log/clamav/freshclam.log does not exist #1155

@Atrate

Description

@Atrate

Describe the bug

When /var/log/clamav/freshclam.log does not exist (such as when /var/log is mounted as tmpfs to extend SSD (or SD card on rpis) longevity), freshclam does not create the log file and simply crashes (the systemd freshclam service).

How to reproduce the problem

  1. Mount /var/log/ as tmpfs.
  2. Reboot
  3. Start clamav-freshclam.service

Clamconf:

Checking configuration files in /etc/clamav

Config file: clamd.conf
-----------------------
LogFile = "/var/log/clamav/clamd.log"
LogTime = "yes"
PidFile = "/run/clamav/clamd.pid"
TemporaryDirectory = "/tmp"
LocalSocket = "/run/clamav/clamd.ctl"
User = "clamav"

Config file: freshclam.conf
---------------------------
PidFile = "/run/clamav/freshclam.pid"
UpdateLogFile = "/var/log/clamav/freshclam.log"
DatabaseMirror = "database.clamav.net"

Config file: clamav-milter.conf
-------------------------------
LogFile = "/var/log/clamav/clamav-milter.log"
LogTime = "yes"
PidFile = "/run/clamav/clamav-milter.pid"
TemporaryDirectory = "/tmp"
User = "clamav"

Software settings
-----------------
Version: 1.2.1
Optional features supported: MEMPOOL AUTOIT_EA06 BZIP2 LIBXML2 PCRE2 ICONV JSON RAR

Database information
--------------------
Database directory: /var/lib/clamav
bytecode.cvd: version 334, sigs: 91, built on Wed Feb 22 22:33:21 2023
main.cvd: version 62, sigs: 6647427, built on Thu Sep 16 14:32:42 2021
daily.cvd: version 27164, sigs: 2051511, built on Wed Jan 24 10:45:32 2024
Total number of signatures: 8699029

Platform information
--------------------
uname: Linux 6.6.13-hardened1-1-hardened #1 SMP PREEMPT_DYNAMIC Sun, 21 Jan 2024 00:24:54 +0000 x86_64
OS: Linux, ARCH: x86_64, CPU: x86_64
Full OS version: "Arch Linux"
zlib version: 1.3 (1.3), compile flags: a9
platform id: 0x0a21bfbf08000000000d0201

Build information
-----------------
GNU C: 13.2.1 20230801 (13.2.1)
sizeof(void*) = 8
Engine flevel: 191, dconf: 191

Attachments

Logs:

Jan 21 22:27:11 hostname systemd[1]: Started ClamAV virus database updater.
Jan 21 22:27:11 hostname freshclam[1322]: ERROR: lchown to user 'clamav' failed on
Jan 21 22:27:11 hostname freshclam[1322]: log file '/var/log/clamav/freshclam.log'.
Jan 21 22:27:11 hostname freshclam[1322]: Error was 'No such file or directory'
Jan 21 22:27:11 hostname freshclam[1322]: WARNING: lchown to user 'clamav' failed on log file '/var/log/clamav/freshclam.log'.  Error was 'No such file or directory'
Jan 21 22:27:11 hostname freshclam[1322]: ERROR: Failed to switch to clamav user.
Jan 21 22:27:11 hostname systemd[1]: clamav-freshclam.service: Main process exited, code=exited, status=9/n/a
Jan 21 22:27:11 hostname systemd[1]: clamav-freshclam.service: Failed with result 'exit-code'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions