summaryrefslogtreecommitdiffstats
path: root/patches/logrotate-3.7.1/generic/dst.patch
blob: 08538eb4c6677758a3b4c17719e5f7cf5549d529 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Closes: #278591
Patch from: Holger Weiss <holger@ZEDAT.FU-Berlin.DE>

If you call logrotate once a week between 00:00 and 01:00 AM and
daylight saving time is in effect, "weekly" rotations will be done only
once in two weeks.  E.g., the following crontab won't work as expected:

12 0 * * 1 /usr/sbin/logrotate

logrotate uses the tm struct "lastRotated" in order to find out whether
a logfile needs rotating.  "lastRotated" is filled by first setting
everything to zero, then setting the mday, month and year of the last
rotation and then calling mktime(3) in order to normalize the rest of
the struct.  The problem is that if daylight saving time is in effect,
mktime() will increment "lastRotated.tm_isdst" from 0 to 1 and push
"lastRotated" by one hour.  Hence, the current time will be compared
with the day of the last rotation, 01:00 AM.  This can be solved by
setting lastRotated.tm_isdst correctly prior to the mktime() call.


Index: logrotate-3.7.1/logrotate.c
===================================================================
--- logrotate-3.7.1.orig/logrotate.c	2006-04-08 21:36:03.268110593 +0100
+++ logrotate-3.7.1/logrotate.c	2006-04-08 21:36:11.342764986 +0100
@@ -78,6 +78,7 @@
 	states[i].lastRotated.tm_mon = now.tm_mon;
 	states[i].lastRotated.tm_mday = now.tm_mday;
 	states[i].lastRotated.tm_year = now.tm_year;
+	states[i].lastRotated.tm_isdst = now.tm_isdst;
 
 	/* fill in the rest of the st->lastRotated fields */
 	lr_time = mktime(&states[i].lastRotated);