Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 249231 - [openrc] app-antivirus/clamav-0.94.2 - init.d script fails to start/stop clamd
Summary: [openrc] app-antivirus/clamav-0.94.2 - init.d script fails to start/stop clamd
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Net-Mail Packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-29 06:59 UTC by Joakim
Modified: 2008-12-28 05:20 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joakim 2008-11-29 06:59:28 UTC
When stopping clamav it looks like all is fine:
mail / # /etc/init.d/clamd stop 
 * Stopping clamd ... [ ok ]
 * Stopping freshclam ... [ ok ]

it's just that clamd never stopped aka pid is not killed:
mail / # /etc/init.d/clamd start
 * Starting clamd ... * start-stop-daemon: /usr/sbin/clamd is already running
 * Failed to start clamd
                                                                                                     [ !! ]
 * Starting freshclam ... * start-stop-daemon: /usr/bin/freshclam is already running
 [ ok ]
 * Virus databases are already up to date.

Needless to say, restart doesn't work either

/Joakim

mail / # emerge --info
Portage 2.2_rc16 (default/linux/amd64/2008.0/server, gcc-4.3.2, glibc-2.8_p20080602-r0, 2.6.24-ovz006 x86_64)
=================================================================
System uname: Linux-2.6.24-ovz006-x86_64-Intel-R-_Core-TM-2_Duo_CPU_E6750_@_2.66GHz-with-glibc2.2.5
Timestamp of tree: Sat, 29 Nov 2008 05:16:01 +0000
app-shells/bash:     3.2_p48
dev-lang/python:     2.4.4-r13, 2.5.2-r8
dev-python/pycrypto: 2.0.1-r6
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.3.0-r1
sys-apps/sandbox:    1.2.18.1-r3
sys-devel/autoconf:  2.63
sys-devel/automake:  1.7.9-r1, 1.10.2
sys-devel/binutils:  2.19
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.27-r2
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /sbin/rc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-march=nocona -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="distlocks parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LDFLAGS="-Wl,-O1"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="acl amd64 authdaemond berkdb bzip2 cli cracklib crypt cups dri fortran gdbm glibc-omitfp gpm iconv isdnlog maildir midi mmx mudflap multilib mysql ncurses nls nptl nptlonly openmp pam pcre perl pppd python readline reflection rrdtool sasl session snmp spl sse sse2 ssl sysfs tcpd truetype unicode urandom xml xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="fbdev glint i810 intel mach64 mga neomagic nv r128 radeon savage sis tdfx trident vesa vga via vmware voodoo"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2008-11-30 06:33:47 UTC
(In reply to comment #0)
> When stopping clamav it looks like all is fine:
> mail / # /etc/init.d/clamd stop 
>  * Stopping clamd ... [ ok ]
>  * Stopping freshclam ... [ ok ]
> 
> it's just that clamd never stopped aka pid is not killed:
> mail / # /etc/init.d/clamd start
>  * Starting clamd ... * start-stop-daemon: /usr/sbin/clamd is already running
>  * Failed to start clamd
>                                            

I have the same problem. I have openrc-0.3.0-r1. The following is the command the /etc/init.d/clamd stop() function uses to "stop" one clamav process. However, I removed the --quiet switch:

nbisgentoo64 ~ # start-stop-daemon --stop --name freshclam
 * start-stop-daemon: no matching processes found
nbisgentoo64 ~ # echo $?
0
nbisgentoo64 ~ # pidof freshclam
15894

Thus, start-stop-daemon (at least from openrc-0.3.0-r1) returns 0 even though it reports that it can't find a process. I fixed this on my system locally by using replacing "--name freshclam" with "--exec /usr/bin/freshclam". I did likewise for clamav-milter and clamd.
I think this change is justifiable because the start() function of /etc/init.d/clamd uses the --exec parameter to start up the clamav processes. If you pass "--exec /usr/sbin/clamd" to start-stop-daemon to start clamd, shouldn't it be passed to start-stop-daemon when stopping the process?

However, because the "pidof freshclam" command worked, shouldn't the "--name freshclam" parameter also work? The solution I am using may be a workaround of an OpenRC/start-stop-daemon bug, but I am not willing to try going back to an earlier baselayout to test this possibility.
Comment 2 hexa 2008-12-18 11:59:22 UTC
I have exactly the same problem.
http://forums.gentoo.org/viewtopic-t-718952-highlight-.html

I'll just add a killall commands to init scripts. 
Comment 3 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2008-12-18 13:20:22 UTC
(In reply to comment #2)
> I have exactly the same problem.
> http://forums.gentoo.org/viewtopic-t-718952-highlight-.html
> 
> I'll just add a killall commands to init scripts. 
> 

I'd recommend against a plain killall command. I think the -w option of killall may be enough, though, because that'll make killall wait for clamd to terminate.

If you use killall without any arguments, it'll merely send SIGTERM and not check up on the clamd process. Then you'll run into problems using the "rc-service clamd restart" command, as clamd would be started again before the old daemon exited.

However, I'm still guessing that the whole problem is an OpenRC start-stop-daemon bug in handling --name. I'll try to remember to check OpenRC's bug tracker and the newest version later.
Comment 4 hexa 2008-12-18 15:30:25 UTC
Thank you for the info Nathan. I'm aware restart won't work. And to tell you the truth i did it your way. Changed my mind later. :-)
Comment 5 Tobias Scherbaum (RETIRED) gentoo-dev 2008-12-27 17:13:25 UTC
Worksforme using openrc-0.4.1. Please test and reopen if it's still an issue for you with openrc-0.4.1.

homer clamav # /etc/init.d/clamd start
* Starting clamd...        [ ok ]
* Starting freshclam...    [ ok ]
homer clamav # ps axf|grep clam
19722 ?        SNs    0:00 /usr/sbin/clamd
19727 ?        SNs    0:00 /usr/bin/freshclam -d
homer clamav # /etc/init.d/clamd stop 
* Stopping clamd...        [ ok ]
* Stopping freshclam...    [ ok ]
homer clamav # ps axf|grep clam
homer clamav # 
Comment 6 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2008-12-28 05:20:30 UTC
(In reply to comment #5)
> Worksforme using openrc-0.4.1. Please test and reopen if it's still an issue
> for you with openrc-0.4.1.
works for me with openrc-0.4.1 too - but not with openrc-0.3.?. So this was an OpenRC bug that was fixed and will probably fix many other initscripts too: ddclient, nfs, xdm, and other scripts in my install use start-stop-daemon's --name switch as well.
Thanks for pointing this out.