FS#22085 - [dcron] "/etc/rc.d/crond restart" causes user's environment to be copied to all cronjobs
Attached to Project:
Arch Linux
Opened by Mantas Mikulėnas (grawity) - Monday, 13 December 2010, 15:38 GMT
Last edited by Andrea Scarpino (BaSh) - Monday, 02 May 2011, 08:50 GMT
Opened by Mantas Mikulėnas (grawity) - Monday, 13 December 2010, 15:38 GMT
Last edited by Andrea Scarpino (BaSh) - Monday, 02 May 2011, 08:50 GMT
|
Details
Description:
Whenever I restart 'crond' using the /etc/rc.d/crond script, part of my current environment (including such things as SUDO_USER and DISPLAY) is copied to all cron jobs of all users. Steps to reproduce: 1. sudo /etc/rc.d/crond restart 2. (crontab -l; echo "* * * * * env > ~/cronenv") | crontab - 3. sleep 60 4. cat ~/cronenv Steps to fix: Use this to start crond in the rc.d script: env -i PATH="/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin" crond |
This task depends upon
Closed by Andrea Scarpino (BaSh)
Monday, 02 May 2011, 08:50 GMT
Reason for closing: Fixed
Additional comments about closing: dcron 4.5-1
Monday, 02 May 2011, 08:50 GMT
Reason for closing: Fixed
Additional comments about closing: dcron 4.5-1
You have to be careful how to use it -- hardcoding variables into initscripts looks like a bad idea to me...
Vixie-cron, on the other hand, makes sure cronjobs run in a clean environment - and it does have a hardcoded $PATH, too.
>(cronjobs inheriting daemon's environment) persists whether I use 'sudo', 'su', 'ssh root@localhost', or login >as 'root' on the console.
Sorry, if I was unclear... When you use sudo, the calling-env setting are inherited. There is not problem, if /etc/rc.d/crond executed on boot, because the $PATH you mention is the default root's PATH, right? I mean, cron runs as root, with root's env. Otherwise, run it as a user cron...
>Vixie-cron, on the other hand, makes sure cronjobs run in a clean environment - and it does have a hardcoded >$PATH, too.
Hmm, I have a rhel5 with vixie-cron here and /etc/init.d/crond looks just as my /etc/rc.d/crond. Can you, please, explain what you mean? Besides, can't you change PATH in a crontab directly?