From 437f48a471f51ac9dd2697ee3b848a71b4f101df Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 12 Nov 2019 17:52:35 +0100 Subject: tree-wide: fix how we set $TZ According to tzset(3) we need to prefix timezone names with ":". Let's do so hence, to avoid any ambiguities and follow documented behaviour. --- src/timedate/timedatectl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/timedate/timedatectl.c') diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 2f9073c3dc..2a98c48987 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -46,7 +46,7 @@ typedef struct StatusInfo { } StatusInfo; static void print_status_info(const StatusInfo *i) { - const char *old_tz = NULL, *tz; + const char *old_tz = NULL, *tz, *tz_colon; bool have_time = false; char a[LINE_MAX]; struct tm tm; @@ -62,7 +62,8 @@ static void print_status_info(const StatusInfo *i) { old_tz = strdupa(tz); /* Set the new $TZ */ - if (setenv("TZ", isempty(i->timezone) ? "UTC" : i->timezone, true) < 0) + tz_colon = strjoina(":", isempty(i->timezone) ? "UTC" : i->timezone); + if (setenv("TZ", tz_colon, true) < 0) log_warning_errno(errno, "Failed to set TZ environment variable, ignoring: %m"); else tzset(); -- cgit v1.2.1