diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-01-15 14:51:30 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-01-15 15:15:26 +0900 |
commit | b4356b5720ae0974f1f8962e26562591dd0be9e9 (patch) | |
tree | 9e4f38a42beef71f3d2b33ce2b3995a0b7425005 /src/timedate | |
parent | 84a87726eec88e7b11c8aa633bca006a0c0fc435 (diff) | |
download | systemd-b4356b5720ae0974f1f8962e26562591dd0be9e9.tar.gz |
timedate: refuse to set time when previous request is not finished
If `timedatectl set-time` is invoked right after `timedatectl set-ntp true`,
then, the NTP service may not be started yet.
Fixes #11420.
Diffstat (limited to 'src/timedate')
-rw-r--r-- | src/timedate/timedated.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 12308bed42..eeb17b613e 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -523,6 +523,10 @@ static int property_get_can_ntp( assert(reply); assert(error); + if (c->slot_job_removed) + /* When the previous request is not finished, then assume NTP is enabled. */ + return sd_bus_message_append(reply, "b", true); + r = context_update_ntp_status(c, bus, reply); if (r < 0) return r; @@ -548,6 +552,10 @@ static int property_get_ntp( assert(reply); assert(error); + if (c->slot_job_removed) + /* When the previous request is not finished, then assume NTP is active. */ + return sd_bus_message_append(reply, "b", true); + r = context_update_ntp_status(c, bus, reply); if (r < 0) return r; @@ -735,6 +743,9 @@ static int method_set_time(sd_bus_message *m, void *userdata, sd_bus_error *erro assert(m); assert(c); + if (c->slot_job_removed) + return sd_bus_error_set(error, BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED, "Previous request is not finished, refusing."); + r = context_update_ntp_status(c, bus, m); if (r < 0) return sd_bus_error_set_errnof(error, r, "Failed to update context: %m"); |