su/sudo behave differently for controlling a user’s launchd
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
On 25 May 2012, at 18:24, Sidney San Martín wrote:
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?
IIRC sudo sets just the EUID, whereas su sets both the EUID and the RUID. launchctl keys off the RUID. Personally I tend to use <x-man-page://chroot> for this sort of thing. It has a nicer interface than su and can't get you into trouble like sudo. Share and Enjoy -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
participants (2)
-
Quinn "The Eskimo!"
-
Sidney San Martín