Hi! We have a product that uses launch agents. We'd like to avoid the reboot after install, so we'd like start the agents for *all* the Aqua session-s from the installer. Is it something supported/possible? I tried to implement it by iterating through the '/tmp/launchd-*/sock' files and setting LAUNCHD_SOCKET to these files, then invoking the launchctl command. But it doesn't seems to do it. Any ideas? Regards, Miklos
We know this is a weak spot right now (bug #5476420), but alas, Leopard to too close to being done to address this properly. I know what I'm about to suggest is unpleasant, but as the author, I'd be happier if users logged out and back in again for this to take effect. Finally, the LAUNCHD_SOCKET variable is an implementation detail that is likely to change in the OS release *after* Leopard. Sorry, davez On Sep 13, 2007, at 6:35 AM, Miklós Fazekas wrote:
Hi!
We have a product that uses launch agents. We'd like to avoid the reboot after install, so we'd like start the agents for *all* the Aqua session-s from the installer.
Is it something supported/possible?
I tried to implement it by iterating through the '/tmp/launchd-*/ sock' files and setting LAUNCHD_SOCKET to these files, then invoking the launchctl command. But it doesn't seems to do it. Any ideas?
Regards, Miklos _______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo/launchd-dev
I'm also having a problem with a LaunchAgent in the local domain. I'm trying to install it to /Library/LaunchAgents via a package installer on Mac OS X 10.4.10 (PowerPC on my test system). It installs and appears loaded via Lingon, but even a logout and login does not cause it to run. I've also tried to load and start it at the command line via launchctl, and the specified script does not run ... at least not in a reasonable amount of time (30 sec). I don't know if this is because I've specified LowPriorityIO or not, but toggling that setting on/off hasn't seemed to make a difference yet. I'm just copying one file from /Library to ~/Library. The script itself runs without error if I execute it directly without the LaunchAgent. However, I'd like to be able to execute it for each user -- as the user -- as they log in, and I don't want to set up and use a LoginHook instead. I also want the installer to make sure the LaunchAgent is set up and running, and preferably run the job once for that current user. While I can do that with a postinstall script in the package installer that calls the LaunchAgent's target script, I'd really like to make sure that the LA is ready to go. I feel like I'm missing something. -- Jeremy
LaunchAgents are busted in Tiger, but fixed in Leopard. Sorry! davez On Oct 4, 2007, at 5:59 AM, Jeremy Reichman wrote:
I'm also having a problem with a LaunchAgent in the local domain.
I'm trying to install it to /Library/LaunchAgents via a package installer on Mac OS X 10.4.10 (PowerPC on my test system). It installs and appears loaded via Lingon, but even a logout and login does not cause it to run.
I've also tried to load and start it at the command line via launchctl, and the specified script does not run ... at least not in a reasonable amount of time (30 sec). I don't know if this is because I've specified LowPriorityIO or not, but toggling that setting on/off hasn't seemed to make a difference yet. I'm just copying one file from /Library to ~/Library.
The script itself runs without error if I execute it directly without the LaunchAgent. However, I'd like to be able to execute it for each user -- as the user -- as they log in, and I don't want to set up and use a LoginHook instead.
I also want the installer to make sure the LaunchAgent is set up and running, and preferably run the job once for that current user. While I can do that with a postinstall script in the package installer that calls the LaunchAgent's target script, I'd really like to make sure that the LA is ready to go.
I feel like I'm missing something.
-- Jeremy
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo/launchd-dev
On 10/4/07 1:41 PM, "Dave Zarzycki" <zarzycki@apple.com> wrote:
LaunchAgents are busted in Tiger, but fixed in Leopard.
So now, with Leopard, LaunchAgents in /Library/LaunchAgents will run at login for each user, as the user (by default), and without having to restart the computer between each user login session? -- Jeremy
At 14:58 -0400 29/10/07, Jeremy Reichman wrote:
So now, with Leopard, LaunchAgents in /Library/LaunchAgents will run at login for each user, as the user [...], and without having to restart the computer between each user login session?
Yes. The only significant gotcha that I can think of relates to installing and upgrading. Except in the simple case (where you have one user logged in and your installer/upgrader is running in that user's context), you run into problems with the install/upgrade process. There's no built in way for you to tell all per-user launchd's on the system that a new property list has been installed (or that an old one has been upgraded). Thus, you can get into situations where one user is running version X of your agent and another is running version X+1. Or one user doesn't have the agent installed and another does. There's no really good way around this right now (although there are plenty of hackish ways). Just for the record, we're tracking this as <rdar://problem/5476420>.
as the user (by default)
The "(by default)" indicates some confusion about how agents work. An agent is always launched by a per-user launchd, and that per-user launchd is always running with its EUID and RUID set to that of the user on whose behalf it's working. Thus, there's no "by default" about it. An agent will always run as that user and there's no way around that (other than by doing something silly like making your agent setuid root). The UserName and GroupName properties in an agent's plist are ignored (as they were on 10.4.x). I've rolled all of this info into a new Technote 2083 "Daemons and Agents" that scheduled to be published in the next couple of weeks. Watch the skies! (actually, <http://developer.apple.com> :-) S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
On Mon, 29 Oct 2007 19:47:03 +0100, "Quinn" <eskimo1@apple.com> said:
At 14:58 -0400 29/10/07, Jeremy Reichman wrote:
So now, with Leopard, LaunchAgents in /Library/LaunchAgents will run at login for each user, as the user [...], and without having to restart the computer between each user login session?
Yes. The only significant gotcha that I can think of relates to installing and upgrading. Except in the simple case (where you have one user logged in and your installer/upgrader is running in that user's context), you run into problems with the install/upgrade process. There's no built in way for you to tell all per-user launchd's on the system that a new property list has been installed (or that an old one has been upgraded). Thus, you can get into situations where one user is running version X of your agent and another is running version X+1. Or one user doesn't have the agent installed and another does. There's no really good way around this right now (although there are plenty of hackish ways).
Just for the record, we're tracking this as <rdar://problem/5476420>.
Okay, good to know. I'm not certain I will run into this situation without having a logout or reboot close by ... and I assume a logout for all users or a system reboot will resolve the situation.
as the user (by default)
The "(by default)" indicates some confusion about how agents work. An agent is always launched by a per-user launchd, and that per-user launchd is always running with its EUID and RUID set to that of the user on whose behalf it's working. Thus, there's no "by default" about it. An agent will always run as that user and there's no way around that (other than by doing something silly like making your agent setuid root). The UserName and GroupName properties in an agent's plist are ignored (as they were on 10.4.x).
I've rolled all of this info into a new Technote 2083 "Daemons and Agents" that scheduled to be published in the next couple of weeks. Watch the skies! (actually, <http://developer.apple.com> :-)
I'm looking forward to it! I hope it lays out things a little more clearly for sys admins, because I know quite a few who've given up on launchd. The "by default" confusion on my part is simply that I know it is possible to put it in the plist but I'd never personally tried to set it to some other value in a LaunchAgent. So, I was covering my bases there, even though it didn't make sense to me for a LaunchAgent to try to switch to another user's context. It's good to know that the attempt will be ignored. I'd been banging my head against the LaunchAgent wall enough in Tiger, just trying to get them to work as I expected from the man page. I'm glad to see it's worth trying again. -- Jeremy
At 20:48 -0400 29/10/07, Jeremy Reichman wrote:
I assume a logout for all users or a system reboot will resolve the situation.
That's correct.
I'm looking forward to it! I hope it lays out things a little more clearly for sys admins, because I know quite a few who've given up on launchd.
Alas, not really. My mandate is specifically to assist developers. However, like the current TN2083, it does explain the underlying architecture, and you can use that knowledge to make sensible decisions about how to deploy things. S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
participants (4)
-
\"Miklós Fazekas\"
-
Dave Zarzycki
-
Jeremy Reichman
-
Quinn