[launchd-dev] su/sudo behave differently for controlling a =?utf-8?Q?user=E2=80=99s_?=launchd

Sidney San Martín s at sidneysm.com
Fri May 25 10:24:33 PDT 2012


I have an installer that loads an agent into launchd. A whiiiiile back, I read Quinn’s post about Mach bootstrap namespaces and launchd:

    http://lists.macosforge.org/pipermail/launchd-dev/2010-February/000741.html

(In my case, I decided that loading it just for the current user was probably good enough.) Well, I just did an overhaul on the installer and noticed that loading the agent on 10.5 was failing with an error:

    launch_msg(): Socket is not connected

Huh?! All seemed to be well in 10.6 and up. After bashing my head against it for a while, I discovered that a line like this in my installer:

    su "$USER" -c "launchctl load …"

had, in the overhaul, changed to this:

    sudo -u "USER" launchctl load …

Using su fixes the issue. I have no idea what the difference might be. I’m posting this in case anyone else runs into the same problem. Also, I wonder, does anyone has any insight into why they behave differently?

Sidney


More information about the launchd-dev mailing list