I want to hook some functions in libssl with LD_PRELOAD in systemd.
In systemd file I put
ExecStart=/etc/myscript.sh
and in /etc/myscript.sh I put
#!/bin/sh
LD_PRELOAD=/lib/inject_libssl.so /bin/run
When I look at /proc/RUN_PID/maps I can see that inject_libssl.so is realy injected to the process but the original libssl.so is loaded before the the injected library, so my hook doesn't work.
I olso tried
ExecStart=/bin/run
Environment="LD_PRELOAD=/lib/inject_libssl.so"
But I got the same results.
If I run LD_PRELOAD=/lib/inject_libssl.so curl https://google.com the injected libssl works well.
Why is that please?