Bug 237953 - Wrong init script
Wrong init script
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: cups (Show other bugs)
5.0
All Linux
low Severity low
: ---
: ---
Assigned To: Tim Waugh
:
Depends On:
Blocks: 237789 237954 237955
  Show dependency treegraph
 
Reported: 2007-04-26 07:44 EDT by Michal Marciniszyn
Modified: 2014-02-10 18:02 EST (History)
1 user (show)

See Also:
Fixed In Version: RHSA-2007-1020
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-10-31 09:49:00 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Michal Marciniszyn 2007-04-26 07:44:27 EDT
Description of problem:
Following code returns error code 0 when function script does not exist
irrespectively of status of the service.
if [ -f /etc/init.d/functions ] ; then
        . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
        . /etc/rc.d/init.d/functions
else
        exit 0
fi
There is also minor error in error code for unimplemented feature (1 instead of
3 at the end of the script).


Version-Release number of selected component (if applicable):
all

How reproducible:
always

Steps to Reproduce:
1. rename functions script
2. service cups start/status
3. echo $?
  
Actual results:
0

Expected results:
non-zero error code

Additional info:
When fixing this bug, please obbey our init script guidelines and be sure that
status command is run correctly.
Our guidelines are on following two pages:
http://intranet.corp.redhat.com/ic/intranet/InitscriptsSpec.html
http://intranet.corp.redhat.com/ic/intranet/InitscriptGuidelines.html

For an example of the script that returns the error codes correctly and always
runs status see:
http://devserv.devel.redhat.com/~mmarcini/amd

This bug is tracked by 237789.
Comment 1 Tim Waugh 2007-04-26 08:53:50 EDT
--- cups.init   1 Jun 2006 12:58:58 -0000       1.10
+++ cups.init   26 Apr 2007 12:50:08 -0000      1.11
@@ -32,13 +32,7 @@
 # Linux
 
 # Source function library.
-if [ -f /etc/init.d/functions ] ; then
-       . /etc/init.d/functions
-elif [ -f /etc/rc.d/init.d/functions ] ; then
-       . /etc/rc.d/init.d/functions
-else
-       exit 0
-fi
+. /etc/init.d/functions
 
 DAEMON=cupsd
 
@@ -90,6 +84,7 @@
        ;;
        status)
                status $DAEMON
+               RETVAL=$?
        ;;
        restartlog)
                stop
@@ -99,7 +94,7 @@
        *)
 
        echo $"Usage: $prog {start|stop|restart|condrestart|reload|status}"
-       exit 1
+       exit 3
 esac
 
 exit $RETVAL
Comment 2 RHEL Product and Program Management 2007-04-26 11:10:07 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.
Comment 10 errata-xmlrpc 2007-10-31 09:49:00 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2007-1020.html

Note You need to log in before you can comment on or make changes to this bug.