Skip to content

Commit

Permalink
auditwheel: ensure write permission on libraries
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
vlaci committed Nov 23, 2022
1 parent 12c1632 commit 084a4e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Tighten src-layout detection logic in [#1281](https://github.com/PyO3/maturin/pull/1282)
* Fix generating pep517 sdist for src-layout in [#1288](https://github.com/PyO3/maturin/pull/1288)
* Deprecate `python-source` option in Cargo.toml in [#1291](https://github.com/PyO3/maturin/pull/1291)
* Fix auditwheel with read-only libraries in [#1292](https://github.com/PyO3/maturin/pull/1292)

## [0.14.1] - 2022-11-20

Expand Down
6 changes: 6 additions & 0 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ impl BuildContext {
fs::copy(&lib_path, &dest_path)?;
libs_copied.insert(lib_path);

// fs::copy copies permissions as well, and the original
// file may have been read-only
let mut perms = fs::metadata(&dest_path)?.permissions();
perms.set_readonly(false);
fs::set_permissions(&dest_path, perms)?;

patchelf::set_soname(&dest_path, &new_soname)?;
if !lib.rpath.is_empty() || !lib.runpath.is_empty() {
patchelf::set_rpath(&dest_path, &libs_dir)?;
Expand Down

0 comments on commit 084a4e7

Please sign in to comment.