LD_PRELOAD does not loaded on systemd

Viewed 5127

I am trying to inject a SO into a process that starts using systemd init system (using LD_PRELOAD), but it does not loaded into the new process.

I complied a basic SO (unrandom.c):

int rand(){
    return 42; //the most random number in the universe
}

with the command line:

gcc -shared -fPIC unrandom.c -o unrandom.so

I changed the .service file to include:

Environment="LD_PRELOAD=/tmp/unrandom.so"

After starting the service the LD_PRELOAD environment variable is exist in the process, but the SO does not injected

cat /proc/<PID>/maps

Am I missing something?

My machine is RHEL7

1 Answers
Related