1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-27 18:04:05 +03:00

Merge pull request #11424 from yuwata/fix-11420

timedate: refuse setting time when unit is in 'activating' or friends
This commit is contained in:
Lennart Poettering 2019-01-18 17:58:20 +01:00 committed by GitHub
commit 0efa18d636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -160,7 +160,7 @@ static int context_ntp_service_is_active(Context *c) {
/* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
LIST_FOREACH(units, info, c->units)
count += streq_ptr(info->active_state, "active");
count += !STRPTR_IN_SET(info->active_state, "inactive", "failed");
return count;
}
@ -174,7 +174,7 @@ static int context_ntp_service_is_enabled(Context *c) {
/* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
LIST_FOREACH(units, info, c->units)
count += STRPTR_IN_SET(info->unit_file_state, "enabled", "enabled-runtime");
count += !STRPTR_IN_SET(info->unit_file_state, "masked", "masked-runtime", "disabled", "bad");
return count;
}
@ -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");