[wellylug] Proper way to start program with correct uid from init.d?

Damon Lynch damon at photo.geek.nz
Mon May 3 18:06:27 NZST 2004


Hi,

On Mon, 2004-05-03 at 09:36, Sam wrote:
> What distribution are you using?

Mandrake.

> 
> Debian has a utility called 'start-stop-daemon' which is used in various
> init.d scripts for .. well .. starting and stopping daemons. :)
> 
> It has quite a few funky parameters you can pass to it, including:
> 
> -c|--chuid username|uid

This seems very handy.  I will look into this.  Thanks very much!

Damon

> Change to this username/uid before starting the process. You can
> also  specify a group by appending a :, then the group or gid in
> the same way as you would for the `chown' command  (user:group).
> When  using  this  option  you must realize that the primary and
> supplemental groups are set as well, even if the --group  option
> is  not  specified.   The --group option is only for groups that
> the user isn't normally a member  of  (like  adding  per/process
> group membership for generic users like nobody).
> 
> I'm not sure if it exists in other distributions, but it might be worth
> having a look. :)
> 
> Cheers
> 
> Sam
> 
> On Mon, 2004-05-03 at 00:46, Damon Lynch wrote:
> > Hi,
> > 
> > Here is a snippet from within a /etc/init.d file that I've created:
> > 
> > sudo -u zope -H vncserver :1 -depth 16 -geometry 640x480 2>/dev/null 1>&2 && success || failure
> > 
> > It 'works' in the sense that the vncserver program starts up -- but many
> > of the programs in the vnc session don't work properly.  For instance
> > OOo can't save any files.  When I start vncserver when I've logged into
> > a shell as user zope, they work just fine.  Thus the problem appears to
> > be with me abusing the role of sudo, or at least using it in the wrong
> > context.
> > 
> > All I'm really trying to do is start some programs as a non root user at
> > startup time.  How do I do this?  
> > 
> > Thanks :)
> > 
> > Damon
> > 
> 




More information about the wellylug mailing list