Red Hat Bugzilla – Bug 915447
Problem to start tomcat with a user whose group has a name different to the user
Last modified: 2017-11-08 07:16:38 EST
Description of problem: The /etc/init.d/tomcat script is not constructed to handle a user with a name that does not correspond to an existing group Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. Create a user (such as "test") on a system where the group "test" does not exist. For example, create with test:test1 configuration 2. Change the /etc/sysconfig/tomcat with TOMCAT_USER=test 3. Start /etc/init.d/tomcat6 Actual results: The chown of the CATALINA_PID file failed The tomcat can't write to the CATALINA_PID file It is impossible to stop tomcat with /etc/init.d/tomcat stop Expected results: The chown is done correctly and the start/stop of tomcat is operationnal Additional info:
I propose to : - Add a variable TOMCAT_GROUP to /etc/tomcat6/tomcat6 /etc/sysconfig/tomcat6 - Modify /etc/init.d/tomcat6 with the following patch (attached) With this modification, we are retro-compatible with the previous behaviour
Created attachment 702485 [details] Patch
This request was not resolved in time for the current release. Red Hat invites you to ask your support representative to propose this request, if still desired, for consideration in the next release of Red Hat Enterprise Linux.
The fix has been applied and is ready to commit. Looks like we only need 6.5+.
Simpler reproducer I've found: # groupmod -n test tomcat # service tomcat6 start ...
FAILED QA on tomcat6-6.0.24-59.el6 (1) A similar patch from the ont in comment 2 is applied, however, there is no TOMCAT_GROUP variable in /etc/sysconfig/tomcat6 or /etc/tomcat6/tomcat6.conf. User still can add the variable himself if wishes to change the name of tomcat user's primary group. However, I consider fix for this bug to be incomplete. (2) Why are we defining a variable for something that can be computed? Doesn't it bring more possibilities of error? I propose to replace: # Define the tomcat group TOMCAT_GROUP="${TOMCAT_GROUP:-tomcat}" in initscript with something like: TOMCAT_GROUP="$(id -gn $TOMCAT_USER)" This way there is no need to configure the variable in /etc/sysconfig/tomcat6 or /etc/tomcat6/tomcat6.conf
TOMCAT_GROUP now appears in sysconfig/tomcat6 and <confdir>/tomcat6.conf to stay with convention with the existing pattern. The appearance in the initscript is a safety net in case TOMCAT_USER and TOMCAT_GROUP is not defined appropriately in the config files. The definition in sysconfig/tomcat6 is commented as is TOMCAT_USER. Customers running individual tomcat instances using a different user name and/or group should define TOMCAT_USER and TOMCAT_GROUP in sysconfig/tomcat6. The default is `id -gn $TOMCAT_USER` TOMCAT_GROUP is defined in <confdir>/tomcat6.conf following convention. Customers running multiple instances using the same TOMCAT_USER and/or TOMCAT_GROUP should find the definitions in tomcat6.conf sufficient.
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. http://rhn.redhat.com/errata/RHBA-2013-1721.html