This is a patch to tomcat.sh that adds a -user flag to control who tomcat executes as. I couldn't get it to work by having it just execute the java command as the new user, so I have the script execute itself as the new user, and pass along the information it needs from the parent's environment (JAVA_HOME, JAVACMD, etc). I don't know if this is suitable for inclusion in one of the maintenance releases, but I thought perhaps somebody would get some good out of it. Paul Frieden
--- jakarta-tomcat-3.2-src/src/shell/tomcat.sh-old Wed Nov 29 21:50:50 2000 +++ jakarta-tomcat-3.2-src/src/shell/tomcat.sh Thu Nov 30 11:32:02 2000 @@ -51,7 +51,7 @@ TOMCAT_HOME=/opt/tomcat echo "Defaulting TOMCAT_HOME to $TOMCAT_HOME" fi - + # Add other "standard" locations for tomcat fi @@ -85,6 +85,21 @@ if [ "$JAVACMD" = "" ] ; then # it may be defined in env - including flags!! JAVACMD=$JAVA_HOME/bin/java +fi + +if [ "$1" = "-user" ] ; then + if [ "x$2" = "x" ] ; then + echo "Must provide a user name with -user" + fi + + # Convert TOMCAT_HOME to an absolute path...is there a better way to do this? + cd $TOMCAT_HOME + TOMCAT_HOME=`pwd` + cd - + + echo "Becoming $2" + # Change users and re-execute this shell script without the -user command + exec su - $2 -c "TOMCAT_HOME=\"$TOMCAT_HOME\" PATH=\"\$PATH:$JAVA_HOME/bin/\" +JAVA_HOME=\"$JAVA_HOME\" JAVACMD=\"$JAVACMD\" $TOMCAT_HOME/bin/$progname $3 $4 $5 $6 +$7 $8 $9" fi oldCP=$CLASSPATH