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

Shared library is missing executable bit #109

Closed
tiran opened this issue Feb 10, 2021 · 1 comment · Fixed by #110
Closed

Shared library is missing executable bit #109

tiran opened this issue Feb 10, 2021 · 1 comment · Fixed by #110

Comments

@tiran
Copy link
Contributor

tiran commented Feb 10, 2021

RustExtension() creates a shared library without executable bit. Shared library on Linux, macOS, and probably other Unix-like operation systems must have executable bit. Kernel may refuse to mmap() shared libraries as PROT_EXEC.

See #106

$ ldd ./build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings/_rust.abi3.so
ldd: warning: you do not have execution permission for `./build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings/_rust.abi3.so'
        linux-vdso.so.1 (0x00007ffce3347000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f5702f8a000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5702f68000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f5702d9d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f5703026000)
$ ls -la ./build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings/*.so
-rwxrwxr-x. 1 heimes heimes 2669672 Feb 10 13:32 ./build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings/_openssl.abi3.so
-rwxrwxr-x. 1 heimes heimes   34400 Feb 10 13:32 ./build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings/_padding.abi3.so
-rw-rw-r--. 1 heimes heimes 3708904 Feb 10 13:32 ./build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings/_rust.abi3.so
@tiran
Copy link
Contributor Author

tiran commented Feb 10, 2021

# executables and win32(cygwin)-dll's need X bits
if executable or sys.platform == "win32" or sys.platform == "cygwin":
mode = os.stat(ext_path).st_mode
mode |= (mode & 0o444) >> 2 # copy R bits to X
os.chmod(ext_path, mode)

tiran added a commit to tiran/setuptools-rust that referenced this issue Feb 10, 2021
Fixes: PyO3#109
Signed-off-by: Christian Heimes <christian@python.org>
tiran added a commit to tiran/setuptools-rust that referenced this issue Feb 10, 2021
Shared libraries on Linux, macOS, and other Unix-like operating systems
require the executable bit, too.

Fixes: PyO3#109
Signed-off-by: Christian Heimes <christian@python.org>
tiran added a commit to tiran/setuptools-rust that referenced this issue Feb 11, 2021
Shared libraries on Linux, macOS, and other Unix-like operating systems
require the executable bit, too.

Fixes: PyO3#109
Signed-off-by: Christian Heimes <christian@python.org>
davidhewitt pushed a commit that referenced this issue Feb 11, 2021
* Shared libraries also need executable bit

Shared libraries on Linux, macOS, and other Unix-like operating systems
require the executable bit, too.

Fixes: #109
Signed-off-by: Christian Heimes <christian@python.org>

* Add changelog entry

Signed-off-by: Christian Heimes <christian@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant