[wellylug] Proper way to start program with correct uid from init.d?
sam at plaz.net.nz
Mon May 3 09:36:30 NZST 2004
What distribution are you using?
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:
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. :)
On Mon, 2004-05-03 at 00:46, Damon Lynch wrote:
> 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
> 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 :)
More information about the wellylug