summaryrefslogtreecommitdiffstats
path: root/src/locale/localed-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/locale/localed-util.c')
-rw-r--r--src/locale/localed-util.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/locale/localed-util.c b/src/locale/localed-util.c
index e4e57a0..5699659 100644
--- a/src/locale/localed-util.c
+++ b/src/locale/localed-util.c
@@ -304,7 +304,7 @@ void context_clear(Context *c) {
c->x11_cache = sd_bus_message_unref(c->x11_cache);
c->vc_cache = sd_bus_message_unref(c->vc_cache);
- c->polkit_registry = bus_verify_polkit_async_registry_free(c->polkit_registry);
+ c->polkit_registry = hashmap_free(c->polkit_registry);
};
X11Context *context_get_x11_context(Context *c) {
@@ -735,7 +735,9 @@ int vconsole_convert_to_x11(const VCContext *vc, X11Context *ret) {
}
int find_converted_keymap(const X11Context *xc, char **ret) {
- _cleanup_free_ char *n = NULL;
+ _cleanup_free_ char *n = NULL, *p = NULL, *pz = NULL;
+ _cleanup_strv_free_ char **keymap_dirs = NULL;
+ int r;
assert(xc);
assert(!isempty(xc->layout));
@@ -748,18 +750,29 @@ int find_converted_keymap(const X11Context *xc, char **ret) {
if (!n)
return -ENOMEM;
- NULSTR_FOREACH(dir, KBD_KEYMAP_DIRS) {
- _cleanup_free_ char *p = NULL, *pz = NULL;
+ p = strjoin("xkb/", n, ".map");
+ pz = strjoin("xkb/", n, ".map.gz");
+ if (!p || !pz)
+ return -ENOMEM;
+
+ r = keymap_directories(&keymap_dirs);
+ if (r < 0)
+ return r;
+
+ STRV_FOREACH(dir, keymap_dirs) {
+ _cleanup_close_ int dir_fd = -EBADF;
bool uncompressed;
- p = strjoin(dir, "xkb/", n, ".map");
- pz = strjoin(dir, "xkb/", n, ".map.gz");
- if (!p || !pz)
- return -ENOMEM;
+ dir_fd = open(*dir, O_CLOEXEC | O_DIRECTORY | O_PATH);
+ if (dir_fd < 0) {
+ if (errno != ENOENT)
+ log_debug_errno(errno, "Failed to open %s, ignoring: %m", *dir);
+ continue;
+ }
- uncompressed = access(p, F_OK) == 0;
- if (uncompressed || access(pz, F_OK) == 0) {
- log_debug("Found converted keymap %s at %s", n, uncompressed ? p : pz);
+ uncompressed = faccessat(dir_fd, p, F_OK, 0) >= 0;
+ if (uncompressed || faccessat(dir_fd, pz, F_OK, 0) >= 0) {
+ log_debug("Found converted keymap %s at %s/%s", n, *dir, uncompressed ? p : pz);
*ret = TAKE_PTR(n);
return 1;
}