-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audit libraries to check for problematic RPATH/RUNPATH when building #173
Conversation
0c29ebc
to
09fcdde
Compare
09fcdde
to
04cb95d
Compare
Based on this conversation with myself, I went ahead and started treating Because this is more likely and wide-reaching that I initially thought, I also went ahead and added Now, an existing test (
Confirmed with
This So I think I'll also have to implement the second part of this self-suggestion which is to check for "dangerous" rpaths. Otherwise, staticx will fail on a bunch of stuff unnecessarily. |
04cb95d
to
4a4558d
Compare
staticx cannot currently handle any libraries that have DT_RUNPATH set as it interferes with our ability to fully control the library paths. See #169
This will let us do other things prior to get_shobj_deps() which assume the file is a shared library
RPATH is also problematic. While RUNPATH will immediately kill the top-level RPATH with set, RPATH on a library can defeat our "jail" and cause target-system libraries to be loaded.
Since staticx has already discovered dependencies of the library (because ldd is effectively recursive), and (like Pyinstaller) will flatten all dependencies when they're tar-ed up and extracted, there's no reason we can't just drop the RPATH/RUNPATH entry. This also renames audit_library to check_library_rpath. I don't want this function to sound too generic, since we're catching exceptions and carrying on. Otherwise, we might "fix" an initial problem but then miss the remaining problems.
We now treat RPATH and RUNPATH (in added dependent libraries) the same by fixing (removing) them. It's the RPATH/RUNPATH in PyInstaller bundled libraries that is an unfixable problem, so we'll have to add another test, sigh.
A primary example of this is _cffi_backend.cpython-39-x86_64-linux-gnu.so which has RPATH = "$ORIGIN/cffi.libs" which doesn't matter because PyInstaller flattens the dependencies anyway. But we allow it because it is relative to $ORIGIN.
4a4558d
to
8450bc2
Compare
This PR audits all libraries included (directly by staticx or indirectly as part of a PyInstaller archive) for use of
DT_RPATH
/DT_RUNPATH
which is problematic as described in #169.RPATH
/RUNPATH
are removed from the libraries when possible, which does not apply to libraries already part of a PyInstaller archive:RPATH
RUNPATH
Those libraries are examined to determine is the
RPATH
/RUNPATH
is problematic.RUNPATH
is always forbidden, as detailed in #169.RPATH
is allowed unless it is deemed "dangerous":RPATH
in a library already part of PyInstaller archive...$ORIGIN
(below)$ORIGIN
(above)Problematic uses which cannot be corrected will point the user at #188.
Closes #172.
See #169.