]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxt_time: always ignore libc timezone
authorJan Engelhardt <jengelh@medozas.de>
Mon, 23 May 2011 15:42:37 +0000 (17:42 +0200)
committerJan Engelhardt <jengelh@medozas.de>
Tue, 24 May 2011 23:02:41 +0000 (01:02 +0200)
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 <jengelh@medozas.de>
extensions/libxt_time.c

index b538476c0d761623605d17b4492206ac0a67858d..67b7f45df9f7601f2ed89aed6a7063f39e3fbeeb 100644 (file)
@@ -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