astral-sh / astral-sh/python-build-standalone

Document how to use raw sockets, low ports, etc. without running setcap on bin/python

Open
#643 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
4.4k
Forks
314
Avg merge
1d 9h
Merged PRs (30d)
27

Description

This is a pretty low-priority thing but the `setcap` approach mentioned in astral-sh/python-build-standalone#576 is a little undesirable for a few reasons. On our side it prevents us from ever having `$ORIGIN`-relative shared libraries, and on the user side, you need to do it every time you upgrade the Python binary and it breaks ptrace (`strace`, `gdb`, etc.). I want to write some recommendations for how to accomplish this goal without `setcap`.

I made an attempt in the comments in that issue but it seemed not to work out right, so the task here is to actually try this out and have a worked example.

(While at the moment we switched libpython to static linking, I don't love committing to this. It might be a good idea to turn libssl, libX11, etc. into shared libraries at some point and I don't want to block ourselves from doing that. Also, some of the workarounds we've talked about re statically linking libpython involve dynamically loading a fake/empty libpython, which would have to be just as `$ORIGIN`-relative as a real one.)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.