From b1319cc083de658c0007da93f25d19874f75d55f Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Mon, 23 May 2011 17:42:37 +0200 Subject: libxt_time: always ignore libc timezone Since xt_time is meant to work across many months, libc doing automatic conversion from local time to UTC (during parse) is unwanted, especially when --utc is specified. The same goes for dumping. Signed-off-by: Jan Engelhardt --- extensions/libxt_time.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extensions/libxt_time.c b/extensions/libxt_time.c index b538476c..67b7f45d 100644 --- a/extensions/libxt_time.c +++ b/extensions/libxt_time.c @@ -136,6 +136,12 @@ static time_t time_parse_date(const char *s, bool end) tm.tm_min = minute; tm.tm_sec = second; tm.tm_isdst = 0; + /* + * Offsetting, if any, is done by xt_time.ko, + * so we have to disable it here in userspace. + */ + setenv("TZ", "UTC", true); + tzset(); ret = mktime(&tm); if (ret >= 0) return ret; @@ -289,7 +295,7 @@ static void time_print_date(time_t date, const char *command) if (date == 0 || date == LONG_MAX) return; - t = localtime(&date); + t = gmtime(&date); if (command != NULL) /* * Need a contiguous string (no whitespaces), hence using -- cgit v1.2.3