Bug 668131

Summary: clamd-wrapper reload() function broken due to incompatible sigspec
Product: [Fedora] Fedora Reporter: James Ralston <ralston>
Component: clamavAssignee: Enrico Scholz <rh-bugzilla>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: low    
Version: rawhideCC: nb, ondrejj, redhat-bugzilla, rh-bugzilla, steve
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-08 11:49:45 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
use -HUP/-USR2 instead of -SIGHUP/-SIGUSR2 to make bash happy none

Description James Ralston 2011-01-08 03:04:11 UTC
The clamd-wrapper script (not part of upstream) contains the follow commands in the reload() function:

killproc -p ${CLAMD_PIDFILE} $procname -SIGHUP  || rc=$?
killproc -p ${CLAMD_PIDFILE} $procname -SIGUSR2 || rc=$?

However, these commands will always fail, because clamd-wrapper (properly) uses /bin/sh (instead of /bin/bash) for the shebang line, and when bash is invoked as /bin/sh instead of /bin/bash, for at least x86_64, the built-in kill() function does not support the SIG prefix for signal names:

$ ( /bin/bash -c 'kill -HUP $$' )
Hangup

$ ( /bin/sh -c 'kill -HUP $$' )
Hangup

$ ( /bin/bash -c 'kill -SIGHUP $$' )
Hangup

$ ( /bin/sh -c 'kill -SIGHUP $$' )
/bin/sh: line 0: kill: SIGHUP: invalid signal specification

Because the reload() function always fails, /usr/sbin/clamav-notify-servers always silently fails.

Arguably, this is a bug in bash... but traditionally, the "kill" program hasn't used the "SIG" prefix for signal names. (Perhaps there is a standard somewhere that defines this?)

At any rate, regardless of whether the behavior of bash is changed, for maximum portability (and more importantly, to avoid breakage), clamd-wrapper should not use the "SIG" prefix.

(I'm filing this bug against rawhide, but it affects all Fedora/EPEL releases.)

Comment 1 James Ralston 2011-01-08 03:05:02 UTC
Created attachment 472333 [details]
use -HUP/-USR2 instead of -SIGHUP/-SIGUSR2 to make bash happy

Comment 2 James Ralston 2011-01-19 20:22:57 UTC
Enrico, any idea when you'll have a chance to fix this? The patch is very simple...

Comment 3 Enrico Scholz 2012-01-08 11:49:45 UTC
thx; was fixed some time ago by 77795d29eba0129ae8d163170d54f57d44c7cbed (2011-01-08).