Getting UserName set in a launchd plist

Ryan Schmidt ryandesign at macports.org
Thu Sep 1 14:17:57 PDT 2011


On Sep 1, 2011, at 15:34, Cantor, Scott wrote:

> On 9/1/11 4:31 PM, "Ryan Schmidt" wrote:
>> 
>> I would say if you're going to be modifying a plist, you should be using
>> a tool designed to do so, like "defaults" or "PlistBuddy".
> 
> That really addresses a different issue. Either way, one would have to
> locate the plist to begin with, and my question was essentially whether
> locating it with those macros was publically stable and accepted practice.

Sorry, I missed that you were asking about how to locate the plist file itself. I thought you were talking about the regular expression you used to locate the key within the plist.


On Sep 1, 2011, at 09:49, Cantor, Scott wrote:

> reinplace 
> "s|^<key>ProgramArguments</key>|<key>UserName</key><string>${runuser}</stri
> ng>\\
> <key>GroupName</key><string>${runuser}</string>\\&|g"
> ${prefix}/etc/${startupitem.location}/${startupitem.uniquename}/${startupit
> em.plist}


Yes that does seem to be the correct way to construct the plist file location, based on:

https://trac.macports.org/browser/trunk/base/src/port1.0/portstartupitem.tcl?rev=83052#L406

And:

https://trac.macports.org/browser/trunk/base/src/port1.0/portstartupitem.tcl?rev=83052#L572




More information about the macports-users mailing list