title: LD_PRELOAD with setuid binary
body: <p>I am trying to use <code>LD_PRELOAD</code> to preload a library with an application that has setuid permissions. Tried <code>LD_PRELOAD</code> at first, and it seemed like it was being ignored with the setuid binary, though it was working when I tried it with others like <code>ls</code>, <code>dir</code> etc. </p>
  
  <p>From the documentation of LD_PRELOAD:</p>
  
  <pre><code>   LD_PRELOAD
            A whitespace-separated list of additional, user-specified, ELF shared
            libraries to be loaded before all others.  This can be used to
            selectively override functions in other shared libraries.  For set-
            user-ID/set-group-ID ELF binaries, only libraries in the standard
            search directories that are also set-user-ID will be loaded.
  </code></pre>
  
  <p>I tried to put the library in <code>/usr/lib</code>, <code>/usr/local/lib</code>, and <code>/usr/lib64</code> with setuid permissions as per this documentation above, but it still doesnt seem to work. If I dont give <code>LD_PRELOAD</code> a path in the case where I have the library in the standard dirs with setuid, it cannot seem to find the library. If I give it the path, it does not do anything.</p>
  
  <p>The setuid binary is a root permissions binary that runs in a non root user shell. Any thoughts? Not sure if I am missing a path, an environment variable, or I am misunderstanding the documentation above.</p>
  
  <p><em>Edit</em>: permissions as requested are:</p>
  
  <p>Library:</p>
  
  <pre><code>-rwsr-sr-x 1 root root 72580 2012-02-10 07:51
  </code></pre>
  
  <p>App:</p>
  
  <pre><code>-rwsr-xr-x 1 root root 137517601 2012-02-10 
  
  env | grep LD
  LD_LIBRARY_PATH=/usr/lib (I added this manually myself, usually LD_LIBRARY_PATH is empty)
  </code></pre>