site_archiver@lists.apple.com Delivered-To: Darwin-dev@lists.apple.com User-agent: Thunderbird 2.0.0.16 (Macintosh/20080707) Hi, 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. 1) I should not use the fork/exec() combination in a daemon. And besides it causes major problems with closing file descriptors, and sometimes even crashes my App. 2) I haven't tried pthread_start(), but its very likely to be equal to (1), is it not? 3) Carbon's LSOpenApplication is neither daemon-safe, nor does it allow to execute as a specific user (or root, so I could setuid() myself). 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. 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)? Cheers, Mario _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com