Bug 640336

Summary: network:dhcp: Init script "rc.dhcpd" not fully LSB compliant
Product: [openSUSE] openSUSE 11.3 Reporter: Forgotten User xRcrmyYBVX <forgotten_xRcrmyYBVX>
Component: OtherAssignee: Marius Tomaschewski <mt>
Status: RESOLVED FIXED QA Contact: E-mail List <opensuse-communityscreening>
Severity: Normal    
Priority: P5 - None CC: lnussel, maintenance, manfred.danzer, radmanic, werner
Version: Final   
Target Milestone: ---   
Hardware: Other   
OS: SLES 11   
Whiteboard: .
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Deadline: 2011-05-16   
Attachments: Proposed patch with more exact return codes

Description Forgotten User xRcrmyYBVX 2010-09-18 08:15:39 UTC
The init script "rc.dhcpd" is not fully LSB compliant.

When the executable of configuration file of the dhcp server is not found in the beginning of the init script, it returns exit 5 or 6 respectively, which is not valid if the "status" parameter was given.

The problem arises in a Heartbeat/Linux-HA configuration, where the Heartbeat service runs a ressource monitor using "rcdhcpd status" to check the status of this ressource. If the configuration file is not available at the time this command is run (e.g. when the configuration file is on an DRBD device which is not (yet) mounted), then the exit code of "6" will cause the Heartbeat monitor to fail, as this exit code is not expected from the "status" parameter!

Here are the corresponding lines (98 to 107) in "rc.dhcpd":

 if ! [ -x "$DAEMON_BIN" ]; then  
     if [ "$1" = "stop" ]; then exit 0; fi  
     echo >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting."  
     exit 5  
 fi  
 if ! [ -r "$DAEMON_CONF" ] ; then  
     if [ "$1" = "stop" ]; then exit 0; fi  
     echo >&2 "$0: \"$DAEMON_CONF\" config file missed. Exiting."  
     exit 6  
 fi
Comment 1 Forgotten User xRcrmyYBVX 2010-09-18 08:35:13 UTC
Possible patch:

--- rc.dhcpd
+++ rc.dhcpd
@@ -95,15 +95,17 @@
 # with force-reload (in case signalling is not supported) are
 # considered a success.
 
-if ! [ -x "$DAEMON_BIN" ]; then
-	if [ "$1" = "stop" ]; then exit 0; fi
-	echo >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting."
-	exit 5
-fi
-if ! [ -r "$DAEMON_CONF" ] ; then
-	if [ "$1" = "stop" ]; then exit 0; fi
-	echo >&2 "$0: \"$DAEMON_CONF\" config file missed. Exiting."
-	exit 6
+if ! [ "$1" = "status" ]; then
+	if ! [ -x "$DAEMON_BIN" ]; then
+		if [ "$1" = "stop" ]; then exit 0; fi
+		echo >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting."
+		exit 5
+	fi
+	if ! [ -r "$DAEMON_CONF" ] ; then
+		if [ "$1" = "stop" ]; then exit 0; fi
+		echo >&2 "$0: \"$DAEMON_CONF\" config file missed. Exiting."
+		exit 6
+	fi
 fi
 
 # remove empty pid files to avoid disturbing warnings by checkproc/killproc
Comment 2 Marius Tomaschewski 2010-09-20 08:33:35 UTC
OK,
the codes 5 and 6 are reserved by LSB in status and the dhcpd binary started
by the service before may, still run.

When a service gets uninstalled, the service is stopped and the binary _and_
the init script removed via rpm scripts.

The easiest (only?) way to trigger the problem is to just remove the config
file without to stop/uninstall the service.

Question is, if this is a bug -- that exists in any service / init script we
ship as well as in /etc/init.d/skeleton, or it has to be resolved as INVALID
[WONTFIX] because it is incorrect use similar to e.g. a "chmod -x $binary" ?

RĂ¼diger, Werner, what do you say?
Comment 3 Ludwig Nussel 2010-09-29 11:01:08 UTC
Interesting case. Looks like a misbehavior of the scripts, even though the state of server running but config absent is weird.
Comment 4 Marius Tomaschewski 2010-09-29 11:28:28 UTC
Whether the service is running or not is finally irrelevant. As soon as
the config file is removed, wrong status codes are returned.
Comment 5 Marius Tomaschewski 2010-09-29 12:34:40 UTC
Created attachment 392102 [details]
Proposed patch with more exact return codes

I'd prefer this patch instead of one in comment 1.

In case there is no executable binary:
  stop   -> code 0 (success)
        the service may still run, but we can't stop it using killproc.
        => use rpm -e or similar to deinstall properly
          "chmod -x $binary" or "mv $binary ..." => unsupported case.
  status -> code 4 (service status unknown)
        the service may still run, but we can't stop find it using checkproc.
        checkproc would return code 5 here => IMO a bug
  *      -> code 5 (program is not installed)

In case of missed dhcpd.conf:
  stop   -> killproc return code
            check for chroot pid file when /etc/sysconfig/dhcpd is missed too
  status -> checkproc return code
            check for chroot pid file when /etc/sysconfig/dhcpd is missed too
  *      -> code 6 (program is not configured)

Comments?
Comment 6 Marius Tomaschewski 2010-10-26 12:20:51 UTC
timeout ;-)
Comment 9 manfred danzer 2010-10-26 14:12:59 UTC
Actually, I just tested your patch today on our HA cluster. Works nicely! :-)
Comment 11 Marius Tomaschewski 2010-10-26 14:50:36 UTC
(In reply to comment #9)
> Actually, I just tested your patch today on our HA cluster. Works nicely! :-)

Thanks!

I'm going to prepare fixed package in my collection/branch first [there
are also another reports for the dhcp package I've to review]:

http://download.opensuse.org/repositories/home:/mtomaschewski:/branches:/openSUSE:/11.3:/Update:/Test/

and finally request a submit into :Update:Test.
Comment 12 Swamp Workflow Management 2011-04-18 13:54:46 UTC
The SWAMPID for this issue is 40346.
This issue was rated as low.
Please submit fixed packages until 2011-05-16.
Also create a patchinfo file using this link:
https://swamp.suse.de/webswamp/wf/40346
Comment 13 Marius Tomaschewski 2011-04-28 08:45:52 UTC
Fixed SLE-11-SP1 dhcp-3.x package (request were 11595) and patchinfo for
SWAMPID 40346 is submitted.

The dhcp-4.x packages on openSUSE-11.3 and 11.4 already this fix before.
Comment 14 Swamp Workflow Management 2011-06-09 11:37:19 UTC
Update released for: dhcp, dhcp-client, dhcp-debuginfo, dhcp-debugsource, dhcp-devel, dhcp-relay, dhcp-server
Products:
SLE-DEBUGINFO 11-SP1 (i386, ia64, ppc64, s390x, x86_64)
SLE-DESKTOP 11-SP1 (i386, x86_64)
SLE-SDK 11-SP1 (i386, ia64, ppc64, s390x, x86_64)
SLE-SERVER 11-SP1 (i386, ia64, ppc64, s390x, x86_64)
SLES4VMWARE 11-SP1 (i386, x86_64)