From rspaulding at arc.nasa.gov Tue May 6 11:52:39 2008 From: rspaulding at arc.nasa.gov (Ryan C. Spaulding) Date: Tue May 6 11:49:15 2008 Subject: [launchd-dev] launchd (257) not building In-Reply-To: References: Message-ID: Hi Quinn, So I have DarwinBuild set up but I still cannot get launchd (258.1) to build. How do I install the headers below? Can I just stick them into the Headers directory. Also according to the two year README (http://darwinbuild.macosforge.org/trac/browser/trunk/README) there are the following commands called darwinbuildheaders and installheaders. I cannot find these anywhere under /usr/local. Have these commands been deprecated? Thank you, Ryan On Mar 17, 2008, at 2:55 AM, Quinn wrote: > At 18:00 -0700 16/3/08, Dave MacLachlan wrote: >> I haven't found bootfiles.h, but from what I can glean: >> >> #define kBootRootActiveKey "bootroot-active" >> #define SO_EXECPATH 0x1085 >> >> (could somebody please correct me if those values are wrong) > > kBootRootActiveKey is defined in "bootfiles", which is open source. > > kext.subproj/bootfiles.h> > > SO_EXECPATH is part of the kernel source. > > socket.h> > > "quarantine.h" is part of the "quarantine" project, which is not > open source AFAIK. > > S+E > -- > Quinn "The Eskimo!" developer/> > Apple Developer Relations, Developer Technical Support, Core OS/ > Hardware > _______________________________________________ > 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/20080506/68a4a94e/attachment.html From Michal.Taurich at seznam.cz Thu May 8 10:09:07 2008 From: Michal.Taurich at seznam.cz (=?us-ascii?Q?Michal=20Taurich?=) Date: Thu May 8 10:05:36 2008 Subject: [launchd-dev] QueueDirectories problem Message-ID: <4938.9427-931-1324662820-1210266547@seznam.cz> Hello all, I have very strange launchd problem. I wrote a small script to watch defined folder and if anything is added to this folder, it copy the file via SCP to different machine and than move the file to another folder. The script looks like following: #!/bin/bash in=/in remote="user@xxx.xxx.xxx.xx:/path" out=/out OLDIFS=$IFS IFS="$(echo -e \"\\n\")" for i in $(find $in -type f) do IFS=$OLDIFS scp "${i}" "${remote}" IFS=$OLDIFS if [ $? = 0 ]; then mv "${i}" "${out}" fi; done IFS=$OLDIFS exit 0 I have also launchd .plist for it like follows: scp_upload ProgramArguments /script QueueDirectories /in RunAtLoad It works perfectly locally. Unfortunately, when I run it on remote host and connect to shared drive via AFP and try to copy file from my computer to "watched folder" I got errors like "Unsupported character" or "filename too long" or so. I discovered, the launchd starts immediately when filesytem is changed (The Finder shows 4 kb as file size, but in Terminal it shows 0 kb so I think it is copied just header). Imagine following example: You want to receive some incoming files from internet (e.g. several customers send you images) and you want to move it according filenames (filenames are only numbers). So files starts with 1xxxx will be moved to folder 10000-19999. And now comes the tricky situation. Because launchd works like it works, when customer starts uploading the file, there is made a file system record for that file. But because launchd is set as "watching for folder changes" it tries to move the file, even the file is not completed (imagine e.g. 20 MB print quality photos). So launchd fails and write in console log "threat" like "9 times I will fail and I will disable myself". So it is just a question of time when launchd will disable itself. So my question is how to avoid this behaviour. I tried to add an condition in my script based on following: lsof | grep -c "${in}/${i}" if [ $? = 0 ]; then exit 0; fi Basically it checks in list of open files, if the file is opened, if yes, than exit0, otherwise continue. But it also sometimes works and sometimes not (better say, some files are moved and some not and I can wait hours and the files sit on the same place even launchd is running). So I would like to ask someone if have some experience with this problem and can recommend me some workarround or some approved and tested way, how to avoid move/copy/rename or whatever incomplete files. Thanks in advance. Michal From dave-ml at dribin.org Thu May 22 11:38:58 2008 From: dave-ml at dribin.org (Dave Dribin) Date: Thu, 22 May 2008 13:38:58 -0500 Subject: [launchd-dev] Listening socket and fast user switching Message-ID: <2AFF6816-44E9-4B2C-88E2-78932CCEBED4@dribin.org> Hello, I'm writing a launchd agent that opens a TCP listening socket. Ideally, I'd like launchd to open and listen to the socket via SockServiceName so my agent only gets launched as-needed. The problem is I'd like to listen to the same port (e.g. 12345), no matter which user is logged in. This is fine when there's only one user logged in, but as soon as fast user switching comes into play, the socket gets an "address already in use" when the second user logs in. This is to be expected, I suppose. But is there any way to have launchd only listen to the socket when the user is the "active" user, and have it *not* listen when the user gets switched out, due to fast user switching? At first glance the LimitLoadToSessionType looked promising, but it doesn't look like any of those will do that. The solution I'm currently entertaining uses launchd to always launch my agent, and have my agent do the socket listening. I can then use the user switch notification to close down the listening port when the session is deactivated and open it when activated. Thanks, -Dave From zarzycki at apple.com Thu May 22 12:01:05 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Thu, 22 May 2008 12:01:05 -0700 Subject: [launchd-dev] Listening socket and fast user switching In-Reply-To: <2AFF6816-44E9-4B2C-88E2-78932CCEBED4@dribin.org> References: <2AFF6816-44E9-4B2C-88E2-78932CCEBED4@dribin.org> Message-ID: Dave, The Apple way to solve this problem is to use Bonjour with a dynamic port assignment. Just use port zero, and set Bonjour to true like so: Sockets Listeners Bonjour SockServiceName 0 davez On May 22, 2008, at 11:38 AM, Dave Dribin wrote: > Hello, > > I'm writing a launchd agent that opens a TCP listening socket. > Ideally, I'd like launchd to open and listen to the socket via > SockServiceName so my agent only gets launched as-needed. > > The problem is I'd like to listen to the same port (e.g. 12345), no > matter which user is logged in. This is fine when there's only one > user logged in, but as soon as fast user switching comes into play, > the socket gets an "address already in use" when the second user logs > in. > > This is to be expected, I suppose. But is there any way to have > launchd only listen to the socket when the user is the "active" user, > and have it *not* listen when the user gets switched out, due to fast > user switching? > > At first glance the LimitLoadToSessionType looked promising, but it > doesn't look like any of those will do that. > > The solution I'm currently entertaining uses launchd to always launch > my agent, and have my agent do the socket listening. I can then use > the user switch notification to close down the listening port when the > session is deactivated and open it when activated. > > Thanks, > > -Dave > > _______________________________________________ > launchd-dev mailing list > launchd-dev at lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev From dave-ml at dribin.org Thu May 22 12:05:07 2008 From: dave-ml at dribin.org (Dave Dribin) Date: Thu, 22 May 2008 14:05:07 -0500 Subject: [launchd-dev] Listening socket and fast user switching In-Reply-To: References: <2AFF6816-44E9-4B2C-88E2-78932CCEBED4@dribin.org> Message-ID: <8F467393-634D-4485-8DFE-BF8FBB8B10F1@dribin.org> On May 22, 2008, at 2:01 PM, Dave Zarzycki wrote: > Dave, > > The Apple way to solve this problem is to use Bonjour with a dynamic > port assignment. Just use port zero, and set Bonjour to true like so: > > Sockets > > Listeners > > Bonjour > > SockServiceName > 0 > > That's what I thought, but I'm thinking this won't quite work for this case. Our agent is actually an HTTP server, and we hand out URLs to stuff it serves up, e.g. http://localhost:12345/foo. If we use a dynamic port, even with Bonjour, our URLs are no longer valid. Unless there's a way to specify Bonjour ports in URLs? I thought that only worked for host names, though (i.e. .local). -Dave From zarzycki at apple.com Thu May 22 12:05:27 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Thu, 22 May 2008 12:05:27 -0700 Subject: [launchd-dev] Listening socket and fast user switching In-Reply-To: References: <2AFF6816-44E9-4B2C-88E2-78932CCEBED4@dribin.org> Message-ID: I'm sorry, I made a mistake, it should look like so: Sockets Listeners Bonjour MyServiceName SockServiceName 0 On May 22, 2008, at 12:01 PM, Dave Zarzycki wrote: > Dave, > > The Apple way to solve this problem is to use Bonjour with a dynamic > port assignment. Just use port zero, and set Bonjour to true like so: > > Sockets > > Listeners > > Bonjour > > SockServiceName > 0 > > > > davez > > > > On May 22, 2008, at 11:38 AM, Dave Dribin wrote: > >> Hello, >> >> I'm writing a launchd agent that opens a TCP listening socket. >> Ideally, I'd like launchd to open and listen to the socket via >> SockServiceName so my agent only gets launched as-needed. >> >> The problem is I'd like to listen to the same port (e.g. 12345), no >> matter which user is logged in. This is fine when there's only one >> user logged in, but as soon as fast user switching comes into play, >> the socket gets an "address already in use" when the second user logs >> in. >> >> This is to be expected, I suppose. But is there any way to have >> launchd only listen to the socket when the user is the "active" user, >> and have it *not* listen when the user gets switched out, due to fast >> user switching? >> >> At first glance the LimitLoadToSessionType looked promising, but it >> doesn't look like any of those will do that. >> >> The solution I'm currently entertaining uses launchd to always launch >> my agent, and have my agent do the socket listening. I can then use >> the user switch notification to close down the listening port when >> the >> session is deactivated and open it when activated. >> >> Thanks, >> >> -Dave >> >> _______________________________________________ >> launchd-dev mailing list >> launchd-dev at lists.macosforge.org >> http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev > > _______________________________________________ > launchd-dev mailing list > launchd-dev at lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev From zarzycki at apple.com Thu May 22 12:07:55 2008 From: zarzycki at apple.com (Dave Zarzycki) Date: Thu, 22 May 2008 12:07:55 -0700 Subject: [launchd-dev] Listening socket and fast user switching In-Reply-To: <8F467393-634D-4485-8DFE-BF8FBB8B10F1@dribin.org> References: <2AFF6816-44E9-4B2C-88E2-78932CCEBED4@dribin.org> <8F467393-634D-4485-8DFE-BF8FBB8B10F1@dribin.org> Message-ID: <96999ADF-559D-4E36-9EBF-810021B854C5@apple.com> On May 22, 2008, at 12:05 PM, Dave Dribin wrote: > On May 22, 2008, at 2:01 PM, Dave Zarzycki wrote: >> Dave, >> >> The Apple way to solve this problem is to use Bonjour with a dynamic >> port assignment. Just use port zero, and set Bonjour to true like so: >> >> Sockets >> >> Listeners >> >> Bonjour >> >> SockServiceName >> 0 >> >> > > That's what I thought, but I'm thinking this won't quite work for this > case. Our agent is actually an HTTP server, and we hand out URLs to > stuff it serves up, e.g. http://localhost:12345/foo. If we use a > dynamic port, even with Bonjour, our URLs are no longer valid. Unless > there's a way to specify Bonjour ports in URLs? I thought that only > worked for host names, though (i.e. .local). Dave, In theory, the Back-to-my-Mac feature of Mac OS X Leopard should make this possible. One would just need to go to the "Bonjour" submenu of the "Bookmarks" menu in Safari.app. davez From dave-ml at dribin.org Thu May 22 12:28:59 2008 From: dave-ml at dribin.org (Dave Dribin) Date: Thu, 22 May 2008 14:28:59 -0500 Subject: [launchd-dev] Listening socket and fast user switching In-Reply-To: <96999ADF-559D-4E36-9EBF-810021B854C5@apple.com> References: <2AFF6816-44E9-4B2C-88E2-78932CCEBED4@dribin.org> <8F467393-634D-4485-8DFE-BF8FBB8B10F1@dribin.org> <96999ADF-559D-4E36-9EBF-810021B854C5@apple.com> Message-ID: <1A71136D-12A5-4D98-A74B-3337F00D1FB8@dribin.org> On May 22, 2008, at 2:07 PM, Dave Zarzycki wrote: > Dave, > > In theory, the Back-to-my-Mac feature of Mac OS X Leopard should > make this possible. One would just need to go to the "Bonjour" > submenu of the "Bookmarks" menu in Safari.app. Yeah, I can see it in Safari if I set the Bonjour service to "http". However, if you click on that link, it sets the url to something like: http://assam.local.:59972/ If I unload and reload the agent, this port number is no longer valid, and I get a different URL: http://assam.local.:59978/ As far as I can tell, this means HTTP URLs cannot be consistent across launchd invocations, which won't work for me, in this case. Unless there's some way to do Bonjour port lookups? FWIW, I'm using the SampleD example and I've modified its plist to have this: Sockets MyListenerSocket Bonjour http SockServiceName 0 -Dave From hamish at gmail.com Thu May 22 14:17:35 2008 From: hamish at gmail.com (Hamish Allan) Date: Thu, 22 May 2008 22:17:35 +0100 Subject: [launchd-dev] Listening socket and fast user switching In-Reply-To: <1A71136D-12A5-4D98-A74B-3337F00D1FB8@dribin.org> References: <2AFF6816-44E9-4B2C-88E2-78932CCEBED4@dribin.org> <8F467393-634D-4485-8DFE-BF8FBB8B10F1@dribin.org> <96999ADF-559D-4E36-9EBF-810021B854C5@apple.com> <1A71136D-12A5-4D98-A74B-3337F00D1FB8@dribin.org> Message-ID: <597e7edb0805221417h586e83f3ha9b71411afa501bf@mail.gmail.com> On Thu, May 22, 2008 at 8:28 PM, Dave Dribin wrote: > As far as I can tell, this means HTTP URLs cannot be consistent across > launchd invocations, which won't work for me, in this case. Unless > there's some way to do Bonjour port lookups? Well, the flip side of the Bonjour way of doing things is that you don't store URLs, you store service names, and they are resolved at the last minute. But if you need to give out URLs for whatever reason, that won't work for you. Have you considered having a LaunchDaemon listen on the port and forward requests to the active GUI user? See http://developer.apple.com/technotes/tn2005/tn2083.html#SECBOOTSTRAPNAMESPACES (read the whole technote from beginning to end, if you haven't already). Hamish