summaryrefslogtreecommitdiff
path: root/source3/lib/replace.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/replace.c')
-rw-r--r--source3/lib/replace.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/source3/lib/replace.c b/source3/lib/replace.c
index cd48b8d160..a826de3560 100644
--- a/source3/lib/replace.c
+++ b/source3/lib/replace.c
@@ -427,23 +427,26 @@ char *rep_inet_ntoa(struct in_addr ip)
#ifndef HAVE_TIMEGM
/*
- yes, I know this looks insane, but its really needed. The function in the
- Linux timegm() manpage does not work on solaris.
+ see the timegm man page on linux
*/
time_t timegm(struct tm *tm)
{
- struct tm tm2, tm3;
- time_t t;
-
- tm2 = *tm;
-
- t = mktime(&tm2);
- tm3 = *localtime(&t);
- tm2 = *tm;
- tm2.tm_isdst = tm3.tm_isdst;
- t = mktime(&tm2);
- t -= TimeDiff(t);
-
- return t;
+ time_t ret;
+ char *tz;
+ char *tzvar;
+
+ tz = getenv("TZ");
+ putenv("TZ=");
+ tzset();
+ ret = mktime(tm);
+ if (tz) {
+ asprintf(&tzvar, "TZ=%s", tz);
+ putenv(tzvar);
+ safe_free(tzvar);
+ } else {
+ putenv("TZ");
+ }
+ tzset();
+ return ret;
}
#endif