← 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. Resolves relative paths and empty strings in ldd() output. Updates FakeElf test fixture. Approved and merged after reviewer feedback on commit structure.

Suggested action:

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
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.
qwen3.6-35b-a3b-mtp-q6 Merged fix to resolve relative path components and handle empty strings in ldd() output, ensuring consistent absolute paths. Updated the FakeElf test fixture accordingly.

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 updates to handle missing ELF dependencies when ldd fails to resolve them. The change prevents filtering unresolved libraries, refactors ldd parsing for reliability, and adds unit tests. Approved by one reviewer and passed CI checks.
77%