Bug 244977

Summary: bug in cron.daily evaluation routine
Product: [openSUSE] openSUSE 10.2 Reporter: Thomas Blume <thomas.blume>
Component: OtherAssignee: Matthias Koenig <mkoenig>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: caustin, ml-itshh
Version: Final   
Target Milestone: ---   
Hardware: Other   
OS: SUSE Other   
Whiteboard:
Found By: Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Thomas Blume 2007-02-13 14:13:09 UTC
Customer has set the variable DAILY_TIME="00:15" in /etc/sysconfig/cron.
According to the documentation this should execute cron.daily at 00:15.

But the customer noticed that now cron daily was run twice, on 00:00 and 00:15.
Investigating this he found a bug in:  /usr/lib/cron/run-crons.
The row:

DAILY_TIME_NEW="`echo $DAILY_TIME | sed s,:,, | sed s,^0,, `"

will remove the colon and the first zero from the value in DAILY_TIME and hence put 015 into DAILY_TIME_NEW.
This is then evaluated in:

[ $(($DAILY_TIME_NEW - 15)) -lt "$NOW_H" ] && [ $(($DAILY_TIME_NEW  + 15)) -gt "$NOW_H" ]

According to the bash manpage (ARITHMETIC EVALUATION):

        Constants  with  a  leading  0  are  interpreted as octal numbers.

Hence 015 is evaluated octal which gives 5 times 8 power of 0 plus 1 time 8 power of 1 equals 5+8=13.
For 13, the comparison above is true for both NOW_H=0 and NOW_H=15.

I guess it is not intended that the value in DAILY_TIME gets evaluated octal.
A fix therefore is simple.
Just remove all leading zeroes from DAILY_TIME in order to let it evaluate decimal, e.g.:

DAILY_TIME_NEW="`echo $DAILY_TIME | sed s,:,, | sed s,^0*,, `"
Comment 1 Matthias Koenig 2007-02-16 09:42:49 UTC
Fixed in stable.
Do we want this for 10.2?
Comment 4 Matthias Koenig 2007-06-12 13:36:20 UTC
*** Bug 283218 has been marked as a duplicate of this bug. ***
Comment 5 Matthias Koenig 2008-09-11 13:38:17 UTC
*** Bug 419636 has been marked as a duplicate of this bug. ***