I am facing a tricky problem with LD_LIBRARY_PATH in python3.8 on Ubuntu 20.04.1.
When I execute with my user the following lines:
user@host>export LD_LIBRARY_PATH=/usr/lib
user@host>echo $LD_LIBRARY_PATH
/usr/lib
user@host>python -c 'import os;print(os.getenv("LD_LIBRARY_PATH"))'
None
Python is not able to access LD_LIBRARY_PATH (please note that other variables are accessible as usual).
When I execute with root the same:
root@host>export LD_LIBRARY_PATH=/usr/lib
root@host>echo $LD_LIBRARY_PATH
/usr/lib
root@host>python -c 'import os;print(os.getenv("LD_LIBRARY_PATH"))'
/usr/lib
it works flawlessly. I therefore suspect it is a safety configuration, I already tried:
- AppArmor (from this thread on opensuse forum) : on my system there is no profile for python defined (
aa-status does
not show python, even whenps aux | grep python
yields various running instances). There is however an abstraction defined in/etc/apparmor.d/abstractions/python
which is included inlsb_release
andusr.bin.firefox
profiles. But neither of them should compromise the Python execution. The usual guides of creating a symlink in/etc/apparmor.d/disable
do not work since there is no profile for python which I could disable. - SELINUX (see the comment stackoverflow thread): on my system there does neither
/etc/selinux/config
norsestatus
exist. So I assume it is disabled, although the folder and some packages are installed. To be sure I executedsetfacl -b /usr/bin/python3.8
(see this thread on superuser) without any change.
Any sort of hint e.g. to other security flags / settings / out-of-the-box solutions (which do not include reinstalling the system from scratch) would be highly appreciated, since I spent already 1 entire day on this.
Some optional Background
I need to compile a rosnode running a python script, which includes C++ code with pybind11, which on the C++ side dynamically loads libraries available in the folders specified in LD_LIBRARY_PATH
. When manually executing the lines shared above with a conda interpreter ~/anaconda3/envs/myenv/bin/python
it correctly sees the library path, so it seems to be bounded to the executable in /usr/bin
. However I am unable to change the the python executable, since pybind11 uses old cmake find_package directives, always falling back to interpreters in /usr/bin
. Workarounds such as using rpath variables or manually changing the path at runtime see this stackoverflow thread are not an option.
The same exact projects works on two other machines running a fresh installation of Ubuntu 20.04 and a Debian Testing system. My recently updated ubuntu (from 18.04) therefore needs to have some hidden configuration issue, which I really would like to figure out.
0 Answers