mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-09-06 13:41:31 +00:00
timedated: flip internal status after executing operation
timedated would set the internal status before calling out to systemd to do the actual change. When the operation was refused because of a SELinux denial, the state kept in timedated would get out of sync, and the second call from timedatectl would appear to succeed. https://bugzilla.redhat.com/show_bug.cgi?id=1014315 (cherry picked from commit192b98b8fe) (cherry picked from commitfb14f86a71) [Amended to reverse the condition.]
This commit is contained in:
@@ -286,7 +286,7 @@ static int context_start_ntp(Context *c, sd_bus *bus, sd_bus_error *error) {
|
||||
l = get_ntp_services();
|
||||
STRV_FOREACH(i, l) {
|
||||
|
||||
if (c->use_ntp)
|
||||
if (!c->use_ntp)
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.systemd1",
|
||||
@@ -337,7 +337,7 @@ static int context_enable_ntp(Context*c, sd_bus *bus, sd_bus_error *error) {
|
||||
|
||||
l = get_ntp_services();
|
||||
STRV_FOREACH(i, l) {
|
||||
if (c->use_ntp)
|
||||
if (!c->use_ntp)
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.systemd1",
|
||||
@@ -673,8 +673,6 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
|
||||
if (r == 0)
|
||||
return 1;
|
||||
|
||||
c->use_ntp = ntp;
|
||||
|
||||
r = context_enable_ntp(c, bus, error);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -683,6 +681,8 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
c->use_ntp = ntp;
|
||||
|
||||
log_info("Set NTP to %s", c->use_ntp ? "enabled" : "disabled");
|
||||
|
||||
sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL);
|
||||
|
||||
Reference in New Issue
Block a user