Re: startup daemon as unpriviliged user
matthew wrote: On Fri, 13 Feb 2004, Louis LeBlanc wrote: [...] So, how can I get a process to run automatically on startup for an unprivileged user? cd /usr/local/etc/rc.d make a small sh script like so: #!/bin/sh su username -c command For scripts in '/usr/local/etc/rc.d' one should stick to the required semantics. That is, in this particular case you need to make sure that it only runs on startup and not a second time on shutdown. Like so: cut here #!/bin/sh case $1 in start) su username -c command ;; stop) ;; esac cut here Also, keep in mind that the script's name requires a suffix of '.sh', or else the system won't execute it automatically. Uwe -- Uwe Doering | EscapeBox - Managed On-Demand UNIX Servers [EMAIL PROTECTED] | http://www.escapebox.net ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: startup daemon as unpriviliged user
On Sat, Feb 14, 2004 at 06:28:29AM -0600, Eric F Crist wrote: On Saturday 14 February 2004 03:01 am, Uwe Doering wrote: matthew wrote: On Fri, 13 Feb 2004, Louis LeBlanc wrote: [...] So, how can I get a process to run automatically on startup for an unprivileged user? cd /usr/local/etc/rc.d make a small sh script like so: #!/bin/sh su username -c command For scripts in '/usr/local/etc/rc.d' one should stick to the required semantics. That is, in this particular case you need to make sure that it only runs on startup and not a second time on shutdown. Like so: cut here #!/bin/sh case $1 in start) su username -c command ;; stop) ;; esac cut here Also, keep in mind that the script's name requires a suffix of '.sh', or else the system won't execute it automatically. Uwe I think you could also setuid for that user to the shell script. No, the setuid flag does not work for shell scripts. -- Insert your favourite quote here. Erik Trulsson [EMAIL PROTECTED] ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: startup daemon as unpriviliged user
Bingo! Thanks a bunch! I'll check out gettytab too, but the @reboot is exactly what I needed for this. Lou On 02/13/04 08:04 PM, Craig Reyenga sat at the `puter and typed: man 5 crontab -- check out @reboot Or, for something crazy, man gettytab; you can autologin on a tty and then use a shell script to do all kinds of fun things. I used to run X without xdm that way. Hope this helps. -Craig - Original Message - From: Louis LeBlanc [EMAIL PROTECTED] To: FreeBSD Questions [EMAIL PROTECTED] Sent: Friday, February 13, 2004 7:47 PM Subject: startup daemon as unpriviliged user 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? Thanks. Lou -- Louis LeBlanc [EMAIL PROTECTED] Fully Funded Hobbyist, KeySlapper Extrordinaire :) http://www.keyslapper.org ԿԬ The clearest way into the Universe is through a forest wilderness. -- John Muir ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] -- Louis LeBlanc [EMAIL PROTECTED] Fully Funded Hobbyist, KeySlapper Extrordinaire :) http://www.keyslapper.org ԿԬ ignisecond, n: The overlapping moment of time when the hand is locking the car door even as the brain is saying, my keys are in there! -- Rich Hall, Sniglets ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: startup daemon as unpriviliged user
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/zzz_local_users.sh #!/bin/sh # spambayes cd /home/danny sudo -u danny sb_server.py -D hammie.db -l 10110 pop.vuurwerk.nl 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. HTH, Dan ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: startup daemon as unpriviliged user
man 5 crontab -- check out @reboot Or, for something crazy, man gettytab; you can autologin on a tty and then use a shell script to do all kinds of fun things. I used to run X without xdm that way. Hope this helps. -Craig - Original Message - From: Louis LeBlanc [EMAIL PROTECTED] To: FreeBSD Questions [EMAIL PROTECTED] Sent: Friday, February 13, 2004 7:47 PM Subject: startup daemon as unpriviliged user 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? Thanks. Lou -- Louis LeBlanc [EMAIL PROTECTED] Fully Funded Hobbyist, KeySlapper Extrordinaire :) http://www.keyslapper.org ԿԬ The clearest way into the Universe is through a forest wilderness. -- John Muir ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: startup daemon as unpriviliged user
On Fri, 13 Feb 2004, 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? cd /usr/local/etc/rc.d make a small sh script like so: #!/bin/sh su username -c command Example use on command line: krazykat# id uid=0(root) gid=0(wheel) groups=0(wheel), 2(kmem), 3(sys), 4(tty), 5(operator), 20(staff), 31(guest) krazykat# su matthew -c id uid=1001(matthew) gid=1001(matthew) groups=1001(matthew), 0(wheel), 69(network) krazykat# l8r, m Thanks. Lou -- Louis LeBlanc [EMAIL PROTECTED] Fully Funded Hobbyist, KeySlapper Extrordinaire :) http://www.keyslapper.org ԿԬ The clearest way into the Universe is through a forest wilderness. -- John Muir ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: startup daemon as unpriviliged user
Louis LeBlanc wrote: So, how can I get a process to run automatically on startup for an unprivileged user? It's reasonable to create a fetchmail.sh script in /usr/local/etc/rc.d which does something like: #!/bin/sh USER = me COMMAND = /usr/local/bin/fetchmail... su - ${USER} -c ${COMMAND} In this case, however, you might want to invoke it from a per-user cron script eievery hour or so instead... -- -Chuck ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]