]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Add workaround for system with non-XSI compatible tzset
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 18 Feb 2018 17:08:48 +0000 (17:08 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 18 Feb 2018 17:08:48 +0000 (17:08 +0000)
CMakeLists.txt
config.h.in
src/libutil/util.c

index 1ba6e767261d81c7c4d064daad709cefd3468425..865bef73568265c7868576101ad6ad8be1ad6d35 100644 (file)
@@ -920,6 +920,15 @@ CHECK_C_SOURCE_COMPILES(
        int main(int argc, char** argv) {
                return cmkcheckweak == NULL;
        }" HAVE_WEAK_SYMBOLS)
+CHECK_C_SOURCE_COMPILES(
+               "#include <time.h>
+               extern char *tzname[2];
+               extern long timezone;
+               extern int daylight;
+       int main(int argc, char** argv) {
+               tzset();
+               return timezone;
+       }" HAVE_SANE_TZSET)
 
 IF(WITH_ICONV)
        CHECK_C_SOURCE_COMPILES("
index 402d410f16d83f344b61314646cc2e908d96759f..aa875534d37e8557700be527209e36ac2ecd4e65 100644 (file)
@@ -75,6 +75,7 @@
 #cmakedefine HAVE_READPASSPHRASE_H  1
 #cmakedefine HAVE_SA_SIGINFO     1
 #cmakedefine HAVE_SANE_SHMEM     1
+#cmakedefine HAVE_SANE_TZSET     1
 #cmakedefine HAVE_SCHED_YEILD    1
 #cmakedefine HAVE_SC_NPROCESSORS_ONLN 1
 #cmakedefine HAVE_SEARCH_H       1
index 5e271ed80d1d34468a647b072a06bc7a9b68d39c..d1500b54a504602712f050ff1c75850820441b11 100644 (file)
@@ -2762,6 +2762,7 @@ rspamd_gmtime (gint64 ts, struct tm *dest)
        dest->tm_zone = "GMT";
 }
 
+#ifdef HAVE_SANE_TZSET
 extern char *tzname[2];
 extern long timezone;
 extern int daylight;
@@ -2784,6 +2785,14 @@ void rspamd_localtime (gint64 ts, struct tm *dest)
 #endif
 }
 
+#else
+void rspamd_localtime (gint64 ts, struct tm *dest)
+{
+       time_t t = ts;
+       localtime_r (&t, dest);
+}
+#endif
+
 gboolean
 rspamd_fstring_gzip (rspamd_fstring_t **in)
 {