Run a process at boot time as another user

Keary Suska yellowdog-general@lists.terrasoftsolutions.com
Mon May 20 10:58:00 2002


on 5/20/02 1:15 AM, fringe@shore.net purportedly said:

> Hopefully someone can help me. I seem to be having a brain fart on how to do
> this. I would like to have a few programs start up when my system boots, the
> way mysql, httpd (apache), etc do now. I figure that I can put a script into
> /etc/rc.d/init.d and symbolically link to it in the runlevels I'd like it to
> start in. But how do I get the programs to run under a user other than root?
> For example, mysql on YDL 2.2 runs as user mysql out of the box. How can I
> get one of these applications to run under a user I specify? Please help.
> Thanks.

The easiest way would probably be to su:
    su - user -c "command_line" &
or
    daemon su - user -c "command_line"

in your init script. Of course, you need a valid login shell for your user
of choice. You may be able to have an suid script--I don't remember whether
that is permitted or restricted by the stock kernel--but that can be a
significant security risk.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"