Pregunta

I'm playing around with LD_PRELOAD and have produced a library that simply wraps puts() in a function that converts the string to be printed to uppercase before printing. I then export the LD_PRELOAD variable as so

$ export LD_PRELOAD=/home/adrian/test/myputs.so

Now the behaviour works as expected when running the command

$ /bin/pwd
/HOME/ADRIAN/TEST

But it does not work when runing like this

$ pwd
/home/adrian/test

What is the mechanism that's causing the LD_PRELOAD environment variable to be ignored in this case?

¿Fue útil?

Solución

Becausepwd is shell builtin command - see man bash or docs here. So if you write

$ pwd

Then the builtin command is launched. If you tell it the path, it will execute the ELF binary and use the LD_PRELOAD.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top