Red Hat Bugzilla – Bug 110561
Production servers startup as 'root' instead of unprivileged user 'servlet'
Last modified: 2007-04-18 12:59:39 EDT
Description of problem:
The original production start / stop scripts always 'su -' to an
unprivileged user (defaulting to 'servlet'). This is an absolutely
critical security precaution taken by *all* UNIX server software. At
most, a server will start off as root & then drop its privileges
before accepting any internet connections.
There is no reason to even start an application server as root, since
any serious deployment will have an apache (or equivalent) front end
on port 80, forwarding requests using mod_caucho/mod_jk.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Login to a server as root
2. Run 'ccm start'
The JVM is running as 'root'
The JVM is running as an unprivileged user 'servlet' (or equivalent
such as 'nobody').
Really well written software will *refuse* outright to run as 'root',
even if the user tries to tell it so. For example, if you set
'cache_effective_user' to 'root' in squid.conf it will exit, printing:
"Don't run Squid as root, set 'cache_effective_user'!"
Our automated configuration/startup scripts should do likewise.
People trust security of Apache much, much more than any Java app
server, & even that will refuse to run as 'root' :
[root@camden root]# grep '^User' /etc/httpd/conf/httpd.conf
[root@camden root]# /etc/init.d/httpd start
Starting httpd: Error: Apache has not been designed to serve pages while
running as root. There are known race conditions that
will allow any local user to read any file on the system.
If you still desire to serve pages as root then
add -DBIG_SECURITY_HOLE to the EXTRA_CFLAGS line in your
src/Configuration file and rebuild the server. It is
strongly suggested that you instead modify the User
directive in your httpd.conf file to list a non-root
Marking QA Ready.
Dan, can you comment on whether the solution is OK, as you opened the
It solves the original problem, yes, but there a some small
improvements that will make it more robust to error conditions:
1. refuse point blank to run if servlet user is set to 'root'
2. If the current user matches the desired user, then don't 'su' at
all - just run the startup.
3. If the servlet user is specified & the user is not logged in as
root, then refuse to startup. As it stands it will silently startup as
the current user - this could lead to people mistakenly running a
production server as the wrong user.
changes checked in @38383