Little bit of background:
I have a execuatable which requires admin-privileges to run. This executable also has a runtime dependency on a custom dynamic lib. That dynamic lib has to be loaded from a custom path (and not from /usr/lib
because a similar old version of this executable is present on which other libs may be referring to) which the executable is referring to setting up -RPATH
when compiling the executable.
When I ran that executable from command line using sudo
command everything works just fine as expected.
Now, this executable is fork/exec
from another non-root process, for which I am setting up the file permission chmod
of the executable to 4755
, so that the executable always run as root.
Problem now is the following thing, when I set the file permission chmod
to 4755
, the -RPATH
is no longer respected by the system, and my executable defaults to searching for the lib path to /usr/lib
, over -RPATH
.
Question: How can I force my executable to prefer -RPATH
over /usr/lib
, irrespective of what is there in my file permission (or at least chmod 4755
)?
Advertisement
Answer
Just in case any soul runs into this issue, here is what I did to resolve this issue.
Simply load the dylibs programmatically by dlopen APIs, by hardcoding the paths.