I want to replace libsqlite3 with the special version for Python.
I have a special version of libsqlite3.so.0 /path/to/libsqlite3.so.0 and configured LD_LIBRARY_PATH.
However, python’s internal will not load it.
I checked and noticed the following:
import sqlite3loads python’s original/usr/lib/python2.7/sqlite/__init__.pyanddbapi2.py.dbapi2.pyimports_sqlite, and this indicates/usr/lib/python2.7//lib-dynload/_sqlite3.so._sqlite3.soalways loads/usr/lib/i386-linux-gnu/libsqlite3.so.0, in spite of settingLD_LIBRARY_PATH.- If I copy
libpthread.so.0to/path/to/libpthread.so.0,_sqlite3.soloads it. So,/path/to/libpthread.so.0is loaded but/path/to/libsqlite3.so.0is not loaded.
I want to know how to load /path/to/libsqlite3.so.0, a special version, without replacing /usr/lib/i386-linux-gnu/libsqlite3.so.0 (only with non-privileged permission).
You might try to force loading of the lib with:
The library will be loaded in memory when python will be executed. So normally when
_sqlite3module will be imported, it will not load libsqlite3.so.0, and use the version already preloaded in memory.Edit
The LD_LIBRARY_PATH doesn’t work in that case cause libsqlite3.so.0 is loaded by _sqlite.so module, loaded by dlopen() within Python. In that case, the manpage of dlopen() said that the order is:
(ELF only) If the executable file for the calling program contains a DT_RPATH tag, and does not contain a DT_RUNPATH tag, then the directories listed in the DT_RPATH tag are searched.
If, at the time that the program was started, the environment variable LD_LIBRARY_PATH was defined to contain a colon-separated list of directories, then these are searched. (As a security measure this variable is ignored for set-user-ID and set-group-ID programs.)
…
So if an DT_RPATH is set on the binary, it will be taken prior to your LD_LIBRARY_PATH.