Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 630858

Summary: sys-process/fcron: default /etc/crontab breaks with username test or rm
Product: Gentoo Linux Reporter: Alexander Zubkov <zubkov318>
Component: Current packagesAssignee: Thomas Deutschmann (RETIRED) <whissi>
Status: RESOLVED DUPLICATE    
Severity: major CC: cron-bugs+disabled
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Alexander Zubkov 2017-09-13 07:06:30 UTC
Hi.

Default /etc/crontab for fcron contains:

59  *  * * *    rm -f /var/spool/cron/lastrun/cron.hourly
9  3  * * *     rm -f /var/spool/cron/lastrun/cron.daily
19 4  * * 6     rm -f /var/spool/cron/lastrun/cron.weekly
29 5  1 * *     rm -f /var/spool/cron/lastrun/cron.monthly
*/10  *  * * *  test -x /usr/sbin/run-crons && /usr/sbin/run-crons

In documentation we see: "Note that the shell command may be preceded by a user name". It works in such a way: it gets first term from that string, checks if there is user with such name. And it it exists, fcron runs the rest of the string under that user. It is easy to guess what will happen if you will have user named rm or test - the things will got broken. This is what can be seen in strace of fcron when you have user named test in your system:

execve("/bin/bash", ["/bin/bash", "-c", "-x /usr/sbin/run-crons && /usr/sbin/run-crons"], [/* 5 vars */])

Bash complains on bad argument and command fails with error.

I think "root" user name should be implicitly specified before the command in /etc/crontab to avoid such errors.
Comment 1 Thomas Deutschmann (RETIRED) gentoo-dev 2017-09-19 12:00:43 UTC
This /etc/crontab you are showing isn't up to date. The reported problem was addressed via https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=531e27c45e1f413da44d8a51ece0f59e454586fb aka bug 525242 (we picked 'Either reference executables in full' as solution).

If you disagree with the fix/still have a problem please comment.

*** This bug has been marked as a duplicate of bug 525242 ***