startup daemon as unpriviliged user

Danny Pansters danny at
Sat Feb 14 15:08:35 PST 2004

On Saturday 14 February 2004 01:47, Louis LeBlanc wrote:
> Hey everyone.  Here's a general question for you.
> I have a FreeBSD 4.8 system that runs fetchmail for me as an
> unprivileged everyday userid.  The problem is that the machine isn't
> on the most reliable powergrid one could hope for.
> So when the system comes back up after going down, I ALWAYS forget
> that I have to get fetchmail restarted.  If I forget for too long,
> there's so much mail it blows the server that receives the mail into
> oblivion (also FreeBSD 4.8, running Sendmail, Cyrus Imapd, and the
> main culprit, Spamassassin - spamd).  This is so bad that I often have
> to reboot the receiving system.
> So, how can I get a process to run automatically on startup for an
> unprivileged user?

For a user unpriviledged but with a login, run service as user if available as 
an option to the app you want to run or use sudo or equivalent (as root you 
can sudo anything as any user).

I have made this little blurb for my desktop after realizing that it's easy to 
forget starting spambayes pop3 proxy and then have my kmail be not able to 
connect to localhost:10110:

% cat /usr/local/etc/rc.d/
# spambayes
cd /home/danny
sudo -u danny -D hammie.db -l 10110 110 &
# get yahoo mail every n minutes
sudo -u danny ./.fetchyahoo &

It's a bit crude (need to hit enter to get my console back) but for my desktop 
its ok as it is. Obviously sudo needs to be installed and in path.

The processes show up if I 'ps' as user danny and I can kill or hup them.



More information about the freebsd-questions mailing list