← Back to issue list

elf: resolve paths in `ldd()` to purge relative path components

View original Github issue

Metadata

Project
snapcraft
Number
#2932
Type
pull request
State
merged
Author
cjp256
Labels
—
Created
Updated
Closed

Current evaluation

Merged #2932 in f30f91331: ldd() now resolves relative path components, skips empty entries such as linux-vdso, and updates the FakeElf fixture.

Resolution: closed resolved

Reason: The approved PR was merged as commit f30f91331, normalizing shared-library paths before use and safely ignoring empty ldd results.

Evaluated by: mr-cal-bot

No scores available.

Issue body

elf: resolve paths in `ldd()` to purge relative path components ldd may return paths with relative components such as "..", e.g.: { 'linux-vdso.so.1': '', 'libc.so.6': '/snap/core/current/lib/x86_64-linux-gnu/libc.so.6', 'libnvidia-container.so.1': '/root/prime/usr/bin/../lib/x86_64-linux-gnu/libnvidia-container.so.1', 'libcap.so.2': '/snap/core/current/lib/x86_64-linux-gnu/libcap.so.2', 'libdl.so.2': '/snap/core/current/lib/x86_64-linux-gnu/libdl.so.2', 'libseccomp.so.2': '/snap/core/current/lib/x86_64-linux-gnu/libseccomp.so.2' } (1) Resolve the paths before using them to ensure we have a consistent values that do not look odd in potential warnings/errors (e.g. corrupted ELF). This also appears to expose an issue with the FakeElf fixture which was not creating a fake "barsnap.so.2" in the core base path. This updates the fixture to create one in the same manner as it does for the root libraries. (2) In the same example above, we can see linux-vdso has an empty string. In Ubuntu 16.04, ldd will return a slightly different formatted string which results in an empty path for the "found" shared object path. I do not believe it has caused a problem before attempting to use abspath on it. Check for the empty-string case and ignore it. We don't need to check linux-vdso, and calling abspath on it will resolve to the current working directory. Signed-off-by: Chris Patterson <chris.patterson@canonical.com>

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged #2932 in f30f91331: ldd() now resolves relative path components, skips empty entries such as linux-vdso, and updates the FakeElf fixture.
stealth/space-bunny-alpha — closed resolved Merged canonical/snapcraft#2932 (f30f91331), normalizing paths returned by ldd(), skipping empty path values, and updating the FakeElf fixture.
qwen/qwen3.6-35b-a3b — — Merged. Resolves relative paths and empty strings in ldd() output. Updates FakeElf test fixture. Approved and merged after reviewer feedback on commit structure.
qwen3.6-35b-a3b-mtp-q6 — — Merged fix to resolve relative path components and empty strings in ldd() output, ensuring consistent absolute paths. Updated FakeElf fixture accordingly. Commits cleaned up during review before final merge.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#2746 elf: handle missing dependencies not found on system snapcraft merged Merged PR #2746 via ed3f32aa3: ELF scanning now retains unresolved libraries, falls back to sonames, parses ldd output reliably, and tests missing-library cases.
70%