Skip to content
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

Permission denied error in add_external_libs when libary is not writable by owner #1287

Closed
1 of 2 tasks
vlaci opened this issue Nov 22, 2022 · 1 comment · Fixed by #1292
Closed
1 of 2 tasks

Permission denied error in add_external_libs when libary is not writable by owner #1287

vlaci opened this issue Nov 22, 2022 · 1 comment · Fixed by #1292
Labels
bug Something isn't working help wanted Extra attention is needed wheel Wheel

Comments

@vlaci
Copy link
Contributor

vlaci commented Nov 22, 2022

Bug Description

The issue is that patchelf fails when invoked on the copy of the to-be-included library as the original permissions are retained and nothing guaranties that they are owner writable which is the case for all libraries on NixOS

Example:

$ patchelf --set-soname libhs-19c0d7fc.so.5 /tmp/.tmpcBPM8J/libhs-19c0d7fc.so.5
patchelf: open: Permission denied
$ stat -c "Access: %a, UID: %u, GID: %g" /tmp/.tmpcBPM8J/libhs-19c0d7fc.so.5
Access: 555, UID: 1000, GID: 100
$ stat -c "Access: %a, UID: %u, GID: %g" /nix/store/l793dc6r9xagw7cfxv2w3bgwy9cy67yi-hyperscan-5.4.0/lib/libhs.so.5.4.0
Access: 555, UID: 0, GID: 0

I understand, there is an ongoing work to get rid of patchelf. In the meantime it could be mitigated by writing to a separate file via the --output flag of patchelf or fixing the permissions beforehand.

Your Python version (python -V)

Python 3.8.15

Your pip version (pip -V)

pip 22.2.2

What bindings you're using

No response

Does cargo build work?

  • Yes, it works

If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)?

  • Yes

Steps to Reproduce

I guess it is enough to set permissions to e..g 555 of a library dependency which gets picked up by auditwheel

@vlaci vlaci added the bug Something isn't working label Nov 22, 2022
@messense
Copy link
Member

Thanks for the report! I don't use Nix so I can't fix this, pull requests are welcome if anyone wants to fix it.

I understand, there is an ongoing work to get rid of patchelf.

That's not going to happen in near future because it's a rather hard task.

@messense messense added help wanted Extra attention is needed wheel Wheel labels Nov 23, 2022
bors bot added a commit that referenced this issue Nov 23, 2022
1292: add_external_libs: ensure write permission on libraries r=messense a=vlaci

`std::fs::copy` also copies the original file permissions. If the original library at `lib_path` was not writable, e.g. because it had its permission set to 0o555, the copy inherited the same permission causing later file manipulations, like `patchelf --set-soname` to fail.

Fixes #1287 

Co-authored-by: László Vaskó <1771332+vlaci@users.noreply.github.com>
@bors bors bot closed this as completed in a5e7236 Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed wheel Wheel
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants