diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-01-26 09:48:11 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-01-28 06:47:36 +0100 |
commit | 800f65f827c9828d4c872d44b19ca8a008505690 (patch) | |
tree | 94711af6c1bc9de39a4cbb1268a7e87a177aea28 /src/locale | |
parent | locale: replace context_get_x11_context() with context_get_x11_context_safe() (diff) | |
download | systemd-800f65f827c9828d4c872d44b19ca8a008505690.tar.xz systemd-800f65f827c9828d4c872d44b19ca8a008505690.zip |
locale: always check input keyboard layout and friends earlier
Diffstat (limited to 'src/locale')
-rw-r--r-- | src/locale/localed.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/locale/localed.c b/src/locale/localed.c index dcd3b3e38d..88f5604f1e 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -378,12 +378,6 @@ static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_erro vc_context_empty_to_null(&in); - r = vconsole_read_data(c, m); - if (r < 0) { - log_error_errno(r, "Failed to read virtual console keymap data: %m"); - return sd_bus_error_set_errnof(error, r, "Failed to read virtual console keymap data: %m"); - } - FOREACH_STRING(name, in.keymap ?: in.toggle, in.keymap ? in.toggle : NULL) { r = keymap_exists(name); /* This also verifies that the keymap name is kosher. */ if (r < 0) { @@ -394,6 +388,12 @@ static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_erro return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED, "Keymap %s is not installed.", name); } + r = vconsole_read_data(c, m); + if (r < 0) { + log_error_errno(r, "Failed to read virtual console keymap data: %m"); + return sd_bus_error_set_errnof(error, r, "Failed to read virtual console keymap data: %m"); + } + if (vc_context_equal(&c->vc, &in)) return sd_bus_reply_method_return(m, NULL); @@ -580,17 +580,6 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err x11_context_empty_to_null(&in); - r = x11_read_data(c, m); - if (r < 0) { - log_error_errno(r, "Failed to read x11 keyboard layout data: %m"); - return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Failed to read x11 keyboard layout data"); - } - - xc = context_get_x11_context(c); - - if (x11_context_equal(xc, &in)) - return sd_bus_reply_method_return(m, NULL); - if (!x11_context_is_safe(&in)) return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Received invalid keyboard data"); @@ -605,6 +594,17 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Specified keymap cannot be compiled, refusing as invalid."); } + r = x11_read_data(c, m); + if (r < 0) { + log_error_errno(r, "Failed to read x11 keyboard layout data: %m"); + return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Failed to read x11 keyboard layout data"); + } + + xc = context_get_x11_context(c); + + if (x11_context_equal(xc, &in)) + return sd_bus_reply_method_return(m, NULL); + r = bus_verify_polkit_async( m, CAP_SYS_ADMIN, |