summaryrefslogtreecommitdiff
path: root/src/timedate/timedatectl.c
diff options
context:
space:
mode:
authorShawn Landden <shawn@churchofgit.com>2015-03-23 04:44:57 -0700
committerKay Sievers <kay@vrfy.org>2015-03-24 13:42:43 +0100
commit3e5e74d5b7f6fcbeff7b6e4e06abd931aab14c48 (patch)
treea7843d386d460338953127ef29b99542fc9b6675 /src/timedate/timedatectl.c
parentc03d5c8e766792a298d8bcdf550c2fd01dd7b959 (diff)
downloadsystemd-3e5e74d5b7f6fcbeff7b6e4e06abd931aab14c48.tar.gz
timedatectl: fix when queried system has differn't timezone
Also allow getting time from time(2) when BUS_TRANSPORT_MACHINE. v2: check for error
Diffstat (limited to 'src/timedate/timedatectl.c')
-rw-r--r--src/timedate/timedatectl.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 9e04f8f7bf..44d329ecc2 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -106,14 +106,21 @@ static void print_status_info(const StatusInfo *i) {
/* Enforce the values of /etc/localtime */
if (getenv("TZ")) {
- fprintf(stderr, "Warning: Ignoring the TZ variable. Reading the system's time zone setting only.\n\n");
+ fprintf(stderr, "Warning: Ignoring the TZ variable.\n\n");
unsetenv("TZ");
}
+ r = setenv("TZ", i->timezone, false);
+ if (r < 0) {
+ log_error_errno(errno, "Failed to set TZ environment variable: %m");
+ exit(EXIT_FAILURE);
+ }
+ tzset();
+
if (i->time != 0) {
sec = (time_t) (i->time / USEC_PER_SEC);
have_time = true;
- } else if (arg_transport == BUS_TRANSPORT_LOCAL) {
+ } else if (IN_SET(arg_transport, BUS_TRANSPORT_REMOTE, BUS_TRANSPORT_MACHINE)) {
sec = time(NULL);
have_time = true;
} else