Re: launchd daemon, spawning children?
Re: launchd daemon, spawning children?
- Subject: Re: launchd daemon, spawning children?
- From: Damien Sorresso <email@hidden>
- Date: Thu, 25 Sep 2008 13:56:52 -0700
On Sep 25, 2008, at 9:40 AM, Mario Emmenlauer wrote:
I have a problem understanding how things are done in a system-
conform way on the Mac. If this is not the right mailing list for
daemon questions, please point me to the correct one.
I want to write a (launchd) daemon that needs to execute processes
upon certain events. This poses quite a problem (to me?), especially
if I want to start the process as a dynamically changing user which
is typically not the current GUI user.
.
.
.
4) Using launchd() works great:
launch_data_t msg = launch_data_alloc(LAUNCH_DATA_DICTIONARY);
launch_data_dict_insert(msg,launch_data_new_string("com.c.App"),
LAUNCH_KEY_STARTJOB);
launch_data_t resp = launch_msg(msg);
but I am missing an interface to set the user. Of course a fixed
user can be chosen in the plist, but then its not dynamic. Also, I
can start an app as root with launchd and setuid from within this
app, but if someone exchanges the app, he will gain root access.
See launchd.plist(5). You can only set a UserName key in a daemon
running under the system launchd.
Though if you're looking to launch applications in user sessions from
a root-owned daemon, you're almost certainly going about it wrong. To
launch an application in a user session, you first have to get that
user's session up and running if it isn't already. We don't want third-
party developers trying to bootstrap user sessions.
I would strongly suggest creating an agent that runs for every user,
is limited to the Aqua session, listens for events and launches the
appropriate application using the appropriate high-level APIs found in
the LaunchServices or AppKit frameworks.
Am I missing something in the launchd API interface? How would one
typically write an ftp-daemon on Mac OS (i.e. write a daemon that
runs as root, then spawns a child that runs as the user that
requests ftp login)?
See the following documentation...
launchd.plist(5)
launchd(8)
http://developer.apple.com/technotes/tn2005/tn2083.html#SECDAEMONOMICON
--
Damien Sorresso
BSD Engineering
Apple Inc.
email@hidden
408.974.7488
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