Getting UserName set in a launchd plist

Cantor, Scott cantor.2 at osu.edu
Thu Sep 1 07:49:00 PDT 2011


I found an old bug open on adding support for additional keywords in the
startup plist created by the macport system, but it doesn't appear to have
been addressed. The documentation simultaneously says that using
start/stop instead of direct exec is less good, but that doesn't really
fly if you're going to support a daemon running as a different user.

A contributor to my project suggested a workaround, and I wanted to ask if
it was kosher or not. He found the right macros to locate the plist and
suggested:

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}

Whether that's exactly correct or not, is it a bad idea to rely on those
macros or to do that replacement?


TIA,
-- Scott



More information about the macports-users mailing list