From prepin at gmail.com Thu Jan 3 11:48:53 2008 From: prepin at gmail.com (Pavel Repin) Date: Thu Jan 3 11:46:55 2008 Subject: [launchd-dev] launchd for windows Message-ID: <4b217830801031148h33a37a12h2a0b5d4fdde1aca7@mail.gmail.com> Hi, Has anyone heard of or personally done any work on porting launchd to Windows? I know Vista has WAS (which is sort of like launchd but mostly tailored for deamon-like services), but launchd, if ported, has no reason to be exclusively tied to Vista, it can work on any version of Windows still in use. On one occassion, I've implemented an enormously severe subset of launchd which can be summarized by the only type of process configuration plist supported: Label my.service.1 ProgramArguments myservice1.exe -k run OnDemand And it was fun to do. I wonder if someone was more productive. -- Pavel Repin From richard at scl.utah.edu Tue Jan 15 16:33:51 2008 From: richard at scl.utah.edu (Richard Glaser) Date: Tue Jan 15 16:33:20 2008 Subject: [launchd-dev] launchd support ranges for StartCalendarInterval? Message-ID: <15E40734-E19C-418E-A420-A9ED1A099080@scl.utah.edu> FYI: Sorry, for this slightly off-topic.. Does launchd does support ranges say for "Days" in the StartCalendarInterval? For example, with cron if I wanted to run a script on the first & third Sunday of each month at 4 AM. I could use this code with a range... # minute hour mday month wday who command 0 4 1-7,15-21 * 0 root /path/to/script1 Then I could run another script the second & fourth Sunday of each month at 4 AM... # minute hour mday month wday who command 0 4 8-14,22-31 * 0 root /path/to/script2 Is this possible with launchd? Thanks: Richard Glaser University of Utah - Student Computing Labs richard@scl.utah.edu 801-585-8016 From richard at scl.utah.edu Tue Jan 15 16:37:46 2008 From: richard at scl.utah.edu (Richard Glaser) Date: Tue Jan 15 16:37:13 2008 Subject: [launchd-dev] launchd misinterpreting cron ranges? Message-ID: <7813777A-AF4F-4166-BD35-86D4DEE9B098@scl.utah.edu> FYI: Sorry, for this slightly off-topic.. I used the following cron lines with Mac OS X 10.4.11 Server, but with Mac OS X 10.5.1 Server it doesn't run correctly. It runs the scripts every day, versus 1st & 3rd or 2nd or 4th Sunday at 4 AM. # minute hour mday month wday who command 0 4 1-7,15-21 * 0 root /path/to/script1 0 4 8-14,22-31 * 0 root /path/to/script2 Is this a bug or is there a workaround? Thanks: Richard Glaser University of Utah - Student Computing Labs richard@scl.utah.edu 801-585-8016 From zarzycki at apple.com Wed Jan 16 08:39:24 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Wed Jan 16 08:40:26 2008 Subject: [launchd-dev] launchd support ranges for StartCalendarInterval? In-Reply-To: <15E40734-E19C-418E-A420-A9ED1A099080@scl.utah.edu> References: <15E40734-E19C-418E-A420-A9ED1A099080@scl.utah.edu> Message-ID: <6A16FE36-33C1-4091-A1CF-7BEDF2F7F3BB@apple.com> Yes, you can do this. Have StartCalendarInterval be an array of dictionaries instead of just a dictionary within the configuration file. Having said that, it would be nice if launchd natively supported some of the common calendar expressions such as {first,second,third,forth,last,second-to-last} {mon,tue,wed,thr,fri,sat,sun}. Doing so would save people the trouble of figuring out the ranges. Feel free to file an enhancement request, davez P.S. -- I've occasionally wanted, just for giggles, to have launchd to support other time intervals such as "only during leap years" or the ability to schedule jobs based on the phase of the moon, or the solstices/equinoxes. I've even considered adding planetary alignment to the schema. :-P On Jan 15, 2008, at 4:33 PM, Richard Glaser wrote: > FYI: > > Sorry, for this slightly off-topic.. > > Does launchd does support ranges say for "Days" in the > StartCalendarInterval? > > For example, with cron if I wanted to run a script on the first & > third Sunday of each month at 4 AM. I could use this code with a > range... > > # minute hour mday month wday who command > 0 4 1-7,15-21 * 0 root /path/to/script1 > > Then I could run another script the second & fourth Sunday of each > month at 4 AM... > > # minute hour mday month wday who command > 0 4 8-14,22-31 * 0 root /path/to/script2 > > Is this possible with launchd? > > Thanks: > > Richard Glaser > University of Utah - Student Computing Labs > richard@scl.utah.edu > 801-585-8016 > > _______________________________________________ > launchd-dev mailing list > launchd-dev@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo/launchd-dev From zarzycki at apple.com Wed Jan 16 08:59:19 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Wed Jan 16 09:00:16 2008 Subject: [launchd-dev] A launchd blog post Message-ID: And while we are on the topic of the last email, I just created a blog post: http://launchd.macosforge.org/?p=5 Cheers, davez From richard at scl.utah.edu Thu Jan 17 08:17:27 2008 From: richard at scl.utah.edu (Richard Glaser) Date: Thu Jan 17 08:16:53 2008 Subject: [launchd-dev] launchd support ranges for StartCalendarInterval? In-Reply-To: <6A16FE36-33C1-4091-A1CF-7BEDF2F7F3BB@apple.com> References: <15E40734-E19C-418E-A420-A9ED1A099080@scl.utah.edu> <6A16FE36-33C1-4091-A1CF-7BEDF2F7F3BB@apple.com> Message-ID: Hello Dave: Ok, I filled it with BugReporter. Here is the bug ID... 5689503 launchd support for ranges Also, any suggestions on why a cron job with the ranges listed below would run the script daily at 4 AM vs 1st & 3rd Sun @ 4 AM and 2nd & 4th Sun @ 4 AM. Does it should like an issue with how launchd is interpreting the cron task? This is on Mac OS X 10.5.1 Server... Here is the bug ID... 5689564 Mac OS X 10.5.1 Server Launchd not running crontabs with ranges correctly On Jan 16, 2008, at 9:39 AM, Dave Zarzycki wrote: > Yes, you can do this. Have StartCalendarInterval be an array of > dictionaries instead of just a dictionary within the configuration > file. Having said that, it would be nice if launchd natively > supported some of the common calendar expressions such as > {first,second,third,forth,last,second-to-last} > {mon,tue,wed,thr,fri,sat,sun}. Doing so would save people the > trouble of figuring out the ranges. > > Feel free to file an enhancement request, > > davez > > P.S. -- I've occasionally wanted, just for giggles, to have launchd > to support other time intervals such as "only during leap years" or > the ability to schedule jobs based on the phase of the moon, or the > solstices/equinoxes. I've even considered adding planetary alignment > to the schema. :-P > > > > On Jan 15, 2008, at 4:33 PM, Richard Glaser wrote: > >> FYI: >> >> Sorry, for this slightly off-topic.. >> >> Does launchd does support ranges say for "Days" in the >> StartCalendarInterval? >> >> For example, with cron if I wanted to run a script on the first & >> third Sunday of each month at 4 AM. I could use this code with a >> range... >> >> # minute hour mday month wday who command >> 0 4 1-7,15-21 * 0 root /path/to/script1 >> >> Then I could run another script the second & fourth Sunday of each >> month at 4 AM... >> >> # minute hour mday month wday who command >> 0 4 8-14,22-31 * 0 root /path/to/script2 >> >> Is this possible with launchd? >> >> Thanks: >> >> Richard Glaser >> University of Utah - Student Computing Labs >> richard@scl.utah.edu >> 801-585-8016 >> >> _______________________________________________ >> launchd-dev mailing list >> launchd-dev@lists.macosforge.org >> http://lists.macosforge.org/mailman/listinfo/launchd-dev > Thanks, Richard Glaser University of Utah - Student Computing Labs From jaharmi at jaharmi.com Fri Jan 18 07:45:47 2008 From: jaharmi at jaharmi.com (Jeremy Reichman) Date: Fri Jan 18 07:45:15 2008 Subject: [launchd-dev] Loading LaunchDaemons Message-ID: Do new jobs that are copied to a directory like /Library/LaunchDaemons get loaded automatically by the system at startup, so that they run when they would normally be scheduled? Or must we specifically load them with launchctl? I've looked back through the launchd and launchctl man pages and I don't see there whether a new job must be explicitly loaded, or if simply having it in the right directory at startup is enough to load/activate it. I have a custom LaunchDaemon which works fine when loaded -- I'm very enthusiastic about how well it works on Leopard vs. Tiger, because the job is scheduled to run when systems are typically asleep. The new behavior of running the job at wakeup is great. Anyway, on some systems (all of which are Intel-based Macs running 10.5.1 with all current updates except for iTunes 7.6 and QuickTime 7.4), the job I've installed does not and has not been running, even though the computers in question have been rebooted multiple times. It appears the job itself is not loading; when I grep for it in the long results of `launchctl list`, I don't see it. (Loading it manually does show that it is loaded, of course.) The LaunchDaemon file was installed by a simple copy -- actually, via the Radmind system management tool. Ergo, `launchctl load` was never explicitly run on it on any of the systems, but I seem to get different behavior -- some load it, some don't. (I'm still in the process of collecting information on where it works and where it doesn't.) Thanks! -- Jeremy From launchd at khiltd.com Fri Jan 18 08:20:59 2008 From: launchd at khiltd.com (Nathan Duran) Date: Fri Jan 18 08:20:18 2008 Subject: [launchd-dev] Loading LaunchDaemons In-Reply-To: References: Message-ID: <68E4A610-3BC1-498B-9E97-63166C1CE4EA@khiltd.com> On Jan 18, 2008, at 7:45 AM, Jeremy Reichman wrote: > The LaunchDaemon file was installed by a simple copy -- actually, > via the > Radmind system management tool. What permissions were set on the copy? From zarzycki at apple.com Fri Jan 18 08:52:54 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Fri Jan 18 08:53:41 2008 Subject: [launchd-dev] Loading LaunchDaemons In-Reply-To: References: Message-ID: On Jan 18, 2008, at 7:45 AM, Jeremy Reichman wrote: > Do new jobs that are copied to a directory like /Library/ > LaunchDaemons get > loaded automatically by the system at startup, so that they run when > they > would normally be scheduled? Or must we specifically load them with > launchctl? They get loaded at boot (or in the case of agents: at login). One should only need to run launchctl during prototyping/development of the job. > I've looked back through the launchd and launchctl man pages and I > don't see > there whether a new job must be explicitly loaded, or if simply > having it in > the right directory at startup is enough to load/activate it. I suppose that the documentation on that fact could be better. Feel free to file a bug. > I have a custom LaunchDaemon which works fine when loaded -- I'm very > enthusiastic about how well it works on Leopard vs. Tiger, because > the job > is scheduled to run when systems are typically asleep. The new > behavior of > running the job at wakeup is great. Thanks! :-) > Anyway, on some systems (all of which are Intel-based Macs running > 10.5.1 > with all current updates except for iTunes 7.6 and QuickTime 7.4), > the job > I've installed does not and has not been running, even though the > computers > in question have been rebooted multiple times. It appears the job > itself is > not loading; when I grep for it in the long results of `launchctl > list`, I > don't see it. (Loading it manually does show that it is loaded, of > course.) Are you running "launchctl list" or "sudo launchctl list"? Also, is launchd complaining about anything in the logs? Good luck, davez From jaharmi at jaharmi.com Fri Jan 18 10:25:51 2008 From: jaharmi at jaharmi.com (Jeremy Reichman) Date: Fri Jan 18 10:25:20 2008 Subject: [launchd-dev] Loading LaunchDaemons In-Reply-To: <68E4A610-3BC1-498B-9E97-63166C1CE4EA@khiltd.com> Message-ID: On 1/18/2008 11:20:59 AM, "Nathan Duran" wrote: >> The LaunchDaemon file was installed by a simple copy -- actually, >> via the >> Radmind system management tool. > > What permissions were set on the copy? They are 644, root:wheel. -- Jeremy From jaharmi at jaharmi.com Fri Jan 18 10:28:20 2008 From: jaharmi at jaharmi.com (Jeremy Reichman) Date: Fri Jan 18 10:27:47 2008 Subject: [launchd-dev] Loading LaunchDaemons In-Reply-To: Message-ID: On 1/18/2008 11:52:54 AM, "Dave Zarzycki" wrote: > Are you running "launchctl list" or "sudo launchctl list"? > > Also, is launchd complaining about anything in the logs? I ran `launchctl list` in an admin account, but without sudo, on the first computer I've noticed this on. I'm investigating further on others. Without sudoing, running `load` and then `list` did show different results. I haven't checked the logs thoroughly yet, as I didn't have a lot of face time with the computer (had someone waiting to use it for their work) but I'll revisit that to see if I notice anything out of the ordinary. -- Jeremy From fasteddy760 at gmail.com Fri Jan 18 11:52:00 2008 From: fasteddy760 at gmail.com (Eddy Martinez) Date: Fri Jan 18 14:15:43 2008 Subject: [launchd-dev] launchd not loading for me in Leopard Message-ID: <0D159F99-FFFB-41FB-92FF-20F64164622D@gmail.com> Hello, I've been searching around and have not been able to find any hints. I have a plist, pref pane based app that fires off at a preset time. With Tiger its all good. However Leopard is failing to run the app at the scheduled time. Pasted are some errors that I hope will help to identify the problem. I'm not the developer, who is a contractor dealing with another deadline. I'm hoping to gather information on his behalf in order to expedite the resolution. I have access to the dev boxes and can run commands and capture any needed output. Any help appreciated, and thanks in advance, Eddy vmini01:~ $ cat /tmp/agentLauncher.stderr 2008-01-17 12:38:00.136 AgentLauncher[218:20b] Cannot checkin with launchd, exiting. 2008-01-17 14:14:00.032 AgentLauncher[323:20b] Cannot checkin with launchd, exiting. 2008-01-17 14:36:00.057 AgentLauncher[389:20b] Cannot checkin with launchd, exiting. vmini01:~ $ vmini01:~$ tail -f /var/log/system.log | grep devapp Jan 18 10:54:44 vmini01 com.apple.launchd[1] (com.devapp.AgentLauncher): Unknown key for array: excluded Jan 18 10:54:44 vmini01 com.apple.launchd[1] (com.devapp.AgentLauncher): Unknown key for boolean: Enabled Jan 18 10:54:44 vmini01 com.apple.launchd[1] (com.devapp.AgentLauncher): Unknown key for array: included Jan 18 10:54:44 vmini01 com.apple.launchd[1] (com.devapp.AgentLauncher): Unknown key: ServiceDescription Jan 18 10:54:44 vmini01 com.apple.launchd[1] (com.devapp.AgentLauncher): Unknown key: server Jan 18 10:54:44 vmini01 com.apple.launchd[1] (com.devapp.AgentLauncher): Unknown key for string: cistern Jan 18 10:54:44 vmini01 com.apple.launchd[1] (com.devapp.AgentLauncher): Unknown key: bucket Jan 18 10:54:44 vmini01 com.apple.launchd[1] (com.devapp.AgentLauncher): Unknown key for integer: finish Jan 18 10:54:44 vmini01 com.apple.launchd[1] (com.devapp.AgentLauncher): Unknown key for string: CustomerID Jan 18 10:54:44 vmini01 com.apple.launchd[1] (com.devapp.AgentLauncher): Unknown key: CustomerID vmini01:~ eddy$ sudo launchctl list | grep devapp - 1 com.devapp.AgentLauncher vmini01:~ $ ls -la /Library/LaunchDaemons/ total 8 drwxr-xr-x 3 root wheel 102 Jan 18 10:54 . drwxrwxr-t+ 46 root admin 1564 Sep 14 10:14 .. -rw-r--r-- 1 root wheel 1248 Jan 18 10:54 com.devapp.AgentLauncher.plist vmini01:~ $ -- Eddy Martinez fasteddy760@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-dev/attachments/20080118/7d0efe50/attachment.html From launchd at khiltd.com Fri Jan 18 14:39:25 2008 From: launchd at khiltd.com (Nathan Duran) Date: Fri Jan 18 14:38:44 2008 Subject: [launchd-dev] launchd not loading for me in Leopard In-Reply-To: <0D159F99-FFFB-41FB-92FF-20F64164622D@gmail.com> References: <0D159F99-FFFB-41FB-92FF-20F64164622D@gmail.com> Message-ID: On Jan 18, 2008, at 11:52 AM, Eddy Martinez wrote: > Pasted are some errors that I hope will help to identify the problem. What's actually in the plist? From fasteddy760 at gmail.com Fri Jan 18 15:16:40 2008 From: fasteddy760 at gmail.com (Eddy Martinez) Date: Fri Jan 18 15:49:12 2008 Subject: [launchd-dev] launchd not loading for me in Leopard In-Reply-To: <0D159F99-FFFB-41FB-92FF-20F64164622D@gmail.com> References: <0D159F99-FFFB-41FB-92FF-20F64164622D@gmail.com> Message-ID: <9838E936-9329-449C-915B-1763C66E602E@gmail.com> Plist - CustomerID 8587928649 Enabled Label com.devapp.AgentLauncher Program /usr/local/sbin/AgentLauncher ProgramArguments /usr/local/sbin/AgentLauncher ServiceDescription devapp launcher ServiceIPC StandardErrorPath /tmp/agentLauncher.stderr StandardOutPath /tmp/agentLauncher.stdout StartCalendarInterval Hour 22 Minute 55 UserName root WorkingDirectory /tmp cistern bucket excluded finish 360 included /Users/eddy/Desktop server server.devappdevappdevapp.com On Jan 18, 2008, at 11:52 AM, Eddy Martinez wrote: > Hello, > > I've been searching around and have not been able to find any > hints. I have a plist, pref > pane based app that fires off at a preset time. With Tiger its all > good. However Leopard > is failing to run the app at the scheduled time. > > Pasted are some errors that I hope will help to identify the > problem. I'm not the developer, > who is a contractor dealing with another deadline. I'm hoping to > gather information on his > behalf in order to expedite the resolution. > > I have access to the dev boxes and can run commands and capture any > needed output. > > Any help appreciated, and thanks in advance, > Eddy > > vmini01:~ $ cat /tmp/agentLauncher.stderr > 2008-01-17 12:38:00.136 AgentLauncher[218:20b] Cannot checkin with > launchd, exiting. > 2008-01-17 14:14:00.032 AgentLauncher[323:20b] Cannot checkin with > launchd, exiting. > 2008-01-17 14:36:00.057 AgentLauncher[389:20b] Cannot checkin with > launchd, exiting. > vmini01:~ $ > > > vmini01:~$ tail -f /var/log/system.log | grep devapp > Jan 18 10:54:44 vmini01 com.apple.launchd[1] > (com.devapp.AgentLauncher): Unknown key for array: excluded > Jan 18 10:54:44 vmini01 com.apple.launchd[1] > (com.devapp.AgentLauncher): Unknown key for boolean: Enabled > Jan 18 10:54:44 vmini01 com.apple.launchd[1] > (com.devapp.AgentLauncher): Unknown key for array: included > Jan 18 10:54:44 vmini01 com.apple.launchd[1] > (com.devapp.AgentLauncher): Unknown key: ServiceDescription > Jan 18 10:54:44 vmini01 com.apple.launchd[1] > (com.devapp.AgentLauncher): Unknown key: server > Jan 18 10:54:44 vmini01 com.apple.launchd[1] > (com.devapp.AgentLauncher): Unknown key for string: cistern > Jan 18 10:54:44 vmini01 com.apple.launchd[1] > (com.devapp.AgentLauncher): Unknown key: bucket > Jan 18 10:54:44 vmini01 com.apple.launchd[1] > (com.devapp.AgentLauncher): Unknown key for integer: finish > Jan 18 10:54:44 vmini01 com.apple.launchd[1] > (com.devapp.AgentLauncher): Unknown key for string: CustomerID > Jan 18 10:54:44 vmini01 com.apple.launchd[1] > (com.devapp.AgentLauncher): Unknown key: CustomerID > > > vmini01:~ eddy$ sudo launchctl list | grep devapp > - 1 com.devapp.AgentLauncher > > vmini01:~ $ ls -la /Library/LaunchDaemons/ > total 8 > drwxr-xr-x 3 root wheel 102 Jan 18 10:54 . > drwxrwxr-t+ 46 root admin 1564 Sep 14 10:14 .. > -rw-r--r-- 1 root wheel 1248 Jan 18 10:54 > com.devapp.AgentLauncher.plist > vmini01:~ $ > > > -- > Eddy Martinez > fasteddy760@gmail.com > > > > _______________________________________________ > launchd-dev mailing list > launchd-dev@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo/launchd-dev -- Eddy Martinez fasteddy760@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-dev/attachments/20080118/b582c2ee/attachment.html From launchd at khiltd.com Fri Jan 18 16:09:50 2008 From: launchd at khiltd.com (Nathan Duran) Date: Fri Jan 18 16:09:08 2008 Subject: [launchd-dev] launchd not loading for me in Leopard In-Reply-To: <9838E936-9329-449C-915B-1763C66E602E@gmail.com> References: <0D159F99-FFFB-41FB-92FF-20F64164622D@gmail.com> <9838E936-9329-449C-915B-1763C66E602E@gmail.com> Message-ID: <16D24849-38F8-465B-AC36-ACA185733FDC@khiltd.com> On Jan 18, 2008, at 3:16 PM, Eddy Martinez wrote: > Plist - Well I think I see 7 completely invalid keys in there. From the looks of it I'd say your developer was trying to get out of having to implement his own preferences file handling by shoving everything in the launchd plist. Whether launchd is supposed to tolerate this or not I don't know, but I'd take all that stuff out of there and see if it doesn't work a little better. From zarzycki at apple.com Fri Jan 18 16:11:25 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Fri Jan 18 16:11:11 2008 Subject: [launchd-dev] launchd not loading for me in Leopard In-Reply-To: <9838E936-9329-449C-915B-1763C66E602E@gmail.com> References: <0D159F99-FFFB-41FB-92FF-20F64164622D@gmail.com> <9838E936-9329-449C-915B-1763C66E602E@gmail.com> Message-ID: <9A0CA5C2-C288-4952-B403-03B93D623B9E@apple.com> Eddy, Your program appears to be overloading the launchd schema for the storage of private preferences. That was not supported in Tiger, and that is now enforced in Leopard. Please update the code to manage preferences elsewhere. Thanks! davez On Jan 18, 2008, at 3:16 PM, Eddy Martinez wrote: > Plist - > > > "> > > > CustomerID > 8587928649 > Enabled > > Label > com.devapp.AgentLauncher > Program > /usr/local/sbin/AgentLauncher > ProgramArguments > > /usr/local/sbin/AgentLauncher > > ServiceDescription > devapp launcher > ServiceIPC > > StandardErrorPath > /tmp/agentLauncher.stderr > StandardOutPath > /tmp/agentLauncher.stdout > StartCalendarInterval > > Hour > 22 > Minute > 55 > > UserName > root > WorkingDirectory > /tmp > cistern > bucket > excluded > > finish > 360 > included > > /Users/eddy/Desktop > > server > server.devappdevappdevapp.com > > > > > > > On Jan 18, 2008, at 11:52 AM, Eddy Martinez wrote: > >> Hello, >> >> I've been searching around and have not been able to find any >> hints. I have a plist, pref >> pane based app that fires off at a preset time. With Tiger its all >> good. However Leopard >> is failing to run the app at the scheduled time. >> >> Pasted are some errors that I hope will help to identify the >> problem. I'm not the developer, >> who is a contractor dealing with another deadline. I'm hoping to >> gather information on his >> behalf in order to expedite the resolution. >> >> I have access to the dev boxes and can run commands and capture any >> needed output. >> >> Any help appreciated, and thanks in advance, >> Eddy >> >> vmini01:~ $ cat /tmp/agentLauncher.stderr >> 2008-01-17 12:38:00.136 AgentLauncher[218:20b] Cannot checkin with >> launchd, exiting. >> 2008-01-17 14:14:00.032 AgentLauncher[323:20b] Cannot checkin with >> launchd, exiting. >> 2008-01-17 14:36:00.057 AgentLauncher[389:20b] Cannot checkin with >> launchd, exiting. >> vmini01:~ $ >> >> >> vmini01:~$ tail -f /var/log/system.log | grep devapp >> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >> (com.devapp.AgentLauncher): Unknown key for array: excluded >> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >> (com.devapp.AgentLauncher): Unknown key for boolean: Enabled >> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >> (com.devapp.AgentLauncher): Unknown key for array: included >> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >> (com.devapp.AgentLauncher): Unknown key: ServiceDescription >> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >> (com.devapp.AgentLauncher): Unknown key: server >> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >> (com.devapp.AgentLauncher): Unknown key for string: cistern >> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >> (com.devapp.AgentLauncher): Unknown key: bucket >> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >> (com.devapp.AgentLauncher): Unknown key for integer: finish >> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >> (com.devapp.AgentLauncher): Unknown key for string: CustomerID >> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >> (com.devapp.AgentLauncher): Unknown key: CustomerID >> >> >> vmini01:~ eddy$ sudo launchctl list | grep devapp >> - 1 com.devapp.AgentLauncher >> >> vmini01:~ $ ls -la /Library/LaunchDaemons/ >> total 8 >> drwxr-xr-x 3 root wheel 102 Jan 18 10:54 . >> drwxrwxr-t+ 46 root admin 1564 Sep 14 10:14 .. >> -rw-r--r-- 1 root wheel 1248 Jan 18 10:54 >> com.devapp.AgentLauncher.plist >> vmini01:~ $ >> >> >> -- >> Eddy Martinez >> fasteddy760@gmail.com >> >> >> >> _______________________________________________ >> launchd-dev mailing list >> launchd-dev@lists.macosforge.org >> http://lists.macosforge.org/mailman/listinfo/launchd-dev > > > > -- > Eddy Martinez > fasteddy760@gmail.com > > > > _______________________________________________ > launchd-dev mailing list > launchd-dev@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo/launchd-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-dev/attachments/20080118/4d675a64/attachment-0001.html From fasteddy760 at gmail.com Fri Jan 18 16:46:16 2008 From: fasteddy760 at gmail.com (Eddy Martinez) Date: Fri Jan 18 17:04:47 2008 Subject: [launchd-dev] launchd not loading for me in Leopard In-Reply-To: <9A0CA5C2-C288-4952-B403-03B93D623B9E@apple.com> References: <0D159F99-FFFB-41FB-92FF-20F64164622D@gmail.com> <9838E936-9329-449C-915B-1763C66E602E@gmail.com> <9A0CA5C2-C288-4952-B403-03B93D623B9E@apple.com> Message-ID: Nathan & Dave, thanks for the help. Feel free to take the rest of the day off, Eddy On Jan 18, 2008, at 4:11 PM, Dave Zarzycki wrote: > Eddy, > > Your program appears to be overloading the launchd schema for the > storage of private preferences. That was not supported in Tiger, > and that is now enforced in Leopard. Please update the code to > manage preferences elsewhere. > > Thanks! > > davez > > > On Jan 18, 2008, at 3:16 PM, Eddy Martinez wrote: > >> Plist - >> >> >> > www.apple.com/DTDs/PropertyList-1.0.dtd"> >> >> >> CustomerID >> 8587928649 >> Enabled >> >> Label >> com.devapp.AgentLauncher >> Program >> /usr/local/sbin/AgentLauncher >> ProgramArguments >> >> /usr/local/sbin/AgentLauncher >> >> ServiceDescription >> devapp launcher >> ServiceIPC >> >> StandardErrorPath >> /tmp/agentLauncher.stderr >> StandardOutPath >> /tmp/agentLauncher.stdout >> StartCalendarInterval >> >> Hour >> 22 >> Minute >> 55 >> >> UserName >> root >> WorkingDirectory >> /tmp >> cistern >> bucket >> excluded >> >> finish >> 360 >> included >> >> /Users/eddy/Desktop >> >> server >> server.devappdevappdevapp.com >> >> >> >> >> >> >> On Jan 18, 2008, at 11:52 AM, Eddy Martinez wrote: >> >>> Hello, >>> >>> I've been searching around and have not been able to find any >>> hints. I have a plist, pref >>> pane based app that fires off at a preset time. With Tiger its >>> all good. However Leopard >>> is failing to run the app at the scheduled time. >>> >>> Pasted are some errors that I hope will help to identify the >>> problem. I'm not the developer, >>> who is a contractor dealing with another deadline. I'm hoping to >>> gather information on his >>> behalf in order to expedite the resolution. >>> >>> I have access to the dev boxes and can run commands and capture >>> any needed output. >>> >>> Any help appreciated, and thanks in advance, >>> Eddy >>> >>> vmini01:~ $ cat /tmp/agentLauncher.stderr >>> 2008-01-17 12:38:00.136 AgentLauncher[218:20b] Cannot checkin >>> with launchd, exiting. >>> 2008-01-17 14:14:00.032 AgentLauncher[323:20b] Cannot checkin >>> with launchd, exiting. >>> 2008-01-17 14:36:00.057 AgentLauncher[389:20b] Cannot checkin >>> with launchd, exiting. >>> vmini01:~ $ >>> >>> >>> vmini01:~$ tail -f /var/log/system.log | grep devapp >>> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >>> (com.devapp.AgentLauncher): Unknown key for array: excluded >>> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >>> (com.devapp.AgentLauncher): Unknown key for boolean: Enabled >>> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >>> (com.devapp.AgentLauncher): Unknown key for array: included >>> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >>> (com.devapp.AgentLauncher): Unknown key: ServiceDescription >>> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >>> (com.devapp.AgentLauncher): Unknown key: server >>> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >>> (com.devapp.AgentLauncher): Unknown key for string: cistern >>> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >>> (com.devapp.AgentLauncher): Unknown key: bucket >>> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >>> (com.devapp.AgentLauncher): Unknown key for integer: finish >>> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >>> (com.devapp.AgentLauncher): Unknown key for string: CustomerID >>> Jan 18 10:54:44 vmini01 com.apple.launchd[1] >>> (com.devapp.AgentLauncher): Unknown key: CustomerID >>> >>> >>> vmini01:~ eddy$ sudo launchctl list | grep devapp >>> - 1 com.devapp.AgentLauncher >>> >>> vmini01:~ $ ls -la /Library/LaunchDaemons/ >>> total 8 >>> drwxr-xr-x 3 root wheel 102 Jan 18 10:54 . >>> drwxrwxr-t+ 46 root admin 1564 Sep 14 10:14 .. >>> -rw-r--r-- 1 root wheel 1248 Jan 18 10:54 >>> com.devapp.AgentLauncher.plist >>> vmini01:~ $ >>> >>> >>> -- >>> Eddy Martinez >>> fasteddy760@gmail.com >>> >>> >>> >>> _______________________________________________ >>> launchd-dev mailing list >>> launchd-dev@lists.macosforge.org >>> http://lists.macosforge.org/mailman/listinfo/launchd-dev >> >> >> >> -- >> Eddy Martinez >> fasteddy760@gmail.com >> >> >> >> _______________________________________________ >> launchd-dev mailing list >> launchd-dev@lists.macosforge.org >> http://lists.macosforge.org/mailman/listinfo/launchd-dev > -- Eddy Martinez fasteddy760@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-dev/attachments/20080118/e3d07f68/attachment-0001.html From hamish at gmail.com Wed Jan 23 14:23:57 2008 From: hamish at gmail.com (Hamish Allan) Date: Wed Jan 23 14:23:52 2008 Subject: [launchd-dev] Binding an individual user's agent to a privileged port Message-ID: <597e7edb0801231423k5a0f2f46r557c30676c14c432@mail.gmail.com> >From "Getting started with launchd" (http://developer.apple.com/macosx/launchd.html): "Of particular interest is that launchd can run a job as a non-root user, but still bind it to a privileged port. This removes one common reason to run daemons as root." Is it possible for a user agent to be bound to a privileged port? This might sound like an odd thing to do, but I wish to automatically mount a remote SMB share on my local machine using SSH port forwarding. Unfortunately, since Finder is too stupid to let me mount shares at alternative ports on localhost (it tells me that I should just access the files locally!) and mount_smbfs doesn't take a port argument, I need to bind the remote ports 139 and 445 to the same ports on my local machine. I want this as an agent rather than a daemon for the purposes of SSH key management. It needs to run as an agent in the GUI context when I log in, as this is where the automatic SSH_AUTH_SOCK facility in Leopard lives. As far as I can tell, there are two ways of demonstrating to launchd that you have the authority to perform privileged operations such as binding to a port < 1024: putting a plist file in /Library/Launch*, or running launchctl sudo. The former means that the operation would be executed for all users, and the latter is sort of missing the point of the original exercise (not to mention bringing file permissions problems of its own). Is what I am trying to do possible with launchd? Hamish From subscriber at gloaming.com Fri Jan 25 10:21:50 2008 From: subscriber at gloaming.com (James Bucanek) Date: Fri Jan 25 10:21:43 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail Message-ID: Greetings, I have a user launch agent (~/Library/LaunchAgents) that has KeepAlive set to true. The launch agent is a Cocoa application, UIElement=YES. It provides a small status window to the user. I want this application to run all of the time, which is why the KeepAlive property was set. Whenever my application quits, launchd restarts it (as one would expect). The problem is that when the user tries to log out, the agent quits, launchd immediately restarts it, and the user gets a nasty message that the logout/restart/shutdown was canceled by my application. [There's clearly an amusing race condition: Once it's down to the Finder, launchd, my application and maybe one or two other small applications, the system manages to log out by killing my app and launchd before launchd has a chance to restart my application again.] Anyway, is there a workaround for this or do I just have to abandon KeepAlive? -- James Bucanek From launchd at khiltd.com Fri Jan 25 10:32:01 2008 From: launchd at khiltd.com (Nathan Duran) Date: Fri Jan 25 10:31:52 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: References: Message-ID: <9AD4CB61-2B3B-425A-B52B-66D5F888CB1F@khiltd.com> On Jan 25, 2008, at 10:21 AM, James Bucanek wrote: > Anyway, is there a workaround for this or do I just have to abandon > KeepAlive? Why not have your application unload the launchd job when it receives the shutdown event? From subscriber at gloaming.com Fri Jan 25 10:38:26 2008 From: subscriber at gloaming.com (James Bucanek) Date: Fri Jan 25 10:38:17 2008 Subject: [launchd-dev] Agent started two different was, two different bootstraps? Message-ID: Hello again, I've got a persistent oddity. I have a drag-install application that automatically installs a couple of launch agents with configuration plists (in ~/Library/LaunchAgents/). The processes and my GUI Cocoa application all communicate using distributed objects via Mach ports. When the agents get installed the first time, I kick-start them using 'launchctl load ...'. The problem is this: The two launch agents are installed and started using launchctl load (running launchctl as the regular user). The Cocoa application then starts a helper process (using NSTask) which registers a named Mach port. Now at this point, I would think that all four processes should be running in the Auqa bootstrap (the Cocoa application, the agent, and the helper process). But the agent can't see/connect with the Mach port registered by the helper process. The application can see it, connect to it, and does its thing. But when one of the agents attempts to connect with the same helper process, they get an error. Here's the oddity: If I restart the computer things appear to work correctly. When they agents are started automatically as part of the user's login procedure, they all communicate with each other just fine. Am I loading the agents incorrectly? Is this a known problem, or do I have to try to develop a reproducible case and file a bug report? From hamish at gmail.com Fri Jan 25 10:53:03 2008 From: hamish at gmail.com (Hamish Allan) Date: Fri Jan 25 10:52:50 2008 Subject: [launchd-dev] Agent started two different was, two different bootstraps? In-Reply-To: References: Message-ID: <597e7edb0801251053i100ea67ew37f18fab20cad535@mail.gmail.com> On Jan 25, 2008 6:38 PM, James Bucanek wrote: > I kick-start them using 'launchctl load ...'. Using 'launchctl load -s Aqua ...'? Hamish From zarzycki at apple.com Fri Jan 25 11:13:34 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Fri Jan 25 11:14:51 2008 Subject: [launchd-dev] Agent started two different was, two different bootstraps? In-Reply-To: <597e7edb0801251053i100ea67ew37f18fab20cad535@mail.gmail.com> References: <597e7edb0801251053i100ea67ew37f18fab20cad535@mail.gmail.com> Message-ID: -S, not -s, but otherwise, that is probably the solution. That should solve it for Leopard (until we make those directories "hot" and automagically load plists that get installed there. I make no promises and about when or if that will get implemented). davez On Jan 25, 2008, at 10:53 AM, Hamish Allan wrote: > On Jan 25, 2008 6:38 PM, James Bucanek > wrote: > >> I kick-start them using 'launchctl load ...'. > > Using 'launchctl load -s Aqua ...'? > > Hamish > _______________________________________________ > launchd-dev mailing list > launchd-dev@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo/launchd-dev From zarzycki at apple.com Fri Jan 25 11:14:05 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Fri Jan 25 11:15:22 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: References: Message-ID: Please file a bug: http://bugreport.apple.com/ Thanks! davez On Jan 25, 2008, at 10:21 AM, James Bucanek wrote: > Greetings, > > I have a user launch agent (~/Library/LaunchAgents) that has > KeepAlive set to true. The launch agent is a Cocoa application, > UIElement=YES. It provides a small status window to the user. > > I want this application to run all of the time, which is why the > KeepAlive property was set. Whenever my application quits, launchd > restarts it (as one would expect). The problem is that when the user > tries to log out, the agent quits, launchd immediately restarts it, > and the user gets a nasty message that the logout/restart/shutdown > was canceled by my application. > > [There's clearly an amusing race condition: Once it's down to the > Finder, launchd, my application and maybe one or two other small > applications, the system manages to log out by killing my app and > launchd before launchd has a chance to restart my application again.] > > Anyway, is there a workaround for this or do I just have to abandon > KeepAlive? > > -- > James Bucanek > > _______________________________________________ > launchd-dev mailing list > launchd-dev@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo/launchd-dev From subscriber at gloaming.com Fri Jan 25 11:16:18 2008 From: subscriber at gloaming.com (James Bucanek) Date: Fri Jan 25 11:16:08 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: <9AD4CB61-2B3B-425A-B52B-66D5F888CB1F@khiltd.com> Message-ID: Nathan Duran wrote (Friday, January 25, 2008 11:32 AM -0800): > On Jan 25, 2008, at 10:21 AM, James Bucanek wrote: > > >Anyway, is there a workaround for this or do I just have to > >abandon KeepAlive? > > Why not have your application unload the launchd job when it receives the shutdown event? That's a interesting idea. Will the unload be forgotten the next time the user logs back in? -- James Bucanek From launchd at khiltd.com Fri Jan 25 11:27:10 2008 From: launchd at khiltd.com (Nathan Duran) Date: Fri Jan 25 11:27:03 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: References: Message-ID: <1EA51C2B-2CF8-491F-B9F8-D928435946E6@khiltd.com> On Jan 25, 2008, at 11:16 AM, James Bucanek wrote: > That's a interesting idea. Will the unload be forgotten the next > time the user logs back in? launchctl unload does not alter the plist unless you supply the -w option. From subscriber at gloaming.com Fri Jan 25 11:28:32 2008 From: subscriber at gloaming.com (James Bucanek) Date: Fri Jan 25 11:28:22 2008 Subject: [launchd-dev] Agent started two different was, two different bootstraps? In-Reply-To: Message-ID: Hamish Allan wrote (Friday, January 25, 2008 11:53 AM -0000): > >Using 'launchctl load -s Aqua ...'? I wasn't specifying the session type. My logic being that all user agents should already be "locked in" to the Aqua bootstrap (in Leopard). In fact, when I tried to include LimitLoadToSessionType=Aqua in the plist, launchd ignores the plist entirely. I still can't decide if that's a bug or if I just completely misunderstand the meaning of LimitLoadToSessionType and/or the session type. Dave Zarzycki wrote (Friday, January 25, 2008 12:13 PM -0800): > >-S, not -s, but otherwise, that is probably the solution. I'll give that a try later and see what happens. >That should solve it for Leopard... This is only for Leopard anyway. In Tiger, the agent gets installed as a login item. -- James Bucanek From hamish at gmail.com Fri Jan 25 11:59:39 2008 From: hamish at gmail.com (Hamish Allan) Date: Fri Jan 25 11:59:28 2008 Subject: [launchd-dev] Agent started two different was, two different bootstraps? In-Reply-To: References: Message-ID: <597e7edb0801251159t39dc967aqbf498d261879b3b8@mail.gmail.com> On Jan 25, 2008 7:28 PM, James Bucanek wrote: > I wasn't specifying the session type. My logic being that all > user agents should already be "locked in" to the Aqua bootstrap > (in Leopard). I would also have assumed that launchctl, if not provided with a session type, would load using the "current" session type... but I already found out the hard way: http://lists.macosforge.org/pipermail/launchd-dev/2007-November/000064.html > In fact, when I tried to include > LimitLoadToSessionType=Aqua in the plist, launchd ignores the > plist entirely. I still can't decide if that's a bug or if I > just completely misunderstand the meaning of > LimitLoadToSessionType and/or the session type. Well, TN2083 (http://developer.apple.com/technotes/tn2005/tn2083.html) states: "If you don't specify the LimitLoadToSessionType property, launchd assumes a value of Aqua." So there's definitely a bug somewhere, be it the documentation or the code... Hamish From subscriber at gloaming.com Fri Jan 25 13:31:27 2008 From: subscriber at gloaming.com (James Bucanek) Date: Fri Jan 25 13:31:18 2008 Subject: [launchd-dev] Agent started two different was, two different bootstraps? In-Reply-To: Message-ID: Dave Zarzycki wrote (Friday, January 25, 2008 12:13 PM -0800): > >-S, not -s, but otherwise, that is probably the solution. Dave, Hamish, That seems to be the problem. If I load the agent using launchctl load com.qrecall.monitor.plist it doesn't work. It runs, but can't connect to any processes using Mach ports. If I unload it and reload it using launchctl load -S Aqua com.qrecall.monitor.plist it works! It connects and communicate just fine. As an experiment, I added LimitLoadToSessionType Aqua to the plist and tried to load it again, with and without specifying the sessiontype. Here's what I got: crocodile:LaunchAgents james$ launchctl load com.qrecall.monitor.plist nothing found to load crocodile:LaunchAgents james$ launchctl load -S Aqua com.qrecall.monitor.plist crocodile:LaunchAgents james$ So it appears issuing "launchctl load" as a user process is assuming some other kind of sessiontype. So I think there's definitely a bug here, although it's not the more overt bug I thought it was. 1) As Hamish pointed out, LimitLoadToSessionType defaults to Aqua. So in the absence of LimitLoadToSessionType, an agent should only be loaded in the Aqua bootstrap/sessiontype. 2) If you include the LimitLoadToSessionType=Aqua in the plist, 'launchctl load' ignores the plist with "nothing to load." I now realize that it's because the session types are different. 3) If you omit the LimitLoadToSessionType in the plist, 'launchctl load' loads the agent in whatever sessiontype it defaults to, which is in contradiction to (1). If this sounds reasonable, I'll file a bug report. In the meantime I'll add -S Aqua to my initial load command. -- James Bucanek From rangerrick at gmail.com Sat Jan 26 12:18:09 2008 From: rangerrick at gmail.com (Benjamin Reed) Date: Sat Jan 26 12:17:56 2008 Subject: [launchd-dev] LaunchAgents, SecureSocketWithKey, and permissions Message-ID: <57eba2250801261218ibf1ef00q81c112161651124c@mail.gmail.com> I've added launchd support to dbus (https://bugs.freedesktop.org/show_bug.cgi?id=14259) -- however, I have a problem with permissions if I try to use it on 10.4. On 10.5, it creates the SecureSocketWithKey socket propertly, but on 10.4, it appears I have 2 sockets: 89990228 0 srwx------ 1 ranger wheel 0 Jan 26 14:44 /tmp/launch-Gi7nee/session 89990177 0 srwx------ 1 root wheel 0 Jan 26 14:42 /tmp/launch-xURB7Y/session ...but the one that gets set in the env var while logged in as ranger is the xURB7Y one. On a whim, I thought "hm, maybe I just need to reboot for launchd to grok it properly." On reboot, I've started a shell, and now the environment variable is not set at all. However, an lsof shows that the socket is being held by launchd: $ sudo lsof | grep /session launchd 158 ranger 9u unix 0x39cb220 0t0 /tmp/launch-7woJl9/session ...and ls shows it's owned properly: srwx------ 1 ranger wheel 0 Jan 26 15:09 /tmp/launch-7woJl9/session Any idea what I need to do to make things set up properly? Do I need to set it to KeepAlive or OnDemand=false to make it initialize right, maybe? -- Benjamin Reed a.k.a. Ranger Rick Fink, KDE, and Mac OS X development http://www.racoonfink.com/ From rangerrick at gmail.com Sun Jan 27 10:58:14 2008 From: rangerrick at gmail.com (Benjamin Reed) Date: Sun Jan 27 10:57:54 2008 Subject: [launchd-dev] Re: LaunchAgents, SecureSocketWithKey, and permissions In-Reply-To: <57eba2250801261218ibf1ef00q81c112161651124c@mail.gmail.com> References: <57eba2250801261218ibf1ef00q81c112161651124c@mail.gmail.com> Message-ID: <57eba2250801271058n15ebebc2h2ba98604468bd7a3@mail.gmail.com> On Jan 26, 2008 3:18 PM, Benjamin Reed wrote: > I've added launchd support to dbus > (https://bugs.freedesktop.org/show_bug.cgi?id=14259) -- however, I > have a problem with permissions if I try to use it on 10.4. Replying to myself. ;) It looks like it's only the launch-on-demand that's broken. If I put OnDemand in my plist file, it works just fine on 10.4. Not optimal, but a suitable solution. -- Benjamin Reed a.k.a. Ranger Rick Fink, KDE, and Mac OS X development http://www.racoonfink.com/ From subscriber at gloaming.com Sun Jan 27 22:16:25 2008 From: subscriber at gloaming.com (James Bucanek) Date: Sun Jan 27 22:16:05 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: <9AD4CB61-2B3B-425A-B52B-66D5F888CB1F@khiltd.com> Message-ID: Nathan Duran wrote (Friday, January 25, 2008 11:32 AM -0800): >On Jan 25, 2008, at 10:21 AM, James Bucanek wrote: > >>Anyway, is there a workaround for this or do I just have to >>abandon KeepAlive? > >Why not have your application unload the launchd job when it receives the shutdown event? The more I think about this, the more it appears that this is really no different than just leaving out the KeepAlive property. The only difference is that KeepAlive would restart my background app if it crashed. Fortunately (through the brilliant programming efforts of its creator, I'm sure), this particular app simply doesn't crash -- knock on wood. What I really wanted is the ability to restart the app simply by asking it to quit, or restarting the app if the user quit it. Since my app can't tell the difference between a Quit for a Shutdown and a Quit just for the sake of quitting, I think I'll have to give up on the KeepAlive flag for this version. -- James Bucanek From eskimo1 at apple.com Mon Jan 28 03:30:07 2008 From: eskimo1 at apple.com (Quinn) Date: Mon Jan 28 03:36:04 2008 Subject: [launchd-dev] Binding an individual user's agent to a privileged port In-Reply-To: <597e7edb0801231423k5a0f2f46r557c30676c14c432@mail.gmail.com> References: <597e7edb0801231423k5a0f2f46r557c30676c14c432@mail.gmail.com> Message-ID: At 22:23 +0000 23/1/08, Hamish Allan wrote: >Is it possible for a user agent to be bound to a privileged port? No. Take a look at Figure 3 in TN2083. launchd agents are managed by the per-user launchds. Those launchds have irrevocably dropped all privileges. Thus, there's no way for them to be able to bind to a privileged port on your behalf. At 22:23 +0000 23/1/08, Hamish Allan wrote: >As far as I can tell, there are two ways of demonstrating to launchd >that you have the authority to perform privileged operations such as >binding to a port < 1024: putting a plist file in /Library/Launch*, or >running launchctl sudo. I believe you mean "/Library/LaunchDaemons" and not "/Library/Launch*". The latter would include agents (in "/Library/LaunchAgents"), which are restricted as I've described above. btw These two mechanism are fundamentally the same. o When you put a file in "/Library/LaunchDaemons", it is consulted by the root launchd at system startup. o When you run launchctl using sudo, it always talks to the root launchd. Thus, in both cases the launchd job gets loaded into the root launchd, which is the only one capable of binding to privileged ports. S+E -- Quinn "The Eskimo!" Apple Developer Relations, Developer Technical Support, Core OS/Hardware From eskimo1 at apple.com Mon Jan 28 03:33:36 2008 From: eskimo1 at apple.com (Quinn) Date: Mon Jan 28 03:37:05 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: References: Message-ID: At 23:16 -0700 27/1/08, James Bucanek wrote: >The only difference is that KeepAlive would restart my background >app if it crashed. Fortunately (through the brilliant programming >efforts of its creator, I'm sure), this particular app simply >doesn't crash -- knock on wood. One option is to set "KeepAlive" to a dictionary containing "SuccessfulExit" set to false. That way, launchd won't restart you if you quit cleanly. OTOH, if you crash, you'll be relaunched. S+E -- Quinn "The Eskimo!" Apple Developer Relations, Developer Technical Support, Core OS/Hardware From hamish at gmail.com Mon Jan 28 06:27:05 2008 From: hamish at gmail.com (Hamish Allan) Date: Mon Jan 28 06:26:49 2008 Subject: [launchd-dev] Binding an individual user's agent to a privileged port In-Reply-To: References: <597e7edb0801231423k5a0f2f46r557c30676c14c432@mail.gmail.com> Message-ID: <597e7edb0801280627r3059b1c3s1e9c34c4933185cc@mail.gmail.com> On Jan 28, 2008 11:30 AM, Quinn wrote: > launchd agents are managed by the per-user launchds. Those launchds > have irrevocably dropped all privileges. Thus, there's no way for > them to be able to bind to a privileged port on your behalf. Good news for security. Bad news for my purposes! On Jan 28, 2008 11:30 AM, Quinn wrote: > At 22:23 +0000 23/1/08, Hamish Allan wrote: >>As far as I can tell, there are two ways of demonstrating to launchd >>that you have the authority to perform privileged operations such as >>binding to a port < 1024: putting a plist file in /Library/Launch*, or >>running launchctl sudo. > > I believe you mean "/Library/LaunchDaemons" and not > "/Library/Launch*". The latter would include agents (in > "/Library/LaunchAgents"), which are restricted as I've described > above. FWIW, I *did* mean /Library/Launch*: putting a file in /Library/LaunchAgents does demonstrate that you have the *authority* to perform privileged operations (because its permissions are the same as those of /Library/LaunchDaemons), but the architecture of launchd prevents this from being translated into actual privileges. On Jan 28, 2008 11:30 AM, Quinn wrote: > btw These two mechanism are fundamentally the same. > > o When you put a file in "/Library/LaunchDaemons", it is consulted by > the root launchd at system startup. > > o When you run launchctl using sudo, it always talks to the root launchd. > > Thus, in both cases the launchd job gets loaded into the root > launchd, which is the only one capable of binding to privileged ports. Aha. Makes sense. Good to know. Thanks, Hamish From subscriber at gloaming.com Mon Jan 28 08:05:14 2008 From: subscriber at gloaming.com (James Bucanek) Date: Mon Jan 28 08:04:52 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: Message-ID: Quinn wrote (Monday, January 28, 2008 4:33 AM -0000): >At 23:16 -0700 27/1/08, James Bucanek wrote: >>The only difference is that KeepAlive would restart my >>background app if it crashed. Fortunately (through the >>brilliant programming efforts of its creator, I'm sure), this >>particular app simply doesn't crash -- knock on wood. > >One option is to set "KeepAlive" to a dictionary containing >"SuccessfulExit" set to false. That way, launchd won't restart you if >you quit cleanly. OTOH, if you crash, you'll be relaunched. Thanks for the suggestion, Quinn, but it still boils down to almost the same thing. I want the process to be restarted if the user or my client application quits it. The program is a simple background Cocoa app that displays a single window with status information. It's really simple and (virtually) never crashes or locks up. It does, however, sometimes accumulate stale process connections and such. It's sometime nice to restart it just by telling it to quit -- either from my client application or by letting the user quit it using the Activity Monitor. About the only thing I can think of that might make this work is to add a function that would cause the application to exit with a non-zero status and call that when I want to restart it. This doesn't solve the problem of the user quiting it (becuase that would use the standard/clean quit request), but that's probably as close as I'm going to get. Cheers, James -- James Bucanek From hamish at gmail.com Mon Jan 28 08:25:21 2008 From: hamish at gmail.com (Hamish Allan) Date: Mon Jan 28 08:24:59 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: References: <9AD4CB61-2B3B-425A-B52B-66D5F888CB1F@khiltd.com> Message-ID: <597e7edb0801280825g2551b108j8913a6db8b87bd76@mail.gmail.com> On Jan 28, 2008 6:16 AM, James Bucanek wrote: > Since my app can't tell the difference between a Quit for a > Shutdown and a Quit just for the sake of quitting, I think I'll > have to give up on the KeepAlive flag for this version. You might try listening for distributed notifications associated with shutdown and restart: com.apple.restartInitiated com.apple.shutdownInitiated com.apple.logoutCancelled (I found these on Leopard with Notification Watcher: http://www.tildesoft.com/Programs.html) If you get a Quit after receiving either of the first two but without having received the third, it's a Quit for a Shutdown rather than a Quit just for the sake of quitting. Hamish From launchd at khiltd.com Mon Jan 28 10:46:36 2008 From: launchd at khiltd.com (Nathan Duran) Date: Mon Jan 28 10:46:19 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: <597e7edb0801280825g2551b108j8913a6db8b87bd76@mail.gmail.com> References: <9AD4CB61-2B3B-425A-B52B-66D5F888CB1F@khiltd.com> <597e7edb0801280825g2551b108j8913a6db8b87bd76@mail.gmail.com> Message-ID: On Jan 28, 2008, at 8:25 AM, Hamish Allan wrote: > You might try listening for distributed notifications associated with > shutdown and restart: > > com.apple.restartInitiated > com.apple.shutdownInitiated > com.apple.logoutCancelled I imagine you would also be able to determine whether the Quit event came from user interaction with your own menus or was an AppleEvent sent by the system. If not through Cocoa directly, then possibly through a CGEventTap. From zarzycki at apple.com Mon Jan 28 10:49:41 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Mon Jan 28 10:50:46 2008 Subject: [launchd-dev] Agent started two different was, two different bootstraps? In-Reply-To: References: Message-ID: On Jan 25, 2008, at 1:31 PM, James Bucanek wrote: > If this sounds reasonable, I'll file a bug report. Yes. Please file a bug report on launchctl requiring -S when it shouldn't. Thanks, davez From zarzycki at apple.com Mon Jan 28 10:50:28 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Mon Jan 28 10:51:02 2008 Subject: [launchd-dev] Re: LaunchAgents, SecureSocketWithKey, and permissions In-Reply-To: <57eba2250801271058n15ebebc2h2ba98604468bd7a3@mail.gmail.com> References: <57eba2250801261218ibf1ef00q81c112161651124c@mail.gmail.com> <57eba2250801271058n15ebebc2h2ba98604468bd7a3@mail.gmail.com> Message-ID: On Jan 27, 2008, at 10:58 AM, Benjamin Reed wrote: > On Jan 26, 2008 3:18 PM, Benjamin Reed wrote: >> I've added launchd support to dbus >> (https://bugs.freedesktop.org/show_bug.cgi?id=14259) -- however, I >> have a problem with permissions if I try to use it on 10.4. > > Replying to myself. ;) > > It looks like it's only the launch-on-demand that's broken. If I put > OnDemand in my plist file, it works just fine on > 10.4. > > Not optimal, but a suitable solution. Actually, agents are practically broken on Tiger. I wouldn't recommend using them unless you're on Leopard. davez From eskimo1 at apple.com Tue Jan 29 02:45:47 2008 From: eskimo1 at apple.com (Quinn) Date: Tue Jan 29 02:50:54 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: <597e7edb0801280825g2551b108j8913a6db8b87bd76@mail.gmail.com> References: <9AD4CB61-2B3B-425A-B52B-66D5F888CB1F@khiltd.com> <597e7edb0801280825g2551b108j8913a6db8b87bd76@mail.gmail.com> Message-ID: At 16:25 +0000 28/1/08, Hamish Allan wrote: >You might try listening for distributed notifications associated with >shutdown and restart: > >com.apple.restartInitiated >com.apple.shutdownInitiated >com.apple.logoutCancelled > >(I found these on Leopard with Notification Watcher: >http://www.tildesoft.com/Programs.html) These are not considered supported API. Worse yet, determining the state of login window by tracking these events is tricky. >If you get a Quit after receiving either of the first two but without >having received the third, it's a Quit for a Shutdown rather than a >Quit just for the sake of quitting. A better solution is to look at the kAEWhyAmIBeingLoggedOutAttr ('why?') attribute of the kAEQuitApplication ('quit') Apple event. If you're being quit by loginwindow, this will contain one of four different codes indicating why (kAEQuitAll, kAEShutDown, kAERestart, kAEReallyLogOut). If you're being quit by the user (or by an AppleScript or any other 'quit' Apple event mechanism), this attribute won't be present. I could've sworn that this attribute was publicly documented, but I looked long and hard and couldn't find anything. Well, it /should/ be publicly documented IMHO . S+E -- Quinn "The Eskimo!" Apple Developer Relations, Developer Technical Support, Core OS/Hardware From launchd at khiltd.com Tue Jan 29 09:22:05 2008 From: launchd at khiltd.com (Nathan Duran) Date: Tue Jan 29 09:21:44 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: References: <9AD4CB61-2B3B-425A-B52B-66D5F888CB1F@khiltd.com> <597e7edb0801280825g2551b108j8913a6db8b87bd76@mail.gmail.com> Message-ID: <9A2ED12C-8DEA-4F51-AA65-19FE3FD309BB@khiltd.com> On Jan 29, 2008, at 2:45 AM, Quinn wrote: > I could've sworn that this attribute was publicly documented, but I > looked long and hard and couldn't find anything. Well, it /should/ > be publicly documented IMHO . I thought there was another way, too, but I know I probably haven't looked at whatever it was since OS 8, so I figured I was either imagining things or it went away. From galen.sprague at staples.com Tue Jan 29 11:40:09 2008 From: galen.sprague at staples.com (Galen Sprague) Date: Tue Jan 29 11:40:00 2008 Subject: [launchd-dev] User agent modified file check for all users? Message-ID: Hey All, I had a question about creating a User Agent for multiple users in Lingon. Is there a way to set the When:Run it if this file is modified as: ~/Library/Preferences/com.systempreferences.plist instead of /Users/loggedInUser/LibraryPreferences/com.apple.systempreferences.plist? It doesn?t seem to recognize ~/Library This way my terminal command will run if any User?s com.apple.systempreferences.plist is modified. Thank you very much! Galen Sprague Senior Analyst Technical ..: Apple Systems :.. Marketing IS Staples, Inc. 500 Staples Dr. Framingham, Ma 01702 galen.sprague@staples.com :.. 508-253-1374 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-dev/attachments/20080129/077858df/attachment.html From launchd at khiltd.com Tue Jan 29 12:14:03 2008 From: launchd at khiltd.com (Nathan Duran) Date: Tue Jan 29 12:13:37 2008 Subject: [launchd-dev] User agent modified file check for all users? In-Reply-To: References: Message-ID: <0E8E6DE1-6E64-47B1-BF8B-0B85DDE199E4@khiltd.com> On Jan 29, 2008, at 11:40 AM, Galen Sprague wrote: > I had a question about creating a User Agent for multiple users in > Lingon. Is there a way to set the When:Run it if this file is > modified as: ~/Library/Preferences/com.systempreferences.plist > instead of /Users/loggedInUser/LibraryPreferences/ > com.apple.systempreferences.plist? It doesn?t seem to recognize ~/ > Library > > This way my terminal command will run if any User?s > com.apple.systempreferences.plist is modified. I can't really imagine this being possible. How is launchd supposed to know which user's directory the tilde should be expanded into at any given moment considering the fact that multiple users can be logged in concurrently? From zarzycki at apple.com Tue Jan 29 12:19:14 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Tue Jan 29 12:20:13 2008 Subject: [launchd-dev] User agent modified file check for all users? In-Reply-To: <0E8E6DE1-6E64-47B1-BF8B-0B85DDE199E4@khiltd.com> References: <0E8E6DE1-6E64-47B1-BF8B-0B85DDE199E4@khiltd.com> Message-ID: On Jan 29, 2008, at 12:14 PM, Nathan Duran wrote: > > On Jan 29, 2008, at 11:40 AM, Galen Sprague wrote: > >> I had a question about creating a User Agent for multiple users in >> Lingon. Is there a way to set the When:Run it if this file is >> modified as: ~/Library/Preferences/com.systempreferences.plist >> instead of /Users/loggedInUser/LibraryPreferences/ >> com.apple.systempreferences.plist? It doesn?t seem to recognize ~/ >> Library >> >> This way my terminal command will run if any User?s >> com.apple.systempreferences.plist is modified. > > I can't really imagine this being possible. How is launchd supposed > to know which user's directory the tilde should be expanded into at > any given moment considering the fact that multiple users can be > logged in concurrently? There is one launchd per user, so in theory, it shouldn't be hard. Unfortunately, the "~" magic doesn't work for WatchPaths at the moment. Feel free to file a bug, davez From galen.sprague at staples.com Tue Jan 29 12:24:54 2008 From: galen.sprague at staples.com (Galen Sprague) Date: Tue Jan 29 12:24:43 2008 Subject: [launchd-dev] User agent modified file check for all users? In-Reply-To: Message-ID: On 1/29/08 3:19 PM, "Dave Zarzycki" wrote: > On Jan 29, 2008, at 12:14 PM, Nathan Duran wrote: > >> >> On Jan 29, 2008, at 11:40 AM, Galen Sprague wrote: >> >>> I had a question about creating a User Agent for multiple users in >>> Lingon. Is there a way to set the When:Run it if this file is >>> modified as: ~/Library/Preferences/com.systempreferences.plist >>> instead of /Users/loggedInUser/LibraryPreferences/ >>> com.apple.systempreferences.plist? It doesn?t seem to recognize ~/ >>> Library >>> >>> This way my terminal command will run if any User?s >>> com.apple.systempreferences.plist is modified. >> >> I can't really imagine this being possible. How is launchd supposed >> to know which user's directory the tilde should be expanded into at >> any given moment considering the fact that multiple users can be >> logged in concurrently? > > There is one launchd per user, so in theory, it shouldn't be hard. > Unfortunately, the "~" magic doesn't work for WatchPaths at the > moment. Feel free to file a bug, I have also tried adding multiple WatchPaths by editing the .plist file but it only seems to use the first WatchPath, is there away around this? Do I need to create another attribute so it watches more than one path? Thank you! Galen From launchd at khiltd.com Tue Jan 29 12:45:49 2008 From: launchd at khiltd.com (Nathan Duran) Date: Tue Jan 29 12:45:23 2008 Subject: [launchd-dev] User agent modified file check for all users? In-Reply-To: References: <0E8E6DE1-6E64-47B1-BF8B-0B85DDE199E4@khiltd.com> Message-ID: <07D6DAFE-D160-43CA-B0F8-E22B6AA0131C@khiltd.com> On Jan 29, 2008, at 12:19 PM, Dave Zarzycki wrote: > There is one launchd per user, so in theory, it shouldn't be hard. > Unfortunately, the "~" magic doesn't work for WatchPaths at the > moment. Feel free to file a bug, I'm assuming kqueue's doing something smarter than constant polling, but I'm still not sure if tilde expansion is something I'd *want* to work there. Seems like it's bound to lead to noticeably increased resource usage somewhere on a box with a whole lot of users. From zarzycki at apple.com Tue Jan 29 13:07:04 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Tue Jan 29 13:08:04 2008 Subject: [launchd-dev] User agent modified file check for all users? In-Reply-To: References: Message-ID: On Jan 29, 2008, at 12:24 PM, Galen Sprague wrote: > On 1/29/08 3:19 PM, "Dave Zarzycki" wrote: > >> On Jan 29, 2008, at 12:14 PM, Nathan Duran wrote: >> >>> >>> On Jan 29, 2008, at 11:40 AM, Galen Sprague wrote: >>> >>>> I had a question about creating a User Agent for multiple users in >>>> Lingon. Is there a way to set the When:Run it if this file is >>>> modified as: ~/Library/Preferences/com.systempreferences.plist >>>> instead of /Users/loggedInUser/LibraryPreferences/ >>>> com.apple.systempreferences.plist? It doesn?t seem to recognize ~/ >>>> Library >>>> >>>> This way my terminal command will run if any User?s >>>> com.apple.systempreferences.plist is modified. >>> >>> I can't really imagine this being possible. How is launchd supposed >>> to know which user's directory the tilde should be expanded into at >>> any given moment considering the fact that multiple users can be >>> logged in concurrently? >> >> There is one launchd per user, so in theory, it shouldn't be hard. >> Unfortunately, the "~" magic doesn't work for WatchPaths at the >> moment. Feel free to file a bug, > > I have also tried adding multiple WatchPaths by editing the .plist > file but > it only seems to use the first WatchPath, is there away around > this? Do I > need to create another attribute so it watches more than one path? Can you please supply an example configuration file? Thanks! davez From galen.sprague at staples.com Tue Jan 29 13:44:42 2008 From: galen.sprague at staples.com (Galen Sprague) Date: Tue Jan 29 13:44:41 2008 Subject: [launchd-dev] User agent modified file check for all users? In-Reply-To: Message-ID: On 1/29/08 4:07 PM, "Dave Zarzycki" wrote: > On Jan 29, 2008, at 12:24 PM, Galen Sprague wrote: > >> On 1/29/08 3:19 PM, "Dave Zarzycki" wrote: >> >>> On Jan 29, 2008, at 12:14 PM, Nathan Duran wrote: >>> >>>> >>>> On Jan 29, 2008, at 11:40 AM, Galen Sprague wrote: >>>> >>>>> I had a question about creating a User Agent for multiple users in >>>>> Lingon. Is there a way to set the When:Run it if this file is >>>>> modified as: ~/Library/Preferences/com.systempreferences.plist >>>>> instead of /Users/loggedInUser/LibraryPreferences/ >>>>> com.apple.systempreferences.plist? It doesn?t seem to recognize ~/ >>>>> Library >>>>> >>>>> This way my terminal command will run if any User?s >>>>> com.apple.systempreferences.plist is modified. >>>> >>>> I can't really imagine this being possible. How is launchd supposed >>>> to know which user's directory the tilde should be expanded into at >>>> any given moment considering the fact that multiple users can be >>>> logged in concurrently? >>> >>> There is one launchd per user, so in theory, it shouldn't be hard. >>> Unfortunately, the "~" magic doesn't work for WatchPaths at the >>> moment. Feel free to file a bug, >> >> I have also tried adding multiple WatchPaths by editing the .plist >> file but >> it only seems to use the first WatchPath, is there away around >> this? Do I >> need to create another attribute so it watches more than one path? > > Can you please supply an example configuration file? > Here you go... -------------- next part -------------- A non-text attachment was scrubbed... Name: example.zip Type: application/octet-stream Size: 549 bytes Desc: not available Url : http://lists.macosforge.org/pipermail/launchd-dev/attachments/20080129/b72b78fc/example.obj From zarzycki at apple.com Tue Jan 29 17:21:06 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Tue Jan 29 17:22:40 2008 Subject: [launchd-dev] User agent modified file check for all users? In-Reply-To: References: Message-ID: <79742707-CC39-409B-9041-300D7345ABE1@apple.com> On Jan 29, 2008, at 1:44 PM, Galen Sprague wrote: > On 1/29/08 4:07 PM, "Dave Zarzycki" wrote: >> On Jan 29, 2008, at 12:24 PM, Galen Sprague wrote: >>> On 1/29/08 3:19 PM, "Dave Zarzycki" wrote: >>>> On Jan 29, 2008, at 12:14 PM, Nathan Duran wrote: >>>>> On Jan 29, 2008, at 11:40 AM, Galen Sprague wrote: >>>>>> I had a question about creating a User Agent for multiple users >>>>>> in >>>>>> Lingon. Is there a way to set the When:Run it if this file is >>>>>> modified as: ~/Library/Preferences/com.systempreferences.plist >>>>>> instead of /Users/loggedInUser/LibraryPreferences/ >>>>>> com.apple.systempreferences.plist? It doesn?t seem to recognize >>>>>> ~/ >>>>>> Library >>>>>> >>>>>> This way my terminal command will run if any User?s >>>>>> com.apple.systempreferences.plist is modified. >>>>> >>>>> I can't really imagine this being possible. How is launchd >>>>> supposed >>>>> to know which user's directory the tilde should be expanded into >>>>> at >>>>> any given moment considering the fact that multiple users can be >>>>> logged in concurrently? >>>> >>>> There is one launchd per user, so in theory, it shouldn't be hard. >>>> Unfortunately, the "~" magic doesn't work for WatchPaths at the >>>> moment. Feel free to file a bug, >>> >>> I have also tried adding multiple WatchPaths by editing the .plist >>> file but >>> it only seems to use the first WatchPath, is there away around >>> this? Do I >>> need to create another attribute so it watches more than one path? >> >> Can you please supply an example configuration file? >> > Here you go... > > Where are you installing this configuration file? davez From galen.sprague at staples.com Wed Jan 30 06:21:44 2008 From: galen.sprague at staples.com (Galen Sprague) Date: Wed Jan 30 06:22:03 2008 Subject: [launchd-dev] User agent modified file check for all users? In-Reply-To: <79742707-CC39-409B-9041-300D7345ABE1@apple.com> Message-ID: On 1/29/08 8:21 PM, "Dave Zarzycki" wrote: > On Jan 29, 2008, at 1:44 PM, Galen Sprague wrote: >> On 1/29/08 4:07 PM, "Dave Zarzycki" wrote: >>> On Jan 29, 2008, at 12:24 PM, Galen Sprague wrote: >>>> On 1/29/08 3:19 PM, "Dave Zarzycki" wrote: >>>>> On Jan 29, 2008, at 12:14 PM, Nathan Duran wrote: >>>>>> On Jan 29, 2008, at 11:40 AM, Galen Sprague wrote: >>>>>>> I had a question about creating a User Agent for multiple users >>>>>>> in >>>>>>> Lingon. Is there a way to set the When:Run it if this file is >>>>>>> modified as: ~/Library/Preferences/com.systempreferences.plist >>>>>>> instead of /Users/loggedInUser/LibraryPreferences/ >>>>>>> com.apple.systempreferences.plist? It doesn?t seem to recognize >>>>>>> ~/ >>>>>>> Library >>>>>>> >>>>>>> This way my terminal command will run if any User?s >>>>>>> com.apple.systempreferences.plist is modified. >>>>>> >>>>>> I can't really imagine this being possible. How is launchd >>>>>> supposed >>>>>> to know which user's directory the tilde should be expanded into >>>>>> at >>>>>> any given moment considering the fact that multiple users can be >>>>>> logged in concurrently? >>>>> >>>>> There is one launchd per user, so in theory, it shouldn't be hard. >>>>> Unfortunately, the "~" magic doesn't work for WatchPaths at the >>>>> moment. Feel free to file a bug, >>>> >>>> I have also tried adding multiple WatchPaths by editing the .plist >>>> file but >>>> it only seems to use the first WatchPath, is there away around >>>> this? Do I >>>> need to create another attribute so it watches more than one path? >>> >>> Can you please supply an example configuration file? >>> >> Here you go... >> >> > > Where are you installing this configuration file? > /Library/LaunchAgents/ From zarzycki at apple.com Wed Jan 30 08:02:34 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Wed Jan 30 08:04:10 2008 Subject: [launchd-dev] User agent modified file check for all users? In-Reply-To: References: Message-ID: <4969EBAB-4FC4-45F5-967B-BA30BE28166C@apple.com> On Jan 30, 2008, at 6:21 AM, Galen Sprague wrote: > On 1/29/08 8:21 PM, "Dave Zarzycki" wrote: > >> On Jan 29, 2008, at 1:44 PM, Galen Sprague wrote: >>> On 1/29/08 4:07 PM, "Dave Zarzycki" wrote: >>>> On Jan 29, 2008, at 12:24 PM, Galen Sprague wrote: >>>>> On 1/29/08 3:19 PM, "Dave Zarzycki" wrote: >>>>>> On Jan 29, 2008, at 12:14 PM, Nathan Duran wrote: >>>>>>> On Jan 29, 2008, at 11:40 AM, Galen Sprague wrote: >>>>>>>> I had a question about creating a User Agent for multiple users >>>>>>>> in >>>>>>>> Lingon. Is there a way to set the When:Run it if this file is >>>>>>>> modified as: ~/Library/Preferences/com.systempreferences.plist >>>>>>>> instead of /Users/loggedInUser/LibraryPreferences/ >>>>>>>> com.apple.systempreferences.plist? It doesn?t seem to recognize >>>>>>>> ~/ >>>>>>>> Library >>>>>>>> >>>>>>>> This way my terminal command will run if any User?s >>>>>>>> com.apple.systempreferences.plist is modified. >>>>>>> >>>>>>> I can't really imagine this being possible. How is launchd >>>>>>> supposed >>>>>>> to know which user's directory the tilde should be expanded into >>>>>>> at >>>>>>> any given moment considering the fact that multiple users can be >>>>>>> logged in concurrently? >>>>>> >>>>>> There is one launchd per user, so in theory, it shouldn't be >>>>>> hard. >>>>>> Unfortunately, the "~" magic doesn't work for WatchPaths at the >>>>>> moment. Feel free to file a bug, >>>>> >>>>> I have also tried adding multiple WatchPaths by editing the .plist >>>>> file but >>>>> it only seems to use the first WatchPath, is there away around >>>>> this? Do I >>>>> need to create another attribute so it watches more than one path? >>>> >>>> Can you please supply an example configuration file? >>>> >>> Here you go... >>> >>> >> >> Where are you installing this configuration file? >> > /Library/LaunchAgents/ The normal file system permissions are tripping you up. The default permissions for ~/Library are 700. That means that any given per-user launchd cannot monitor the preferences of their peers. davez From subscriber at gloaming.com Thu Jan 31 10:17:30 2008 From: subscriber at gloaming.com (James Bucanek) Date: Thu Jan 31 10:17:32 2008 Subject: [launchd-dev] ~/LaunchAgent + KeepAlive=true = Login Jail In-Reply-To: Message-ID: Quinn wrote (Tuesday, January 29, 2008 3:45 AM -0000): >A better solution is to look at the kAEWhyAmIBeingLoggedOutAttr >('why?') attribute of the kAEQuitApplication ('quit') Apple event. If >you're being quit by loginwindow, this will contain one of four >different codes indicating why (kAEQuitAll, kAEShutDown, kAERestart, >kAEReallyLogOut). If you're being quit by the user (or by an >AppleScript or any other 'quit' Apple event mechanism), this attribute >won't be present. Thanks, Quinn. That's a excellent solution. I did, indeed, search the documentation, developer.apple.com, and the various lists for any mention of determining if a Quit event was being sent because of a shutdown, restart, or logout. So this isn't just undocumented, it's below the radar. Inside Apple, you're probably using header files we don't have. ;) grepping of all of the 10.4 & 10.5 SDK header files, I can't find any declaration for kAEWhyAmIBeingLoggedOutAttr. However, there is a declaration for kEventParamReason = 'why?' in CarbonEvents.h. That's good enough for me. So I think I have this working nicely now. I added the SuccessfulExit=false to the KeepAlive property and added the following code to my Cocoa application static void dirtyExit( void ) { // At the very last moment possible, force an abnormal exit _exit(2); } - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender { #pragma unused(sender) // Find out if the application is quitting for a Log Out, Shutdown, or Restart // This has to be detemined in applicationShouldTerminate: becuase the AppleEvent goes away soon. NSAppleEventDescriptor* quitEventDesc = [[NSAppleEventManager sharedAppleEventManager] currentAppleEvent]; // NSLog(@"%p%s %@",self,__func__,quitEventDesc); NSAppleEventDescriptor* whyDesc = [quitEventDesc attributeDescriptorForKeyword:kEventParamReason]; OSType why = [whyDesc typeCodeValue]; if ( !(why==kAEQuitAll || why==kAEShutDown || why==kAERestart || why==kAEReallyLogOut) ) { //NSLog(@"application will exit abnormally"); // If the monitor is not exiting cleanly, register a program exit handler that will throw an error following normal termination atexit(dirtyExit); } return (YES); } Thanks again. I'll file a bug report on the documentation. James -- James Bucanek