77e6ed9
From fb14f86a7188f289dfc4081a6d83a5c9c7ce5a81 Mon Sep 17 00:00:00 2001
77e6ed9
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
77e6ed9
Date: Sat, 21 Mar 2015 17:40:20 -0400
77e6ed9
Subject: [PATCH] timedated: flip internal status after executing operation
77e6ed9
77e6ed9
timedated would set the internal status before calling out to systemd to do
77e6ed9
the actual change. When the operation was refused because of a SELinux denial,
77e6ed9
the state kept in timedated would get out of sync, and the second call from
77e6ed9
timedatectl would appear to succeed.
77e6ed9
77e6ed9
https://bugzilla.redhat.com/show_bug.cgi?id=1014315
77e6ed9
(cherry picked from commit 192b98b8fe73c8fb4bb3d6540deb93f5fb6eb9d2)
77e6ed9
---
77e6ed9
 src/timedate/timedated.c | 4 ++--
77e6ed9
 1 file changed, 2 insertions(+), 2 deletions(-)
77e6ed9
77e6ed9
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
77e6ed9
index 753c3d1d65..bee66af24a 100644
77e6ed9
--- a/src/timedate/timedated.c
77e6ed9
+++ b/src/timedate/timedated.c
77e6ed9
@@ -609,8 +609,6 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
77e6ed9
         if (r == 0)
77e6ed9
                 return 1;
77e6ed9
 
77e6ed9
-        c->use_ntp = ntp;
77e6ed9
-
77e6ed9
         r = context_enable_ntp(c, bus, error);
77e6ed9
         if (r < 0)
77e6ed9
                 return r;
77e6ed9
@@ -619,6 +617,8 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
77e6ed9
         if (r < 0)
77e6ed9
                 return r;
77e6ed9
 
77e6ed9
+        c->use_ntp = ntp;
77e6ed9
+
77e6ed9
         log_info("Set NTP to %s", c->use_ntp ? "enabled" : "disabled");
77e6ed9
 
77e6ed9
         sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL);