Is this possible?
I got a chrooted environment for my users.
I copied crontab and all necessary libs to that environment and when running crontab everything looks fine. root runs a cronjob every minute and copies all new crontab-files into the real spool. But the cronjobs just don't run. Is there anything I'm missing?
Here is some more detailed information of the environment.
Code:
|-home
| \-{user}
| |-home
| | \-{user}
| |-var
| | \-spool
| |-bin \-cron
| |-etc \-crontabs
| \-lib \-{user}
|-var
| \-spool
| \-cron
|-var \-crontabs
|-bin \-{user}
|-etc
\-lib
Red is the chrooted environment
If a chrooted user now edits his crontab, the crontab-file will be written to /home/
{user}/var/spool/cron/crontabs/{user}
Since this is not the right path cron will be looking for, I set up a cronjob for root that runs every single minute. The script that is called checks (diff with a backup) if the crontab-files contain any updates. If so, all commands inside the crontab will be chrooted too and the modified file will be written to the right place: /var/spool/cron/crontabs/{user}
An example what is inside a generated crontabfile:
Quote:
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (crontab.test installed on Tue Apr 19 13:30:12 2005)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
* * * * * chroot /home/testuser echo "test" > /home/testuser/testfile
|
Yes, I see that warning about not editing these files.
But there is no other way since crontab won't write to the correct path when called from inside the chrooted environment.
Until here everything is fine. But as I mentioned above the jobs inside the generated crontab-files won't be executed.
I restarted the crond, but that did not help. Is there anything I can do to make cronjobs accessible by my chrooted users?
I'm very thankful for every hint you can give me.
Regards,
Daniel