Re: User for startupitem.executable

2016-09-20 Thread Javier Alcázar
The asterisk example wouldn't work here because it depends on the
executable supporting being run as a different user.
The -U option.

Thank you anyway Ken.




Although  the mongo example using sudo launches an additional process, it
works because daemondo and in turn launchd monitors the whole thing, i.e.,
 "sudo -u ${user}  ${prefix}/bin/executable"

instead of monitoring
 "su -c" only.
Where the call to "executable" gets lost. In other words, with su, launchd
and daemondo automatically restart the su process but not the "executable" .

So, I'll go with his approach.

Thank you Rainer.





In the future I will use macports-dev for  Portfile writing related
discussion as noted in
https://lists.macosforge.org/mailman/listinfo/macports-dev

*Discussion for MacPorts development and Portfile writing. *





Best


On Sun, Sep 18, 2016 at 10:16 PM, Rainer Müller  wrote:

> On 2016-09-17 17:12, Javier Alcázar wrote:
> > I'm creating a new Portfile with startupitem.executable, and wondering
> > what is the best way to execute the command with a specific user.
>
> Just for the future, Portfile development is usually discussed on
> macports-dev, where you would reach more developers. The discussion on
> macports-users is about usage of the port command and problems with
> installs and upgrades.
>
> > I tried using "su -c executable args" but with this approach
> > launchd ends up monitoring the "su" process instead of the "executable"
> >
> > What would you recommend to do so launchd looks at the "executable"
> process?
>
> A few ports use this approach, citing from the mongodb port:
>
>   startupitem.executable  sudo -u ${mongouser} ${prefix}/bin/mongod ...
>
> While this adds an additional processes to the hierarchy, I do not see
> any problem with that. The su/sudo keeps running until the command exits
> and any signals sent to su/sudo will be relayed to the executed process.
>
> Rainer
>



-- 
Javier
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


Re: User for startupitem.executable

2016-09-18 Thread Rainer Müller
On 2016-09-17 17:12, Javier Alcázar wrote:
> I'm creating a new Portfile with startupitem.executable, and wondering
> what is the best way to execute the command with a specific user.

Just for the future, Portfile development is usually discussed on
macports-dev, where you would reach more developers. The discussion on
macports-users is about usage of the port command and problems with
installs and upgrades.

> I tried using "su -c executable args" but with this approach
> launchd ends up monitoring the "su" process instead of the "executable"
> 
> What would you recommend to do so launchd looks at the "executable" process?

A few ports use this approach, citing from the mongodb port:

  startupitem.executable  sudo -u ${mongouser} ${prefix}/bin/mongod ...

While this adds an additional processes to the hierarchy, I do not see
any problem with that. The su/sudo keeps running until the command exits
and any signals sent to su/sudo will be relayed to the executed process.

Rainer
___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users


Re: User for startupitem.executable

2016-09-17 Thread Ken Cunningham

Here's a snippet from another port that might help:

startupitem.create  yes
startupitem.netchange   yes
if {[getuid] == 0} {
startupitem.executable  ${prefix}/sbin/asterisk -d -U asterisk -G asterisk
} else {
startupitem.executable  ${prefix}/sbin/asterisk -d
}

and there is a discussion in the mailing list about this from years gone by  
the might be worth reading if that doesn't happen:


Hope this helps.

ken


On 2016-09-17, at 8:12 AM, Javier Alcázar wrote:

> Hi people,
> 
> I'm creating a new Portfile with startupitem.executable, and wondering what 
> is the best way to execute the command with a specific user.
> 
> I tried using "su -c executable args" but with this approach launchd ends up 
> monitoring the "su" process instead of the "executable"
> 
> What would you recommend to do so launchd looks at the "executable" process?
> 
> 
> 
> 
> 
> Cheers
> 
> 
> -- 
> Javier
> ___
> macports-users mailing list
> macports-users@lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/macports-users

___
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users