diff mbox series

systemd: Improve detection of executables and libraries

Message ID 20261027152930.1387813-1-anusmita.duttamazumder@arm.com
State New
Headers show
Series systemd: Improve detection of executables and libraries | expand

Commit Message

Anusmita Dutta Mazumder Oct. 27, 2026, 3:29 p.m. UTC
Use cached mode bits to detect executables independently of
host access permissions. Match shared-library basenames with
a regex to avoid matching directory names.

Signed-off-by: Anusmita Dutta Mazumder <anusmita.duttamazumder@arm.com>
---
 meta/recipes-core/systemd/dlopen-deps.inc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/dlopen-deps.inc b/meta/recipes-core/systemd/dlopen-deps.inc
index 37074a9682..4ce9845ad8 100644
--- a/meta/recipes-core/systemd/dlopen-deps.inc
+++ b/meta/recipes-core/systemd/dlopen-deps.inc
@@ -3,7 +3,7 @@  PACKAGEFUNCS =+ "package_generate_dlopen_deps"
 python package_generate_dlopen_deps() {
     # https://systemd.io/ELF_DLOPEN_METADATA/
 
-    import os, struct, json
+    import os, struct, json, re
 
     def extract_segment(filename, segment):
         """
@@ -49,6 +49,7 @@  python package_generate_dlopen_deps() {
     }
 
     shlibs = oe.package.read_shlib_providers(d)
+    shlib_pattern = re.compile(r"\.so(\.|$)")
 
     for pkg, files in pkgfiles.items():
         # Skip -dbg packages as we won't need to generate dependencies for those
@@ -61,7 +62,8 @@  python package_generate_dlopen_deps() {
             if cpath.islink(f):
                 continue
 
-            if os.access(f, os.X_OK) or ".so." in f or f.endswith(".so"):
+            # Scan shared libraries and executable files for dlopen notes.
+            if shlib_pattern.search(os.path.basename(f)) or cpath.is_executable(f):
                 try:
                     elf = oe.qa.ELFFile(f)
                     elf.open()