RSS RSS feed | Atom Atom feed
Popular Articles: Tom Riddle's Magical Diary | AJAX Lego Robot | AJAX CAPTCHA | SQL Multisets

Running Jetty as Non Root

I'm kicking the tires of Jetty and am in the process of setting it up on a production machine and found that the latest Jetty realeas (6.1.14) has a really easy way to start jetty out running as root and later switch to a uid of your choice which enables you to open up server sockets on the privileged ports 80 & 443. See the README file under {jetty.root}/extras/setuid. The process is just a one-liner...well, there are some more perks as you'll see at the end.

The README seems little bit out of date as my

mvn install
did all of the compiling and copying steps. However, when I try to launch jetty with the new jetty-setuid.xml config file I get the following error.
2009-01-20 23:10:33.887::WARN: Config error at <Set name="uid">jetty</Set> 2009-01-20 23:10:33.888::WARN: EXCEPTION java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(libgcj.so.81) at org.mortbay.xml.XmlConfiguration.set(XmlConfiguration.java:405) at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:248) at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:214) at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:974) at java.lang.reflect.Method.invoke(libgcj.so.81) at org.mortbay.start.Main.invokeMain(Main.java:194) at org.mortbay.start.Main.start(Main.java:523) at org.mortbay.start.Main.main(Main.java:119) Caused by: java.lang.NumberFormatException: invalid character at position 1 in jetty at java.lang.Integer.parseInt(libgcj.so.81) at java.lang.Integer.<init>(libgcj.so.81) at java.lang.reflect.Constructor.newInstance(libgcj.so.81) ...8 more
My jetty-setuid.xml file looks like:
<Configure id="Server" class="org.mortbay.setuid.SetUIDServer"> <Set name="startServerAsPrivileged">false</Set> <Set name="umask">2</Set> <Set name="uid">jetty</Set> <Set name="gid">jetty</Set> </Configure>
For some reason its expecting an integer instead of "jetty"...well well
> su jetty > id uid=1002(jetty) gid=1003(jetty) groups=1003(jetty)
My jetty-setuid.xml now looks like:
<Configure id="Server" class="org.mortbay.setuid.SetUIDServer"> <Set name="startServerAsPrivileged">false</Set> <Set name="umask">2</Set> <Set name="uid">1002</Set> <Set name="gid">1003</Set> </Configure>
...works like a charm.
Tags :
slashdot digg del.icio.us technorati [more]



Re: Running Jetty as Non Root

Thanks ! I will try it. I was looking how to do it.

Add a comment Send a TrackBack