diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-11-12 17:52:35 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-11-13 12:30:22 +0100 |
commit | 437f48a471f51ac9dd2697ee3b848a71b4f101df (patch) | |
tree | f05a4944d2069c33b52618eea544f9b799414730 /src/timedate/timedatectl.c | |
parent | d5fc5b2f8d62ba2a79eb755272e67ff3f117c5c5 (diff) | |
download | systemd-437f48a471f51ac9dd2697ee3b848a71b4f101df.tar.gz |
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.
Diffstat (limited to 'src/timedate/timedatectl.c')
-rw-r--r-- | src/timedate/timedatectl.c | 5 |
1 files changed, 3 insertions, 2 deletions
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(); |