Re: launchd and programmatic access
Re: launchd and programmatic access
- Subject: Re: launchd and programmatic access
- From: Jason Coco <email@hidden>
- Date: Fri, 3 Oct 2008 14:55:53 -0400
On Oct 3, 2008, at 14:02 , Damien Sorresso wrote:
On Oct 3, 2008, at 10:17 AM, Jason Coco wrote:
Hello all,
I have a question about the launchd API from launch.h...
background:
I have a daemon application that is using launchd but is a cross-
platform application so I can't make it totally launchd aware (it's
written in Java). It has a plist that lives in /Library/
LaunchDaemons and starts up properly without any issues.
My problem is that I have created a preference pane that I want the
console use to be able to use to get status, set some configuration
options and start/stop the service.
Your preference pane should talk to the application via IPC (in your
case, probably a Unix domain socket). You can specify the socket
path in your daemon's property list and get a file descriptor to the
socket when you check in with launchd.
I don't know much about Java, but I believe you can call C libraries
from it. If that's not feasible, create a C wrapper that grabs the
file descriptor sets a flag somewhere in the process' environment
and then exec(2)s your Java application. Then your Java app can look
at its environment and find where the previous occupant of the
address space stashed the descriptor.
Thanks for the advice, Damien. I'll re-work it to do something like
this... although, unfortunately, I can't alter the Java code at this
point so I'll have to have the wrapper program manage the without
using exec. I will have the wrapper manage everything, as you suggest,
and use IPC from the pref pane to do configuration. I do have one more
question on how you'd recommend the design of this... since I can't
alter the Java source right now, do you think it makes sense to add 2
plists to launchd... one being the wrapper and one being the Java app.
Then I could have the Java app depend on the wrapper and have the
wrapper instruct launchd to load and unload the app as needed. This
way I can check-in with launchd and communicate appropriately. Or...
do you think it's better to simply add the wrapper daemon to launchd
and then have the wrapper manage a fork/exec of the Java process?
The pref pane includes a setuid helper application that does proper
authorization, etc.
Your privileged operations should be done in your daemon. We heavily
discourage the use of setuid tools, and we're actively trying to
cleanse the system of them.
I agree... I didn't want to do it that way, but I didn't think of your
solution...
Thanks again, Jason
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden