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]

Virtualbox Port Forwarding Problems

I've recently started using VirtualBox and find it really good. However, I was setting up port forwarding with NAT according to the documentation and must have made a mistake since I got the following error while restarting the virtual machine

Failed to start virtual machine XYZ -56 (VERR_NO_DIGITS)
I tried to remove the newly added settings using
vboxmanage setextradata XYZ ... <null>
but I guess I had a typo somewhere in my initial attempt to use setextradata, and I couldn't figure out what the typo was (I had closed the command prompt window and there was no history available). I couldn't find anything online using google so I simple deleted the virtual machine and added it again using the same vdi...worked like a charm. Hope this helps someone out there.

Tags :
slashdot digg del.icio.us technorati [more]

Single Table Polymorphic Inheritance with ActiveRecords

Ruby on Rails warning: toplevel constant XX referenced by YY

Implementing a single table polymorphic inheritance in rails is dead easy. Simply do
class Fruit < ActiveRecord::Migration def self.up create_table :persons do |t| t.column :type :string t.column :shape, :string t.timestamps end end def self.down drop_table :fruits end end
or if you a migrating...
class Fruit < ActiveRecord::Migration def self.up add_column :fruits, :type, :string end def self.down remove_column :fruits, :type end end
Now, all you have to do is to create your sub-classes
class Fruit < ActiveRecord::Base def calc_volume ... end end class Apple < Fruit def calc_volume ... end end
Don't forget to put Apple in a separate file by itself apple.rb or else ruby will spit out an unconditional warning if you reference Apple in your code with Fruit::Apple
warning: toplevel constant Fruit referenced by Fruit::Apple

Read more...

Tags :
slashdot digg del.icio.us technorati [more]

GreenMail v1.3 Released

The Birth of Mr GreenMail JBoss Service

This release contains minor changes to GreenMail core, most notable the introduction of slf4j for logging.

New in this release is a JBoss service for GreenMail. The service runs GreenMail as a lightweight mail server sandbox, nicely suited for developers.

Check out the project page http://www.icegreen.com/greenmail for the latest documentation!

Note about the released files (goto download page):

  • greenmail-1.3-bundle.jar : mvn upload bundle
  • greenmail-1.3.jar : contains all greenmail core classes
  • greenmail-1.3-src.zip : contains sources, javadoc, required libs, docs
  • greenmail-1.3.zip : like above, but no sources
  • greenmail-jboss-service-1.3.sar : deployable JBoss service archive


Changes:

  • Added logging via slf4j, replacing System.out.println
  • Minor improvements:
    • c.i.g.AbstractServer exposes ServerSetup
    • c.i.g.util.GreenMailUtil exposes sendTextEmail(...)
  • New JBoss service wrapper (see the project page)

Credits:
Marcel May added the JBoss service and contributed the logging changes. Thanks!

Upcoming changes:
For 1.4 we plan to replace the current Foedus smtp and pop implementation with http://subetha.tigris.org

slashdot digg del.icio.us technorati [more]

Internet Explorer 6 & 7 document.domain bug

Disclaimer: Im not sure this a bug discovery...couldn't find anything that resembled it after a couple of minutes of googling, or a super silly security restriction.

I've been coding some javascript ajax code that inserts an iframe, and into the created iframe, inserts a form and submits the form to a (cross domain) server. This is an old cross-domain ajax technique by now, but while implementing it I came across this ridiculously annoying bug in IE. The line in red below will result in an "Access Denied" exception being thrown...again, only in IE. Tried this with IE6 under WinXP Media Center Edition SP2, IE7 under WinXP Home Edition SP2, and IE7 Windows Vista Home. Needless to say...it works just fine in FireFox.

<script type="text/javascript"> document.domain = 'waelchatila.com'; var new_html = '<iframe id="frm" name="frm" src="http://waelchatila.com"></iframe>'; document.body.innerHTML+=new_html; try { var iframe_doc = document.getElementById("frm").contentWindow.document; } catch (e) { alert(e); } </script>
Try it by clicking the button below.

This page should be served off http://waelchatila.com. As you can see, the document.domain is explicitly set to the domain the page was served from. The iframe src is also from the same server. I've tried it with a whole variety of variations, none of the demonstrated here but tested for.

  • iframe's document.domain = 'waelchatila.com';
  • iframe src is empty
  • iframe src is "javascript:false"
There should be no problem accessing the iframe's content in either case.

Now, if the document.domain = 'waelchatila.com'; line is removed, it works. In order for this to work, you'll need to reload this page if you clicked the previous button since document.domain has now already been assigned.

The same results present itself if the iframe is created with document.createElement('iframe') and document.appendChild(...)

I've yet to find a workaround for this issue. I'll be positing another entry if I found out how. Please let me know if you know of one!

slashdot digg del.icio.us technorati [more]