From d0c50d8dfa7ea6721d3b83af5bbbd4d96be22085 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 23 May 2023 17:32:49 +0200 Subject: [PATCH] firstboot: reload manager after writing /etc/locale.conf 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 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 4d14aa75e14..c423aff5ddd 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -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) -- 2.47.3