[launchd-dev] Install and load a launch daemon without a reboot

Jeremy Reichman jaharmi at jaharmi.com
Thu Oct 20 06:32:06 PDT 2011


Thanks for the replies. I'm looking for clarification, though.

It looks like it is possible to launch in the user's context.

Prior to the new launchctl feature in Lion, is it _appropriate_ to start a
LaunchAgent in the context of the current user as part of an _Apple
package installer script_? I ask for myself, and also because I see
vendors doing this on their own.

Especially with the link back to Quinn's answer, it seems to be preferable
to request a restart to load the agent ... unless a) you're running on at
least Lion and b) your target disk is also at least Lion.

I'm coming from a sysadmin background, so I tend to think that having an
installer script do anything in the user context is a recipe for problems.
There are so many ways that an installer can be run (especially when you
get to managed environments). Installer scripts often make assumptions
that their parent installer is being run in only one of them.

Thanks!

-- 
Jeremy



On 10/12/2011 7:17 PM, "Damien Sorresso" <dsorresso at apple.com> wrote:

>That should be:
>
>$ sudo launchctl asuser $DESIRED_UID launchctl bslist
>-- 
>Damien Sorresso
>dsorresso at apple.com
>
>On Oct 12, 2011, at 4:08 PM, Damien Sorresso wrote:
>> In Lion, launchctl now has an asuser subcommand. Give it a shot:
>> 
>> $ sudo launchctl asuser $DESIRED_UID bslist
>> -- 
>> Damien Sorresso
>> dsorresso at apple.com
>> 
>> On Oct 12, 2011, at 2:29 PM, Thomas Clement wrote:
>>> Not that simple.
>>> You must switch into the appropriate user context which turns to be
>>>quiet complicated and unsupported.
>>> 
>>> Please see:
>>> 
>>>http://lists.macosforge.org/pipermail/launchd-dev/2011-January/000890.ht
>>>ml
>>> 
>>> 
>>> Thomas
>>> 
>>> On Oct 12, 2011, at 11:23 PM, Stephane Sudre wrote:
>>> 
>>>> /usr/bin/su $USER -c
>>>> 
>>>> On Wed, Oct 12, 2011 at 9:01 AM, Jeremy Reichman
>>>><jaharmi at jaharmi.com> wrote:
>>>>> I'm resurrecting an old thread -- but it was my thread, and I have a
>>>>> slightly new spin on it.
>>>>> 
>>>>> Is it appropriate to start a LaunchAgent for the current user (with
>>>>> LimitLoadToSessionType: Aqua) via a script (such as
>>>>>post{install,upgrade})
>>>>> in an installer? I don't remember this being covered in TN2083, and
>>>>>my
>>>>> quick re-review of the tech note didn't turn anything up.
>>>>> 
>>>>> If so, is there an acceptable method or process to load the agent?
>>>>> 
>>>>> I am able to load a LaunchDaemon via an installer script, and have
>>>>>done so
>>>>> via the recommendation of checking to make sure EUID and RUID are 0.
>>>>>My
>>>>> Python code from earlier in the thread.
>>>>> 
>>>>> import posix
>>>>> if posix.getuid() and posix.geteuid() == 0:
>>>>>   # launchctl here
>>>>> 
>>>>> At the very least, I'd expect you'd need to find the current user
>>>>>and load
>>>>> the agent in that account's context even though the installer and its
>>>>> scripts are running with EUID/RUID 0.
>>>>> 
>>>>> 
>>>>> Thanks!
>>>> _______________________________________________
>>>> 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
>> 
>> _______________________________________________
>> 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




More information about the launchd-dev mailing list