Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How Do I Run a Java App with Superuser Privileges?




On 14 Dec 2004, at 3:57 PM, William C. McCain wrote:

Is there a property in Info.plist that I can set to give my Java
application, packaged as a .app bundle, the superuser privilege?  Or
some other simple way to run a Java app with superuser privileges?

My application exposes a small, low-function, secure HTTP server (this
is not the main function of my application, but it is needed to support
a master/remote interface between machines on a local area network in a
user's home).  This requires superuser privileges.

It works fine in a shell when I prefix my application with "sudo".  But
I can't ask users to do that!  I have also been able to get it to work
from an AppleScript (something like 'do shell script "sudo open
MyApp"').  That will be what I will have to ship, unless there is a
better, more "transparent" solution.

Any ideas?

Since you say that the main function of of your application does not require root privileges, I would strongly suggest that you find some other solution than to run the whole thing as root.


Is the only reason it needs root so it can bind to port 80? Can you change your app to use a high numbered port, such that user privileges are sufficient.

If not, can you separate the small server part from the rest and only run it as root?

Once you've seprated your App into privileged and non privileged bits, you need a way to run the privileged bit as root.

With a bit of googling, I came across:

  http://www.amug.org/~glguerin/sw/#authkit/

From a quick browse through the online docs, this looks like exactly what you need. It uses the standard "Authorisation Services" built in to Mac OS X to authenticate as an administrator and run code as root.

--
Rohan Lloyd

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >How Do I Run a Java App with Superuser Privileges? (From: "William C. McCain" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.