]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(dracut-install): handling of multiple sonames in dlopen JSON
authorJames Le Cuirot <jlecuirot@microsoft.com>
Mon, 11 Aug 2025 09:12:59 +0000 (10:12 +0100)
committerLaszlo <laszlo.gombos@gmail.com>
Sat, 6 Sep 2025 10:26:58 +0000 (06:26 -0400)
We should not try to install every library referenced in the soname
array, only the first one present. The array is intended to be an
ordered preference list.

Closes: https://github.com/dracut-ng/dracut-ng/issues/1552
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
src/install/dracut-install.c

index deaf54f85eb44b29b705d263be80d5308900dde2..275c0cc806b8fbf616d3a26a628d541e7a27a8cd 100644 (file)
@@ -955,9 +955,10 @@ static void resolve_deps_dlopen_parse_json(Hashmap *pdeps, Hashmap *deps, const
         for (size_t entry_idx = 0; entry_idx < sd_json_variant_elements(dlopen_json); entry_idx++) {
                 sd_json_variant *entry = sd_json_variant_by_index(dlopen_json, entry_idx);
                 sd_json_variant *feature_json = sd_json_variant_by_key(entry, "feature");
+                const char *feature = NULL;
 
                 if (feature_json && sd_json_variant_is_string(feature_json)) {
-                        const char *feature = sd_json_variant_string(feature_json);
+                        feature = sd_json_variant_string(feature_json);
                         const char *name = src_soname ?: basename(fullsrcpath);
 
                         Iterator i;
@@ -992,12 +993,15 @@ static void resolve_deps_dlopen_parse_json(Hashmap *pdeps, Hashmap *deps, const
 
                         const char *soname = sd_json_variant_string(soname_json);
                         if (hashmap_get(pdeps, soname))
-                                continue;
+                                goto skip;
 
                         char *library = find_library(soname, fullsrcpath, src_len, match64, match32);
-                        if (!library || hashmap_put_strdup_key(deps, soname, library) < 0)
-                                log_warning("WARNING: could not locate dlopen dependency %s requested by '%s'", soname, fullsrcpath);
+                        if (library && hashmap_put_strdup_key(deps, soname, library) == 0)
+                                goto skip;
                 }
+
+                log_warning("WARNING: could not locate dlopen dependency for %s feature requested by '%s'", feature ?: "unnamed",
+                            fullsrcpath);
 skip:
         }
 }