JPz'log Coin Coin and Plop da Plop

10Nov/084

IzPack installers with privileged permissions

One common issue when dealing with installers is that they sometimes need to be run with privileged permissions: think root on Unix or an administrator on Windows. Otherwise some operations are not permitted such as writing to /usr/local/ or putting some system-wide entries in the infamous Windows registry.

The classic solution is of course to ask your end-users to run your installer as the right user, but I guess you agree that this is not very user-friendly...

With IzPack things have never been easy on this point, as telling your users to "launch a JVM as an administrator" is all but an easy thing.

There has been a workaround for some time under Windows Vista, as one can wrap an installer JAR into a self-extracting executable using our izpack2exe script. As long as the filename contains "setup" or "install", Windows Vista asks for a privileges elevation. This is of course not really satisfactory, as it requires some further efforts and does not work everywhere (plus you have to ship JAR and EXE versions of the same installer).

Fortunately the latest Subversion trunk of IzPack just fixes that :-) The next screenshot shows the result on Mac OS X through the familiar security dialog box.

To do that, we had to make some OS-specific workarounds to relaunch JVMs, as there is unfortunately no way in the Java APIs to ask a JVM to run as a different user (or even better, as what the guest OS calls an administrator).

On Windows, we use a JScript that is an adaptation of the one from Aaron Margosis 'elevate.js' script. On Windows XP, a dialog appears and asks you under which account the application should be run, and on Windows Vista, a privileges escalation is proposed to the user through the familiar UAC machanisms (you know the UAC: it's the thing that constantly pops you to make sure that you indeed clicked there or there :-) ).

On Mac OS X, we use a native universal application that calls the security framework (the source code lives in a Git repository at Github, feel free to reuse!).

Finally on Unix systems we chose a least-common denominator approach by relying on the presence of xterm and sudo.

You can already sample this in a special version of the experimental installer for Glassfish v3 Prelude. Of course you can also checkout the source code from our SVN trunk and see for yourself ;-)

The last thing left to implement is to port the feature to uninstallers, as otherwise they are unable to properly remove what installers had put in the first place.

Feedback is more that welcome! I think this feature will make IzPack-based installers even more appealing... remember: Package Once. Deploy everywhere! :-)

Share this post:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Live
  • Netvibes
  • StumbleUpon
  • Technorati
  • FriendFeed
  • Wikio
  • Twitter
  • Identi.ca
  • Reddit
  • RSS
  • Slashdot

Related posts:

  1. New IzPack-based installers for GlassFish
  2. IzPack-based installer for GlassFish v3 Prelude
  3. IzPack 4.2.0 has been released
  4. IzPack 4.2.1 released + launching professional services for IzPack
  5. IzPack and Java Web Start

Comments (4) Trackbacks (1)
  1. That’s awesome – the issue of permissions has been troubling me for a long time, especially since (in my case) I can’t rely on administrators being the only users or asking users to launch from the commandline.

    Any idea when this might make the main release?

  2. This will get into IzPack in December for 4.2.0.

    You may also try it already by compiling the source code by yourself.

  3. This is a great new feature. But how can we use it? Is there a new xml tag for the setup.xml file for Izpack?

  4. Yes Tobi, it’s available now in IzPack 4.2.0.

    Add an empty “run-privileged” element in the “info” section.


Leave a comment


JPz'log is Digg proof thanks to caching by WP Super Cache