[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: launchctl...configuring a launch daemon Ben Spink Sun Aug 30 20:00:56 2009

I haven't tested AuthKit on 10.6 yet, and I'm not in a position to do
so right now.  There is one caution: its JNI library is 32-bit only.
So make sure you're running under the 32-bit JVM.

If AuthKit still doesn't work, you should be able to use Runtime.exec
() to run 'sudo' with 'launchctl' as its target, but you have to
provide the password on its stdin stream and specify the -S option to
'sudo'.  This means you have to prompt the user for the password
first using whatever dialog you want, build the exec() args
accordingly, and then write the password with UTF8 encoding to the
outputStream() of the Process.  I recommend testing this with an
innocuous command like 'id' or 'printenv'.

Also, if your current Java process is already running as root, then
'sudo anything' will not need a password, because root is always
granted sudo access.  You may want to try that first, before the -S

You would think that, but it doesn't seem to hold true. I thought I had things fixed...until I realized that my sudo command I was putting in my Runtime.exec was only working since I had also recently issued it in my Terminal session. Once that timeout had expired, now my Java app was hanging as it was prompting for a password I wasn't providing.

CrushFTP is running as root...but that doesn't mean everything it launches will also be root. Almost everything...but somethings don't honor that. (Probably for good reason...but I thought my reason for wanting it was good too!) Running "bash" will ignore that it was executed by a root process. Running "sudo" will ignore it, and so will running "launchctl". All of those know your original userid...and instead of running under that context, run as your real userid.

I knew about the 32bit issue. I was running Java 1.5, 32bit on OS X 10.5.8. I'm trying to change my daemon install method from a script, to using launchctl...which will fix the 10.6 issue, but will also work fine on 10.4, and 10.5. Authkit worked fine when I wasn't already running as a root user, to make my app run as root. But now that its running as root, it gives that error.

My fall back is to ask for the password. That method is simpler for sure...but its also less elegant, and I hate apps myself that do that to me, so I am trying to avoid being one of those apps. :) My decision however may become forced.

Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      ([EMAIL PROTECTED])
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]