]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
locale: check xkb data before requesting authentication
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 May 2018 06:49:21 +0000 (15:49 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 31 May 2018 07:16:25 +0000 (16:16 +0900)
src/locale/localed.c

index ccc552008afe4d2a0dfdfde9946bf2e0ab1caf34..ab16705d1d61efc2e4c9416493e40056a0965c0a 100644 (file)
@@ -547,6 +547,17 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
             (options && !string_is_safe(options)))
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Received invalid keyboard data");
 
+        r = verify_xkb_rmlvo(model, layout, variant, options);
+        if (r < 0) {
+                log_error_errno(r, "Cannot compile XKB keymap for new x11 keyboard layout ('%s' / '%s' / '%s' / '%s'): %m",
+                                strempty(model), strempty(layout), strempty(variant), strempty(options));
+
+                if (r == -EOPNOTSUPP)
+                        return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Local keyboard configuration not supported on this system.");
+
+                return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Specified keymap cannot be compiled, refusing as invalid.");
+        }
+
         r = bus_verify_polkit_async(
                         m,
                         CAP_SYS_ADMIN,
@@ -561,17 +572,6 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
         if (r == 0)
                 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
 
-        r = verify_xkb_rmlvo(model, layout, variant, options);
-        if (r < 0) {
-                log_error_errno(r, "Cannot compile XKB keymap for new x11 keyboard layout ('%s' / '%s' / '%s' / '%s'): %m",
-                                strempty(model), strempty(layout), strempty(variant), strempty(options));
-
-                if (r == -EOPNOTSUPP)
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Local keyboard configuration not supported on this system.");
-
-                return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Specified keymap cannot be compiled, refusing as invalid.");
-        }
-
         if (free_and_strdup(&c->x11_layout, layout) < 0 ||
             free_and_strdup(&c->x11_model, model) < 0 ||
             free_and_strdup(&c->x11_variant, variant) < 0 ||