Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
clamav-1.2.1: clamd init script reporting as crashed
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2041
Location: United Kingdom

PostPosted: Sat Dec 30, 2023 2:25 pm    Post subject: clamav-1.2.1: clamd init script reporting as crashed Reply with quote

In my Gentoo Linux Testing (~amd64) installation I have clamav-1.2.1 installed:

Code:
meshedgedx /home/fitzcarraldo # eix -I clamav
[I] acct-group/clamav
     Available versions:  0-r2
     Installed versions:  0-r2(03:58:28 04/08/23)
     Description:         System group: clamav

[I] acct-user/clamav
     Available versions:  0-r2
     Installed versions:  0-r2(04:06:23 04/08/23)
     Description:         System user: clamav

[I] app-antivirus/clamav
     Available versions:  0.103.8(0/lts)^t (~)0.103.11(0/lts)^t (~)1.0.3(0/lts)^t 1.1.0(0/sts)^t (~)1.1.3(0/sts)^t (~)1.2.1(0/sts)^t {bzip2 +clamapp clamdtop clamonacc clamsubmit debug doc experimental iconv ipv6 jit libclamav-only metadata-analysis-api milter rar selinux +system-mspack systemd test xml}
     Installed versions:  1.2.1(0/sts)^t(12:16:37 30/12/23)(clamapp rar system-mspack -clamonacc -debug -doc -experimental -jit -libclamav-only -milter -selinux -systemd -test)
     Homepage:            https://www.clamav.net/
     Description:         Clam Anti-Virus Scanner

Found 3 matches


rc-status reports that clamd has crashed:

