Hello All,
When i do a reboot (about once per month) I carefully check all the essential services are running (I especially needed to do this as systemd was, until now, not starting sendmail - a bug that is now fixed).
Clamd will not start after a reboot. A little investigation reveals that it won't start because it tries to create a pid file in /var/run/clamd.clamd/ - but /var/run/clamd.clamd/ does not exist.
mkdir /var/run/clamd.clamd && chown clamd:clamd /var/run/clamd.clamd/ will allow the service to be started with no problems.
The next reboot and... poof... /var/run/clamd.clamd/ is gone again!
I have grepped the whole of /etc/* to see if there are any references to this directory with the only entries being the sensible ones in /etc/init.d/clamd-wrapper.
In that init script the "stop" stanza does have the following command: "[ $RETVAL -eq 0 ] && rm -f $lockfile" but "$lockfile" refers to lockfile=/var/lock/subsys/clamd.${CLAMD_SERVICE}
There are no other "rm" commands.
So what deletes the /var/run/clamd.clamd/ directory on reboot?
Thanks in advance
Mark
On 07/20/2011 06:17 AM, Arthur Dent wrote:
There are no other "rm" commands.
So what deletes the /var/run/clamd.clamd/ directory on reboot?
I wonder if you should look for what should be creating it instead - because of the fact that /run = /var/run is now tmpfs.
gene
On Wed, 2011-07-20 at 07:41 -0400, Genes MailLists wrote:
On 07/20/2011 06:17 AM, Arthur Dent wrote:
There are no other "rm" commands.
So what deletes the /var/run/clamd.clamd/ directory on reboot?
I wonder if you should look for what should be creating it instead - because of the fact that /run = /var/run is now tmpfs.
gene
Good point.
Well I attach the whole of the init script to this email in case anyone can see any problems - but the key parts are:
CLAMD_PIDFILE=/var/run/clamd.${CLAMD_SERVICE}/clamd.pid
and
start () { echo -n $"Starting $prog: " daemon --pidfile=${CLAMD_PIDFILE} \ exec -a $procname /usr/sbin/clamd \ ${CLAMD_CONFIGFILE:+-c $CLAMD_CONFIGFILE} ${CLAMD_OPTIONS} --pid ${CLAMD_PIDFILE} RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $lockfile return $RETVAL }
Should I put a "touch $PIDFILE" in there? Or would I also need a mkdir command?
This is a Fedora yum package. Shouldn't this just work?
Thanks for your help so far...
Mark
On 07/20/2011 07:59 AM, Arthur Dent wrote:
...
Should I put a "touch $PIDFILE" in there? Or would I also need a mkdir command?
This is a Fedora yum package. Shouldn't this just work?
1) I think clamd should be doing the mkdir .. not the start script .. but ..
2) For now I'd put (you sure about the dir having .{${CLAMD_SERVICE} } on the end?
piddir = /var/run/clamd.${CLAMD_SERVICE} ## fix if needed
if [ !-d $piddir ] ; then mkdir piddir}
fi
in the file ...
3) i'd file a bug report against clamav on this - needing to be updated for /var/run being tmpfs.
gene/
* On Wed, 2011-07-20 at 08:56 -0400, Genes MailLists wrote:
On 07/20/2011 07:59 AM, Arthur Dent wrote:
...
Should I put a "touch $PIDFILE" in there? Or would I also need a mkdir command?
This is a Fedora yum package. Shouldn't this just work?
- I think clamd should be doing the mkdir .. not the start script ..
but ..
- For now I'd put (you sure about the dir having .{${CLAMD_SERVICE}
} on the end?
piddir = /var/run/clamd.${CLAMD_SERVICE} ## fix if needed if [ !-d $piddir ] ; then mkdir piddir} fiin the file ...
- i'd file a bug report against clamav on this - needing to be
updated for /var/run being tmpfs.
gene/
Thanks Gene.
https://bugzilla.redhat.com/show_bug.cgi?id=723544
Also, I found that in order for your suggested modification to work I needed to put a space between the ! and the -d and also I needed to chown the new directory.
For the benefit of the archives this is what now works for me:
#============8<=================================================== # In the definitions section: CLAMD_PIDDIR=/var/run/clamd.${CLAMD_SERVICE}
# and in the "start" stanza:
if [ ! -d $CLAMD_PIDDIR ] ; then mkdir $CLAMD_PIDDIR && chown clamd:clamd $CLAMD_PIDDIR fi #============8<===================================================
Thanks again for your help Gene. Much appreciated.
Mark
On 07/20/2011 11:11 AM, Arthur Dent wrote:
Also, I found that in order for your suggested modification to work I needed to put a space between the ! and the -d and also I needed to chown the new directory.
...
Thanks again for your help Gene. Much appreciated.
Hah well glad you got it - I should have said - "untested" :-)
On Wed, 2011-07-20 at 16:11 +0100, Arthur Dent wrote:
For the benefit of the archives this is what now works for me:
#============8<=================================================== # In the definitions section: CLAMD_PIDDIR=/var/run/clamd.${CLAMD_SERVICE}
# and in the "start" stanza:
if [ ! -d $CLAMD_PIDDIR ] ; then mkdir $CLAMD_PIDDIR && chown clamd:clamd $CLAMD_PIDDIR fi #============8<===================================================
For those who aren't following the bug https://bugzilla.redhat.com/show_bug.cgi?id=723544 Apparently the correct solution to the problem of /var/run now being tempfs (and therefore wiped clean with each reboot) is to create a /etc/tmpfiles.d file with instructions on how to create the directory with the appropriate permissions. This simply involves (for me) creating a /etc/tmpfiles.d/clamd.conf file with the following line in it:
d /var/run/clamd.clamd 0700 clamd clamd -
At reboot the directory /var/run/clamd.clamd/ is then created with 0700 permissions and clamd:clamd ownership. The clamd package will then start properly.
I hope that helps anyone else suffering the same problem.
Mark