return 1;
}
+static bool keymap_exists_bool(const char *name) {
+ return keymap_exists(name) > 0;
+}
+
+static typeof(&keymap_is_valid) determine_keymap_validity_func(int rfd) {
+ int r;
+
+ r = dir_fd_is_root(rfd);
+ if (r < 0)
+ log_debug_errno(r, "Unable to determine if operating on host root directory, assuming we are: %m");
+
+ return r != 0 ? keymap_exists_bool : keymap_is_valid;
+}
+
static int prompt_keymap(int rfd) {
_cleanup_strv_free_ char **kmaps = NULL;
int r;
print_welcome(rfd);
return prompt_loop("Please enter system keymap name or number",
- kmaps, 60, keymap_is_valid, &arg_keymap);
+ kmaps, 60, determine_keymap_validity_func(rfd), &arg_keymap);
}
static int process_keymap(int rfd) {
/* We check these conditions here instead of in parse_argv() so that we can take the root directory
* into account. */
+ if (arg_keymap && !determine_keymap_validity_func(rfd)(arg_keymap))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Keymap %s is not installed.", arg_keymap);
if (arg_locale && !locale_is_ok(rfd, arg_locale))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Locale %s is not installed.", arg_locale);
if (arg_locale_messages && !locale_is_ok(rfd, arg_locale_messages))