Code:
meshedgedx /home/fitzcarraldo # rc-status
Runlevel: default
 swap                                                                    [  started  ]
 syslog-ng                                                               [  started  ]
 dbus                                                                    [  started  ]
 NetworkManager                                                          [  started  ]
 cronie                                                                  [  started  ]
 bluetooth                                                               [  started  ]
 sshd                                                                    [  started  ]
 atd                                                                     [  started  ]
 avahi-daemon                                                            [  started  ]
 cupsd                                                                   [  started  ]
 wsdd                                                                    [  started  ]
 netmount                                                                [  started  ]
 display-manager                                                         [  started  ]
 alsasound                                                               [  started  ]
 clamd                                                                   [  crashed  ]
 cups-browsed                                                            [  started  ]
 freshclam                                                               [  started  ]
 hddtemp                                                                 [  started  ]
 lm_sensors                                                              [  started  ]
 samba                                                                   [  started  ]
 local                                                                   [  started  ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
 display-manager-setup                                                   [  started  ]
Dynamic Runlevel: manual
 ntp-client                                                              [  started  ]



However, the clamav daemon appears to be running:

Code:
meshedgedx /home/fitzcarraldo # ps -ef | grep clam
clamav    4885     1  0 12:04 ?        00:00:00 /usr/bin/freshclam -p /run/freshclam.pid --daemon
clamav   12813     1  4 12:55 ?        00:00:55 /usr/sbin/clamd
root     24382  6591  0 13:14 pts/1    00:00:00 grep --colour=auto clam


I looked in /etc/init.d/clamd and noticed the line:

Code:
pidfile="/run/${RC_SVCNAME}.pid"


However, for this version of clamav (and any earlier versions after upstream changed the pid file location) it should be:

Code:
pidfile="/run/clamav/${RC_SVCNAME}.pid"


I edited /etc/init.d/clamd and changed the line as shown above, then restarted clamd:

Code:
meshedgedx /home/fitzcarraldo # nano /etc/init.d/clamd
meshedgedx /home/fitzcarraldo # rc-service clamd restart
 * Caching service dependencies ...                                             [ ok ]
 * Stopping clamd ...                                                           [ ok ]
 * Starting clamd ...                                                           [ ok ]
meshedgedx /home/fitzcarraldo # rc-status
Runlevel: default
 swap                                                                    [  started  ]
 syslog-ng                                                               [  started  ]
 dbus                                                                    [  started  ]
 NetworkManager                                                          [  started  ]
 cronie                                                                  [  started  ]
 bluetooth                                                               [  started  ]
 sshd                                                                    [  started  ]
 atd                                                                     [  started  ]
 avahi-daemon                                                            [  started  ]
 cupsd                                                                   [  started  ]
 wsdd                                                                    [  started  ]
 netmount                                                                [  started  ]
 display-manager                                                         [  started  ]
 alsasound                                                               [  started  ]
 clamd                                                                   [  started  ]
 cups-browsed                                                            [  started  ]
 freshclam                                                               [  started  ]
 hddtemp                                                                 [  started  ]
 lm_sensors                                                              [  started  ]
 samba                                                                   [  started  ]
 local                                                                   [  started  ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
 display-manager-setup                                                   [  started  ]
Dynamic Runlevel: manual
 ntp-client                                                              [  started  ]


Problem solved. I have filed a bug report: https://bugs.gentoo.org/921088
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.

My blog
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1782
Location: PB, Germany

PostPosted: Fri Jun 21, 2024 5:04 am    Post subject: Reply with quote

Thanks for the bug report. app-antivirus/clamav-1.2.2 still has the same issue.
_________________
HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2041
Location: United Kingdom

PostPosted: Fri Jun 21, 2024 2:32 pm    Post subject: Reply with quote

The issue arises because the init script (/etc/init.d/clamd) installed by the clamav ebuild specifies the PID file as /run/clamd.pid whereas the clamd.conf created by the ebuild specifies the PID file as /run/clamav/clamd.pid (it does this by uncommenting a line in the example clamd.conf file extracted from the downloaded clamav source code tarball). In the aforementioned Gentoo Linux bug report I assumed that the init script is incorrect and should be changed to specify the path /run/clamav/clamd.pid specified in the clamd.conf file. However, Gentoo Linux developer Michael Orlitzky stated that the PID file path given in the init script is secure whereas the path given in the config file is not, so the config file should be changed, not the init script. To date, the discrepancy remains in both the Gentoo stable version (1.2.2) and testing version (1.3.1) of the clamav ebuild in the Gentoo Linux ebuild repositories.

Until the ebuild is modified, to avoid the problem occurring I created a script in /etc/local.d/ for OpenRC to run at shutdown to ensure the PID file path is the same in the init script and config file, in case I forget to check this whenever a new version of clamav is installed. The script makes the PID file path in the config file match the file path in the init script, whether that be /run/clamd.pid or /run/clamav/clamd.pid. Obviously, if the former path is secure then that would be preferable, but I have no control over what the ebuild maintainer does, so the script caters for both situations. Anyway, the script I created is listed below.

Code:
# cd /etc/local.d
# nano 20-clamav.stop
# chmod +x 20-clamav.stop
# cat 20-clamav.stop

Code:
#!/bin/bash
#
# See Gentoo Bugzilla Bug 921088 for app-antivirus/clamav-1.2.1
# According to Comment 1, the content of /etc/init.d/clamd is correct as: pidfile="/run/${RC_SVCNAME}.pid"
# and the content of /etc/clamav/clamd.conf should be: PidFile /run/clamd.pid
#
# However, (~)clamav-1.3.1 has the following:
# /etc/init.d/clamd contains: pidfile="/run/${RC_SVCNAME}.pid"
# /etc/clamav/clamd.conf contains: PidFile /run/clamav/clamd.pid
#
# Therefore cater for either situation:
if `grep "pidfile=" /etc/init.d/clamd | grep -q clamav`; then
    sed -i 's|PidFile /run/clamd.pid|PidFile /run/clamav/clamd.pid|' /etc/clamav/clamd.conf
elif `grep "pidfile=" /etc/init.d/clamd | grep -q -v clamav`; then
    sed -i 's|PidFile /run/clamav/clamd.pid|PidFile /run/clamd.pid|' /etc/clamav/clamd.conf
fi

_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.

My blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum