]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timedate: do not ignore fix_system argument in SetLocalRTC method 18771/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 24 Feb 2021 04:16:15 +0000 (13:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 24 Feb 2021 14:50:21 +0000 (23:50 +0900)
Fixes #18391.

src/timedate/timedated.c

index 563f470f54e3142ce65f129c3c6eab44befd92ba..1257d950aee60e62a406f00c3b5d143f231bd533 100644 (file)
@@ -725,7 +725,7 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error
         if (r < 0)
                 return r;
 
-        if (lrtc == c->local_rtc)
+        if (lrtc == c->local_rtc && !fix_system)
                 return sd_bus_reply_method_return(m, NULL);
 
         r = bus_verify_polkit_async(
@@ -742,13 +742,15 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error
         if (r == 0)
                 return 1;
 
-        c->local_rtc = lrtc;
+        if (lrtc != c->local_rtc) {
+                c->local_rtc = lrtc;
 
-        /* 1. Write new configuration file */
-        r = context_write_data_local_rtc(c);
-        if (r < 0) {
-                log_error_errno(r, "Failed to set RTC to %s: %m", lrtc ? "local" : "UTC");
-                return sd_bus_error_set_errnof(error, r, "Failed to set RTC to %s: %m", lrtc ? "local" : "UTC");
+                /* 1. Write new configuration file */
+                r = context_write_data_local_rtc(c);
+                if (r < 0) {
+                        log_error_errno(r, "Failed to set RTC to %s: %m", lrtc ? "local" : "UTC");
+                        return sd_bus_error_set_errnof(error, r, "Failed to set RTC to %s: %m", lrtc ? "local" : "UTC");
+                }
         }
 
         /* 2. Tell the kernel our timezone */