Bug 1372789 - init script status command gives incorrect result
Summary: init script status command gives incorrect result
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: tomcat
Version: el6
Hardware: Unspecified
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Coty Sutherland
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-02 17:03 UTC by Ken Geis
Modified: 2017-03-22 14:47 UTC (History)
6 users (show)

Fixed In Version: tomcat-7.0.75-1.el6
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-03-22 14:47:37 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
patch proposal for testing (1.04 KB, patch)
2017-02-10 20:33 UTC, Coty Sutherland
no flags Details | Diff
correct patch (1021 bytes, patch)
2017-02-10 20:39 UTC, Coty Sutherland
no flags Details | Diff

Description Ken Geis 2016-09-02 17:03:39 UTC
Description of problem:
I am running a service with a different NAME than tomcat. When I ask for its status, it says that it's not running.

Version-Release number of selected component (if applicable):
7.0.70-2.el6

How reproducible:
I was able to reproduce it simply as below.

Steps to Reproduce:
1. create additional Tomcat service by linking foo to tomcat in /etc/init.d
2. create a simple Catalina base in /tmp/bar
3. in /etc/sysconfig/foo set
    CATALINA_BASE=/tmp/bar
    CATALINA_TMPDIR=/tmp/bar/temp
    CATALINA_PID=/var/run/foo.pid
4. service foo start
5. service foo status

Actual results:
<NAME> (pid <pid>) is running...                        [  OK  ]
<NAME> lockfile exists but process is not running       [FAILED]

Expected results:
<NAME> (pid <pid>) is running...                        [  OK  ]


Additional info:
/etc/init.d/tomcat tries to get the PID by
            pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_USER} -f "${NAME}[ $]")"
This does not work here because ${NAME} does not appear anywhere in the command line. Perhaps it would if $CATALINA_BASE contained $NAME.

Comment 1 Ken Geis 2016-09-02 17:07:04 UTC
I am able to work around this by changing the test to

  pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_USER} -f "${CATALINA_BASE}[ $]")"

Comment 2 Coty Sutherland 2016-09-02 17:41:42 UTC
Thanks for the report, Ken. I made a bad assumption that $NAME would always be available, but it isn't (as you said). I think $CATALINA_BASE will work fine (I tested it previously), so I'll try and switch over to that method soon.

Comment 3 Coty Sutherland 2017-02-10 20:32:19 UTC
I tested this a bit more and it seems that you need to specify which property you're looking for instead of just "${CATALINA_BASE}[ $]", otherwise you'll get false positives when you have the same CATALINA_HOME as some other service.

I'm attaching a patch shortly, can you test to verify I didn't miss something?

Comment 4 Coty Sutherland 2017-02-10 20:33:13 UTC
Created attachment 1249138 [details]
patch proposal for testing

Here's what I think works best.

Comment 5 Coty Sutherland 2017-02-10 20:39:00 UTC
Created attachment 1249139 [details]
correct patch

That other patch was from the wrong version :(

Comment 6 Ken Geis 2017-02-10 22:09:26 UTC
This patch works for me. It would be more correct to escape the . in the pattern.

Comment 8 Fedora Update System 2017-02-17 20:29:33 UTC
tomcat-7.0.75-1.el6 has been submitted as an update to Fedora EPEL 6. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2017-c3b112eb9e

Comment 9 Fedora Update System 2017-02-18 19:16:40 UTC
tomcat-7.0.75-1.el6 has been pushed to the Fedora EPEL 6 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2017-c3b112eb9e

Comment 10 Fedora Update System 2017-03-22 14:47:37 UTC
tomcat-7.0.75-1.el6 has been pushed to the Fedora EPEL 6 stable repository. If problems still persist, please make note of it in this bug report.


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