Anacron for non-root users?

Jeffrey F. Bloss jbloss at tampabay.rr.com
Tue Mar 6 20:34:26 UTC 2007


Adam Funk wrote:

> On 2007-03-06, Alan Pope wrote:
> 
> > On Tue, Mar 06, 2007 at 11:22:44AM +0000, Adam Funk wrote:
> >> As far as I can tell, anacron only picks up the jobs in cron.daily,
> >> cron.hourly, cron.monthly and cron.weekly and runs them as root.
> >> Is there any way for non-root users to set up periodic jobs that
> >> get picked up by anacron and run under their accounts?
> >> 
> >
> > crontab -e
> >
> > Is the command a user can run which allows them to setup their own
> > cron jobs.
> 
> Right, but those are run only when the exact time conditions are met
> and the computer is switched on --- whereas anacron tests more
> frequently than once a day how long it's been since the daily jobs
> were run (for example).

Is there anything to prevent you from using existing anacron tools,
letting root "start" the job, but using 'su' to run it as a user?

In your /etc/cron.whatever scripts it might look something like this...

 #!/bin/sh
 if [ $test-some-condition -eq $being-cautious ]; then
    su <username> -c "/path/to/your-user-commands-go-here"
 fi

Running su as root requires no password, and the -c switch tells su to
execute "commands" in the shell spawned with <username> privileges,
then gracefully exit and become God again. 

The only disadvantage is that you need root privileges to set it up of
course. So if you were looking for something users can meddle with keep
looking. ;) Or....

You could create cron.whatever jobs that parsed user home directories
for some predefined file/directory, evaluating and executing anything
found there. This would seem to be a pretty serious security risk
though, as you're trusting users not to try passing nasty things like
'rm -rf' back to the "root" shell. :(

-- 
     _?_      Outside of a dog, a book is a man's best friend.
    (o o)         Inside of a dog, it's too dark to read.
-oOO-(_)--OOo------------------------------[ Groucho Marx ]---
                    http://wrench.homelinux.net/~jeff/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 892 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20070306/96f1c43b/attachment.sig>


More information about the ubuntu-users mailing list