5

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?

eltommo
  • 346
  • 3
  • 15

1 Answers1

4

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.

Tomas
  • 57,621
  • 49
  • 238
  • 373
  • 2
    Thanks! After a quick search I found I can disable the builtin pwd using `enable -n pwd` and now it behaves as expected. – eltommo Apr 25 '12 at 09:38
  • @eltommo, wow, I was not aware of this possiblity. Interesting! – Tomas Apr 25 '12 at 09:39