]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
firstboot: reload manager after writing /etc/locale.conf
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 23 May 2023 15:32:49 +0000 (17:32 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 23 May 2023 15:38:43 +0000 (17:38 +0200)
Requested in https://github.com/systemd/systemd/pull/27750#issuecomment-1559258861.
I didn't apply the locale configuration in firstboot itself, because
we don't have any localized messages, so that wouldn't change anything.

src/firstboot/firstboot.c

index 4d14aa75e1489637729c83b32e31ad35e5d079ca..c423aff5dddbc196ff5e3d39de9cd8fcc35ec2cc 100644 (file)
@@ -448,7 +448,7 @@ static int process_locale(int rfd) {
                 return log_error_errno(r, "Failed to write /etc/locale.conf: %m");
 
         log_info("/etc/locale.conf written.");
-        return 0;
+        return 1;
 }
 
 static int prompt_keymap(int rfd) {
@@ -1567,6 +1567,25 @@ static int parse_argv(int argc, char *argv[]) {
         return 1;
 }
 
+static int reload_system_manager(sd_bus **bus) {
+        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+        int r;
+
+        assert(bus);
+
+        if (!*bus) {
+                r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, RUNTIME_SCOPE_SYSTEM, bus);
+                if (r < 0)
+                        return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL);
+        }
+
+        r = bus_call_method(*bus, bus_systemd_mgr, "Reload", &error, NULL, NULL);
+        if (r < 0)
+                return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r));
+        log_info("Requested manager reload to apply locale configuration.");
+        return 0;
+}
+
 static int reload_vconsole(sd_bus **bus) {
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
         int r;
@@ -1668,6 +1687,8 @@ static int run(int argc, char *argv[]) {
         r = process_locale(rfd);
         if (r < 0)
                 return r;
+        if (r > 0 && !offline)
+                (void) reload_system_manager(&bus);
 
         r = process_keymap(rfd);
         if (r < 0)