Bug 267844 - security/clamav: ERROR: Can't save PID to file /var/run/clamav/clamd.pid
Summary: security/clamav: ERROR: Can't save PID to file /var/run/clamav/clamd.pid
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Yasuhiro Kimura
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-18 09:04 UTC by O. Hartmann
Modified: 2022-11-19 07:23 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (yasu)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description O. Hartmann 2022-11-18 09:04:10 UTC
Running security/clamav on recent CURRENT (14.0-CURRENT #108 main-n259290-f556a05c4926: Thu Nov 17 19:44:14 CET 2022 amd64). After the last update, a couple of day ago from today (performing daily updates), clamd won't startup again, see the error below.

This issue is well known if /var/run is on tmpfs or any other memory backed filesystem vanishing after a reboot (this is a very common procedure in environments of elevated security):

[...]
#:/usr/src # service clamav-clamd restart
clamav_clamd not running? (check /var/run/clamav/clamd.pid).
Starting clamav_clamd.
ERROR: Can't save PID to file /var/run/clamav/clamd.pid: No such file or directory
/usr/local/etc/rc.d/clamav-clamd: WARNING: failed to start clamav_clamd

In /etc/rc.conf the tag 

var_run_enable="YES"

is set (all other var_run_ options are left untouched so far). The issue shown below has been discussed recently, I provided an alteration to the rc script checking for the existence of /var/run at startup of clamav. According to man rc.conf(5) setting this variable/tag to YES should provide saving the folder tree layout of /var/run and saving this to /var/db/mtree. Obvously, this isn't correctly done, /var/db/mtree is empty on those hosts (var/db is on a non-volatile device).

When I did the update of security/clamav, clamav-clamd was already running, var/run/clamav existed. Shutting down/rebooting the system then left var/run untouched after recreating, so I suppose this method is either flawed or it doesn't work properly with clamav-clamd.