Bug 1104708 - Tomcat init script does not respect setting of CATALINA_PID in /etc/sysconfig/tomcat
Summary: Tomcat init script does not respect setting of CATALINA_PID in /etc/sysconfig...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: tomcat
Version: el6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Coty Sutherland
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1304220
TreeView+ depends on / blocked
 
Reported: 2014-06-04 14:18 UTC by C. Morgan Hamill
Modified: 2016-09-02 09:22 UTC (History)
4 users (show)

Fixed In Version: tomcat-7.0.70-2.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1304220 (view as bug list)
Environment:
Last Closed: 2016-09-02 09:22:34 UTC
Type: Bug


Attachments (Terms of Use)

Description C. Morgan Hamill 2014-06-04 14:18:44 UTC
Description of problem:
No matter what CATALINA_PID is set to in /etc/sysconfig/${NAME}, /etc/init.d/tomcat assumes the pid file is at /var/run/${NAME}.pid

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

How reproducible:
Set CATALINA_PID to something other name /var/run/${NAME}.pid in /etc/sysconfig/${NAME}

Steps to Reproduce:
1. echo 'CATALINA_PID=/var/run/whatsmyname.pid' >> /etc/sysconfig/tomcat
2. service tomcat start

Actual results:
CATALINA_PID=/var/run/tomcat.pid

Expected results:
CATALINA_PID=/var/run/whatsmyname.pid

Additional info:
This ends up a problems because the Tomcat init script sets the ownership on CATALINA_PID to TOMCAT_USER:TOMCAT_GROUP so Tomcat can write to the file, but this will fail when CATALINA_PID is set to something other than /var/run/${NAME}.pid

Comment 1 Nico Kadel-Garcia 2014-12-03 15:15:37 UTC
The patch for this is below.

diff -ur tomcat-7.0.33-4.el6.pid/etc/init.d/tomcat tomcat-7.0.33-4.el6/etc/init.d/tomcat
--- tomcat-7.0.33-4.el6.pid/etc/init.d/tomcat   2014-12-03 10:12:51.689838620 -0500
+++ tomcat-7.0.33-4.el6/etc/init.d/tomcat       2014-12-03 10:10:49.812736936 -0500
@@ -69,6 +69,8 @@
 # Define the tomcat log file
 TOMCAT_LOG="${TOMCAT_LOG:-${CATALINA_HOME}/logs/${NAME}-initd.log}"

+# Define the tomcat pid file
+CATALINA_PID="${CATALINA_PID:-/var/run/${NAME}.pid}"

 RETVAL="0"

@@ -162,7 +164,6 @@
         fi
     fi
     # fix permissions on the log and pid files
-    export CATALINA_PID="/var/run/${NAME}.pid"
     touch $CATALINA_PID 2>&1 || RETVAL="4"
     if [ "$RETVAL" -eq "0" -a "$?" -eq "0" ]; then
       chown ${TOMCAT_USER}:${TOMCAT_USER} $CATALINA_PID
@@ -210,8 +211,8 @@
       fi
       if [ "$RETVAL" -eq "0" ]; then
          count="0"
-         if [ -s "/var/run/${NAME}.pid" ]; then
-            read kpid < /var/run/${NAME}.pid
+         if [ -s "$CATALINA_PID" ]; then
+            read kpid < $CATALINA_PID
             until [ "$(ps --pid $kpid | grep -c $kpid)" -eq "0" ] || \
                       [ "$count" -gt "$SHUTDOWN_WAIT" ]; do
                     if [ "$SHUTDOWN_VERBOSE" = "true" ]; then
@@ -228,7 +229,7 @@
                 fi
                 log_success_msg
             fi
-            rm -f /var/lock/subsys/${NAME} /var/run/${NAME}.pid
+            rm -f /var/lock/subsys/${NAME} $CATALINA_PID
         else
             log_failure_msg
             RETVAL="4"
@@ -262,7 +263,7 @@
         start
         ;;
     condrestart|try-restart)
-        if [ -s "/var/run/${NAME}.pid" ]; then
+        if [ -s "$CATALINA_PID" ]; then
             stop
             start
         fi
@@ -271,14 +272,14 @@
         RETVAL="3"
         ;;
     force-reload)
-        if [ -s "/var/run/${NAME}.pid" ]; then
+        if [ -s "$CATALINA_PID" ]; then
             stop
             start
         fi
         ;;
     status)
-        if [ -s "/var/run/${NAME}.pid" ]; then
-            read kpid < /var/run/${NAME}.pid
+        if [ -s "$CATALINA_PID" ]; then
+            read kpid < $CATALINA_PID
             if [ -d "/proc/${kpid}" ]; then
                 log_success_msg "${NAME} (pid ${kpid}) is running..."
                 RETVAL="0"

Comment 2 Coty Sutherland 2016-02-03 03:38:39 UTC
https://github.com/csutherl/fedora-tomcat/commit/017ab53

There was one missing /var/run/${NAME}.pid usage in the above patch, but other than that (which I added in the above commit) it looks good.

Comment 3 Mike McCune 2016-03-28 22:44:25 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune@redhat.com with any questions

Comment 5 Fedora Update System 2016-08-05 20:10:48 UTC
tomcat-7.0.70-2.el6 has been submitted as an update to Fedora EPEL 6. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-3ff1f4485b

Comment 6 Fedora Update System 2016-08-09 02:17:55 UTC
tomcat-7.0.70-2.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-2016-3ff1f4485b

Comment 7 Fedora Update System 2016-09-01 16:20:09 UTC
tomcat-7.0.70-2.el6 has been pushed to the Fedora EPEL 6 stable repository. If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2016-09-02 09:21:58 UTC
tomcat-7.0.70-2.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.