NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.98k stars 13.99k forks source link

clamav service doesn't create its state dir #187992

Open vcunat opened 2 years ago

vcunat commented 2 years ago

Steps To Reproduce

Set services.clamav.daemon.enable = true; and get

  clamd[1221]: LibClamAV Error: cl_load(): No such file or directory: /var/lib/clamav
  systemd[1]: clamav-daemon.service: Main process exited, code=exited, status=1/FAILURE

I did this on fresh NixOS 22.05, but I can't see any related recent change on master either.

Notify maintainers

@robberer @qknight @globin

Workaround

For now I did:

{
  systemd.services.clamav-daemon.serviceConfig = {
    StateDirectory = "clamav";
  };
}

but you may prefer a different way of doing this in the service, e.g. tmpfiles.

GeorgesAlkhouri commented 1 year ago

I first encountered the same error log as you did, with NixOS 22.11 this time. After editing my config with your lines of code I still get kind of the same error:

Dez 28 16:29:16 nixos systemd[1]: Started ClamAV daemon (clamd).
Dez 28 16:29:16 nixos clamd[39051]: LibClamAV Error: cli_loaddbdir: No supported database files found in /var/lib/clamav
Dez 28 16:29:16 nixos clamd[39051]: ERROR: Can't open file or directory
Dez 28 16:29:16 nixos systemd[1]: clamav-daemon.service: Main process exited, code=exited, status=1/FAILURE
Dez 28 16:29:16 nixos systemd[1]: clamav-daemon.service: Failed with result 'exit-code'.

Basically saying there is no clamav database. So just after manually firing the update service for clamav systemctl start clamav-freshclam.service I was able to start the clamav daemon.

Maybe we need a oneshot service to initially create the signature DB for clamav before starting the daemon?