If /var/run/clamav (or whatever is specified in the conf file) does not exist - when /var/run is on tmpfs for instance - clamav fails to start with: Aug 21 10:21:42 east clamd[31237]: LOCAL: Socket file /var/run/clamav/clamd.sock could not be bound: No such file or directory Aug 21 10:21:42 east freshclam[31244]: Can't save PID to file /var/run/clamav/freshclam.pid: No such file or directory Clamav init script should check for socket and pid file directories and create them if necessary. Please see the revized init script. Reproducible: Always
Created attachment 243843 [details] clamd.rc For your reference: --- files/clamd.rc.old 2009-06-21 13:05:18.000000000 +0300 +++ files/clamd.rc 2010-08-21 15:10:30.000000000 +0300 @@ -1,7 +1,7 @@ #!/sbin/runscript -# Copyright 1999-2005 Gentoo Foundation +# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/app-antivirus/clamav/files/clamd.rc,v 1.17 2009/06/21 09:46:12 dertobi123 Exp $ +# $Header: $ opts="logfix" @@ -77,6 +77,10 @@ # (might be clobbered by logrotate or something) local logfile=`awk '$1 == "LogFile" { print $2 }' /etc/clamd.conf` local clamav_user=`awk '$1 == "User" { print $2 }' /etc/clamd.conf` + local clamav_basedir=$(awk '$1 == "PidFile" { print $2 }' /etc/clamd.conf | sed s:/[^/]*$::) + clamav_basedir="${clamav_basedir:-/var/run/clamav}" + clamd_socketdir="${clamd_socket%/*}" + clamd_socketdir="${clamd_socketdir:-/var/run/clamav}" if [ -n "${logfile}" ] && [ -n "${clamav_user}" ]; then if [ ! -f "${logfile}" ]; then touch ${logfile} @@ -84,6 +88,12 @@ chown ${clamav_user} ${logfile} chmod 640 ${logfile} fi + if [ ! -d "${clamav_basedir}" ]; then + checkpath -q -d -o "${clamav_user}:${clamav_user}" -m 0755 "${clamav_basedir}" + fi + if [ ! -d "${clamd_socketdir}" ]; then + checkpath -q -d -o "${clamav_user}:${clamav_user}" -m 0755 "${clamd_socketdir}" + fi fi if [ "${START_FRESHCLAM}" = "yes" ]; then @@ -91,6 +101,8 @@ # (might be clobbered by logrotate or something) logfile=`awk '$1 == "UpdateLogFile" { print $2 }' /etc/freshclam.conf` local freshclam_user=`awk '$1 == "DatabaseOwner" { print $2 }' /etc/freshclam.conf` + local freshclam_basedir=$(awk '$1 == "PidFile" { print $2 }' /etc/freshclam.conf | sed s:/[^/]*$::) + freshclam_basedir="${freshclam_basedir:-/var/run/clamav}" if [ -n "${logfile}" -a -n "${clamav_user}" ]; then if [ ! -f "${logfile}" ]; then touch ${logfile} @@ -98,5 +110,8 @@ chown ${freshclam_user} ${logfile} chmod 640 ${logfile} fi + if [ ! -d "${freshclam_basedir}" ]; then + checkpath -q -d -o "${freshclam_user}:${freshclam_user}" -m 0755 "${freshclam_basedir}" + fi fi }
Created attachment 244543 [details] clamd.rc Added error checking
what is keeping this out of portage?
With baselayout-2.1 now stable, this stops clamd from running! Can someone please update the init script which is now broken?
Created attachment 317113 [details] Update of the previous init script using extra_commands instead of opts Please find attached fix which works fine for me. While we're all waiting for someone to get around to putting this in portage. I suggest the following. copy the attached to /etc/init.d/ as clamd-fixed chmod a+x clamd-fixed cp /etc/conf.d/clamd /etc/conf.d/clamd-fixed rc-update del clamd rc-update add clamd-fixed that way the new file won't get clobbered by any updates. Also since the base layout change I think this has become a bug rather than an enhancement.
*** Bug 430322 has been marked as a duplicate of this bug. ***
+*clamav-0.97.5-r1 (07 Aug 2012) + + 07 Aug 2012; Eray Aslan <eras@gentoo.org> +clamav-0.97.5-r1.ebuild, + +files/clamd.initd: + Create run dir during startup if necessary - bug #333783. Thanks to Valery + Kartel +
Created attachment 320704 [details] app-antivirus/clamav/files/clamd.initd polishing init.d script to use openrc applet checkpath rather than touch;chmod;chown commands. Some fixes in get_config().
As I have START_CLAMD=no START_FRESHCLAM=yes in /etc/conf.d/clamd the checkpath call in the if [ "${START_CLAMD}" = "yes" ]; then branch wasn't executed but freshclam still want's to store it's pid file in /var/run/clamav and writes to /var/log/clamav/freshclam.log: ERROR: Can't save PID to file /var/run/clamav/freshclam.pid: No such file or directory I simply copied the checkpath call to the if [ "${START_FRESHCLAM}" = "yes" ]; then branch to fix this.