mirror of
https://github.com/systemd/systemd.git
synced 2025-01-24 06:04:05 +03:00
Merge pull request #27755 from keszybz/fix-root-resize-new
Reload keymap and locale config after firstboot writes it out
This commit is contained in:
commit
a484320572
@ -10,6 +10,9 @@
|
||||
#include "alloc-util.h"
|
||||
#include "ask-password-api.h"
|
||||
#include "build.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-locator.h"
|
||||
#include "bus-util.h"
|
||||
#include "chase.h"
|
||||
#include "copy.h"
|
||||
#include "creds-util.h"
|
||||
@ -445,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) {
|
||||
@ -533,7 +536,7 @@ static int process_keymap(int rfd) {
|
||||
return log_error_errno(r, "Failed to write /etc/vconsole.conf: %m");
|
||||
|
||||
log_info("/etc/vconsole.conf written.");
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool timezone_is_valid_log_error(const char *name) {
|
||||
@ -1564,7 +1567,46 @@ 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;
|
||||
|
||||
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, "RestartUnit", &error, NULL, "ss", "systemd-vconsole-setup.service", "replace");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r));
|
||||
log_info("Requested vconsole setup to apply key map configuration.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int run(int argc, char *argv[]) {
|
||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||
_cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL;
|
||||
_cleanup_(umount_and_freep) char *mounted_dir = NULL;
|
||||
_cleanup_close_ int rfd = -EBADF;
|
||||
@ -1578,13 +1620,14 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
umask(0022);
|
||||
|
||||
if (!arg_root && !arg_image) {
|
||||
bool enabled;
|
||||
bool offline = arg_root || arg_image;
|
||||
|
||||
if (!offline) {
|
||||
/* If we are called without --root=/--image= let's honour the systemd.firstboot kernel
|
||||
* command line option, because we are called to provision the host with basic settings (as
|
||||
* opposed to some other file system tree/image) */
|
||||
|
||||
bool enabled;
|
||||
r = proc_cmdline_get_bool("systemd.firstboot", &enabled);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse systemd.firstboot= kernel command line argument, ignoring: %m");
|
||||
@ -1644,10 +1687,14 @@ 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)
|
||||
return r;
|
||||
if (r > 0 && !offline)
|
||||
(void) reload_vconsole(&bus);
|
||||
|
||||
r = process_timezone(rfd);
|
||||
if (r < 0)
|
||||
|
@ -28,24 +28,14 @@
|
||||
#include "user-util.h"
|
||||
|
||||
static int reload_system_manager(sd_bus *bus) {
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
int r;
|
||||
|
||||
assert(bus);
|
||||
|
||||
r = sd_bus_message_new_method_call(bus, &m,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"Reload");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
r = sd_bus_call(bus, m, 0, &error, NULL);
|
||||
r = bus_call_method(bus, bus_systemd_mgr, "Reload", &error, NULL, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to reload system manager: %s", bus_error_message(&error, r));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -56,10 +46,8 @@ static int vconsole_reload(sd_bus *bus) {
|
||||
assert(bus);
|
||||
|
||||
r = bus_call_method(bus, bus_systemd_mgr, "RestartUnit", &error, NULL, "ss", "systemd-vconsole-setup.service", "replace");
|
||||
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user