Bug 970288 - luci initscript does not check return values correctly
luci initscript does not check return values correctly
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: conga (Show other bugs)
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Jan Pokorný
Cluster QE
: EasyFix
Depends On:
  Show dependency treegraph
Reported: 2013-06-03 17:46 EDT by Jan Pokorný
Modified: 2014-09-16 01:31 EDT (History)
4 users (show)

See Also:
Fixed In Version: conga-0.12.2-70.el5
Doc Type: Bug Fix
Doc Text:
Cause: Improper return value check when stopping the luci service. Consequence: Luci reported as stopped even if, for some reason, it was not. Fix: Return value checked correctly when stopping the luci service. Result: Accurate diagnostics reported when stopping the luci service failed.
Story Points: ---
Clone Of:
Last Closed: 2014-09-16 01:31:00 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jan Pokorný 2013-06-03 17:46:18 EDT
Reproducer could be something like this (untested)

# service luci start
# vim /etc/init.d/luci  # set LUCI_ZOPE_TIMEOUT=1
# <command to utilize the machine on 100% so luci stop is slow>&


# service luci stop && pgrep -f luci
Shutting down luci:                                        [  OK  ]


# service luci stop && pgrep -f luci
Shutting down luci:                                        [ FAIL ]
# grep '[lL]uci' /var/log/messages | tail -n1
[...] Luci did not stop after 1 seconds.


The issue is in bad handling of $? special variable in (1) the "if" inner
context and (2) the "while" outer context.  Bash man page says...

re (1):
> The exit status is the exit status of the last command executed, or zero if
> no condition tested true.

re (2):
> The exit status of the while and until commands is the exit status of the
> last do list command executed, or zero if none was executed.

Under this conditions, following snippet from stop function in luci

> while [ $cur_wait -lt $max_wait ]; do
>         sleep 1
>         cur_wait=`expr $cur_wait + 1`
>         luci_running
>         if [ $? -eq 0 ]; then
>                 break
>         fi
> done

will always have, immediately after being executed, exit code of zero
and it makes no sense to use it in subsequent conditionals.

Action items:
a. fix stop function so that it works as per "Expected"
b. check the correctness of exit code handling in other parts of initscript
Comment 6 errata-xmlrpc 2014-09-16 01:31:00 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


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