we're having some special requirements. we're using the pysoem library to communicate with ethercat devices. this means that the python executable needs cap_net_raw+ep capability, which can be achieved by running sudo setcap cap_net_raw+ep /path/to/python.
this works fine with the system python, but when setting it on the uv provided python executable:
sudo setcap cap_net_raw+ep ~/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/bin/python3.11
i get this when i then try to run python:
[...]/python3: error while loading shared libraries: $ORIGIN/../lib/libpython3.11.so.1.0: DST not allowed in SUID/SGID programs
if i run this:
patchelf --replace-needed "\$ORIGIN/../lib/libpython3.11.so.1.0" ~/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/libpython3.11.so.1.0 ~/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/bin/python3.11
it works (after re-running setcap), so it seems to be related to the relative path. and sure, from a security point of view i can understand why that may be problematic.
i found this:
|
# slash, the explicit path is used. |
|
patchelf --replace-needed ${LIBPYTHON_SHARED_LIBRARY_BASENAME} "\$ORIGIN/../lib/${LIBPYTHON_SHARED_LIBRARY_BASENAME}" \ |
|
${ROOT}/out/python/install/bin/python${PYTHON_MAJMIN_VERSION} |
|
|
|
# libpython3.so isn't present in debug builds. |
|
if [ -z "${CPYTHON_DEBUG}" ]; then |
|
patchelf --replace-needed ${LIBPYTHON_SHARED_LIBRARY_BASENAME} "\$ORIGIN/../lib/${LIBPYTHON_SHARED_LIBRARY_BASENAME}" \ |
|
${ROOT}/out/python/install/lib/libpython3.so |
|
fi |
|
|
|
if [ -n "${PYTHON_BINARY_SUFFIX}" ]; then |
|
patchelf --replace-needed ${LIBPYTHON_SHARED_LIBRARY_BASENAME} "\$ORIGIN/../lib/${LIBPYTHON_SHARED_LIBRARY_BASENAME}" \ |
|
${ROOT}/out/python/install/bin/python${PYTHON_MAJMIN_VERSION}${PYTHON_BINARY_SUFFIX} |
|
fi |
which is probably what causes this. but what is the right forward here? running pop!_os 22.04 lts (based on ubuntu 24.04) amd64
we're having some special requirements. we're using the pysoem library to communicate with ethercat devices. this means that the python executable needs
cap_net_raw+epcapability, which can be achieved by runningsudo setcap cap_net_raw+ep /path/to/python.this works fine with the system python, but when setting it on the
uvprovided python executable:i get this when i then try to run python:
if i run this:
it works (after re-running
setcap), so it seems to be related to the relative path. and sure, from a security point of view i can understand why that may be problematic.i found this:
python-build-standalone/cpython-unix/build-cpython.sh
Lines 684 to 697 in f0abfc9
which is probably what causes this. but what is the right forward here? running pop!_os 22.04 lts (based on ubuntu 24.04) amd64