[systemd-devel] [PATCH] timedatectl: check for getenv("TZDIR")

Shawn Landden shawn at churchofgit.com
Fri Mar 27 09:46:19 PDT 2015


I liked having the DST information. It is a pity glibc doesn't export
this information.

If TZDIR is set, glibc will look there rather than /usr/share/zoneinfo.
See tzset(3).
---
 src/timedate/timedatectl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 1d10c19..b10ab82 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -81,12 +81,18 @@ static void print_status_info(const StatusInfo *i) {
 
         assert(i);
 
-        /* Enforce the values of /etc/localtime */
+        /* Enforce the values of /etc/localtime, or remote /etc/localtime*/
         if (getenv("TZ")) {
                 fprintf(stderr, "Warning: Ignoring the TZ variable.\n\n");
                 unsetenv("TZ");
         }
 
+        /* also use /usr/share/zoneinfo */
+        if (getenv("TZDIR")) {
+                fprintf(stderr, "Warning: Ignoring the TZDIR variable. Using system zoneinfo data.\n\n");
+                unsetenv("TZDIR");
+        }
+
         r = setenv("TZ", i->timezone, false);
         if (r < 0) {
                 log_error_errno(errno, "Failed to set TZ environment variable: %m");
-- 
2.2.1.209.g41e5f3a



More information about the systemd-devel mailing list