Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added section on how to crate a setuid script to start/stop tomcat as a regular

...

BTW, you should read the 1st howto. (wink)

Another method is to use SetUID scripts (assuming you have the capability) to do this. Here's how I do it.

Create a file called foo.c with this content (replace "/path/startupscript" with the tomcat startup script):

#include <unistd.h>
#include <stdlib.h>

Wiki Markup
int main( int argc, char \*argv\[\] )
\{
        if ( setuid( 0 ) != 0 ) perror( "setuid() error" );

printf( "Starting ${APPLICATION}\n" );
execl( "/bin/sh", "sh", "/path/startupscript", 0 );
return 1;
}

Run the following as root (replacing tmp with whatever you want the startup script to be and replacing XXXXX with whatever group you want to be able to start and stop tomcat:

gcc tmp.c -o tmp chown root:XXXXX tmp chmod ugo-rwx tmp chmod u+rwxs,g+rx tmp

Now members of the tomcat group should be able to start and stop tomcat. One caveat though, you need to ensure that that your tomcat startup script is not writable by anyone other than root, otherwise your users will be able to insert commands into the script and have them run as root (very big security hole).

...

  • A another way is to use Iptables to redirect Port 80 and 443 to user ports (>1024)

...