views:

36

answers:

4

How can I list all executables on my Red Hat Linux system which link to libssl? I can get close with:

find / -type f -perm /a+x -exec ldd {} \; | grep libssl   

ldd shows me which libraries the executable links with, but the line that contains the library name does not also show the filename, so although I get a lot of matches with grep, I can't figure out how to back out the name of the executable from which the match occured. Any help would be greatly appreciated.

A: 

I'm not sure, but maybe sudo lsof |grep libssl.so

a1ex07
Unfortunately I do not have root priveleges so I can't test this solution
Steven
+3  A: 
find / -type f -perm /a+x -print0 |
    while read -d $'\0' FILE; do
        ldd "$FILE" | grep -q libssl && echo "$FILE"
    done
John Kugelman
Maybe add `-xdev` and then this is probably the most robust solution, I think.
DarkDust
Thanks this worked perfectly!
Steven
A: 
find /usr/bin/ -type f -perm /a+x | while read i; do match=`ldd $i | grep libssl`; [[ $match ]] && echo $i; done

Instead of using -exec, pipe to a while loop and check a match before you echo the file name. Optionally, you could add "ldd $i" to the check on match using either () or a real if/then/fi block.

Dave
A: 
find / -type f -perm /a+x -xdev | while read filename ; do
  if ldd "$filename" | grep -q "libssl" ; then
    echo "$filename"
  fi
done

The -xdev makes find stay on the same filesystem (i.e. it won't dive into /proc or /sys). Note: if constructed this on Mac OS X, the -perm of yours doesn't work here so I don't know whether it's correct. And instead of ldd I've used otool -L but the result should be the same.

DarkDust