title: LD_PRELOAD in every log in to server
body: <p>I need to logging all terminal commands in Linux.
  I have found correctly working library in C, but it works only when I run <code>LD_PRELOAD=/usr/local/bin/bashpreload.so /bin/bash</code>:</p>
  
  <pre><code># ldd /bin/bash
      linux-vdso.so.1 =&gt;  (0x00007ffef59f8000)
      /usr/local/bin/bashpreload.so (0x00007fe691323000)
      libtinfo.so.5 =&gt; /lib64/libtinfo.so.5 (0x00007fe691102000)
      libdl.so.2 =&gt; /lib64/libdl.so.2 (0x00007fe690efe000)
      libc.so.6 =&gt; /lib64/libc.so.6 (0x00007fe690b6a000)
      /lib64/ld-linux-x86-64.so.2 (0x00007fe691524000)
  </code></pre>
  
  <p>If I log in again in the system after this, I will not see the lib with ldd:</p>
  
  <pre><code>[root@XXX ~]# LD_PRELOAD=/usr/local/bin/bashpreload.so /bin/bash
  [root@XXX ~]# ldd /bin/bash
      linux-vdso.so.1 =&gt;  (0x00007ffe481f6000)
      /usr/local/bin/bashpreload.so (0x00007f3f1b808000)
      libtinfo.so.5 =&gt; /lib64/libtinfo.so.5 (0x00007f3f1b5e7000)
      libdl.so.2 =&gt; /lib64/libdl.so.2 (0x00007f3f1b3e3000)
      libc.so.6 =&gt; /lib64/libc.so.6 (0x00007f3f1b04f000)
      /lib64/ld-linux-x86-64.so.2 (0x00007f3f1ba09000)
  [root@XXX ~]# exit
  [root@XXX ~]# logout
  Connection to XXX closed.
  [sahaquiel@sahaquiel-PC ~]$ ssh root@XXX
  root@XXX's password: 
  Last login: Tue Dec 19 11:28:22 2017 from YYY
  [root@XXX ~]# ldd /bin/bash
      linux-vdso.so.1 =&gt;  (0x00007ffca2f98000)
      libtinfo.so.5 =&gt; /lib64/libtinfo.so.5 (0x00007f19a13ff000)
      libdl.so.2 =&gt; /lib64/libdl.so.2 (0x00007f19a11fb000)
      libc.so.6 =&gt; /lib64/libc.so.6 (0x00007f19a0e67000)
      /lib64/ld-linux-x86-64.so.2 (0x00007f19a1620000)
  </code></pre>
  
  <p>And one more trouble: if I use this library, my current PID is changing:</p>
  
  <pre><code>Last login: Tue Dec 19 11:28:54 2017 from YYY
  [root@XXX ~]# echo "Library is not uploaded"
  Library is not uploaded
  [root@XXX ~]# echo $$
  4639
  [root@XXX ~]# LD_PRELOAD=/usr/local/bin/bashpreload.so /bin/bash
  [root@XXX ~]# echo $$
  4654
  [root@212-24-57-104 ~]# ps awwufx | grep -B5 [4]654
  root      1706  0.0  0.0  66256  1192 ?        Ss   10:54   0:00 /usr/sbin/sshd
  root      4517  0.0  0.0 104636  4644 ?        Ss   11:27   0:00  \_ sshd: root@pts/1 
  root      4519  0.0  0.0 108320  1872 pts/1    Ss+  11:27   0:00  |   \_ -bash
  root      4637  0.0  0.0 104636  4624 ?        Ss   11:30   0:00  \_ sshd: root@pts/0 
  root      4639  0.0  0.0 108320  1872 pts/0    Ss   11:30   0:00  |   \_ -bash
  root      4654  0.0  0.0 110376  1956 pts/0    S    11:31   0:00  |       \_ /bin/bash
  </code></pre>
  
  <p>So, I need two things:</p>
  
  <ol>
  <li>Find the way to do <code>LD_PRELOAD</code> quietly for each logging in user;</li>
  <li>Know why after this I'm working in the child <code>/bin/bash</code> process.</li>
  </ol>
  
  <p>Thanks!</p>