]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
locale: make errors in writing files not critical
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 23 Dec 2022 01:34:36 +0000 (10:34 +0900)
committerLuca Boccassi <bluca@debian.org>
Mon, 23 Jan 2023 11:30:03 +0000 (11:30 +0000)
Suggested at https://github.com/systemd/systemd/pull/25805#discussion_r1054871210

> we now write multiple files and we cannot possibly guarantee that
> either both updates worked or neither. unix fs apis simply have
> no concept that would allow us to implement that. hence I think
> we should update what we can, log about what we cannot, but return
> success as long as our in-memory state was updated.

src/locale/localed.c

index 161f899fd04040bdface0c40798440ca515eae37..0312963f3ebd68c17fbcdc79e56d49e8b0ac57ff 100644 (file)
@@ -435,10 +435,8 @@ static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_erro
         }
 
         r = vconsole_write_data(c);
-        if (r < 0) {
-                log_error_errno(r, "Failed to set virtual console keymap: %m");
-                return sd_bus_error_set_errnof(error, r, "Failed to set virtual console keymap: %m");
-        }
+        if (r < 0)
+                log_warning_errno(r, "Failed to write virtual console keymap, ignoring: %m");
 
         if (convert) {
                 r = x11_write_data(c);
@@ -646,10 +644,8 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
         }
 
         r = x11_write_data(c);
-        if (r < 0) {
-                log_error_errno(r, "Failed to set X11 keyboard layout: %m");
-                return sd_bus_error_set_errnof(error, r, "Failed to set X11 keyboard layout: %m");
-        }
+        if (r < 0)
+                log_warning_errno(r, "Failed to write X11 keyboard layout, ignoring: %m");
 
         log_info("Changed X11 keyboard layout to '%s' model '%s' variant '%s' options '%s'",
                  strempty(in.layout),