3 # NOTE: OMG - evidently 'read' can't be part of a pipeline if you want to export the variables
4 function child_of_sshd ()
8 while read xPID xPPID xO ; do
10 pid2ppid[$xPID]="$xPPID"
13 done < <( ps ax -opid,ppid,cmd | grep -E "sshd|bash" )
17 # is the working PID part of the pid2ppid mapping?
18 if echo ${!pid2ppid[@]} | grep -q $pid ; then
23 # is the working PID command sshd?
24 if echo "${pid2cmd[$pid]}" | grep -q 'sshd' ; then
25 # then success; we're a child or sshd
30 # we are not a child of sshd
34 if child_of_sshd ; then
35 export LD_PRELOAD=/usr/lib/snoopy.so