diff options
author | rpaulo <rpaulo@FreeBSD.org> | 2015-06-16 22:42:19 +0000 |
---|---|---|
committer | rpaulo <rpaulo@FreeBSD.org> | 2015-06-16 22:42:19 +0000 |
commit | eedeb8c00ca9a990362e249ac86f61b136438062 (patch) | |
tree | 7502ac781944ad02cf9759bea2a066442cbca656 /usr.sbin/syslogd | |
parent | fcc68ddb2e2bfd77175e509a7b3b5ec44b7f2659 (diff) | |
download | FreeBSD-src-eedeb8c00ca9a990362e249ac86f61b136438062.zip FreeBSD-src-eedeb8c00ca9a990362e249ac86f61b136438062.tar.gz |
syslogd: re-read the timezone when receive a SIGHUP.
syslogd already re-reads the configuration file and the hostname when
receiving a SIGHUP, so it makes sense to reset the timezone.
Special care was taken to ensure we don't break installations running
with a custom TZ variable.
PR: 196905
Submitted by: Kurt Lidl <lidl pix.net>
Sponsored by: Pi-Coral, Inc.
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 9ffe797..ff3e524 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1603,6 +1603,24 @@ init(int signo) } /* + * Load / reload timezone data (in case it changed). + * + * Just calling tzset() again does not work, the timezone code + * caches the result. However, by setting the TZ variable, one + * can defeat the caching and have the timezone code really + * reload the timezone data. Respect any initial setting of + * TZ, in case the system is configured specially. + */ + dprintf("loading timezone data via tzset()\n"); + if (getenv("TZ")) { + tzset(); + } else { + setenv("TZ", ":/etc/localtime", 1); + tzset(); + unsetenv("TZ"); + } + + /* * Close all open log files. */ Initialized = 0; |