How to list all services linked to libwrap.a (tcp wrappers)

Yew Hang asked:

I know most Linux network services are linked to libwarp.a (tcp-wrappers) and this can be check via the ldd command. But can’t seem to find how to list all the network services being linked to libwarp.a.

After some waiting, I created a dump way myself. Run the script below in /usr/sbin

find ./ -type f -exec echo {} \; -exec ldd {} \; | egrep "\\./|libwrap" | less

Found 5 in CentOS7. Is there a correct way to do this?

My answer:

There are many ways to do it, but first you will want to search for binaries linking to

My one liner is (broken into separate lines for readability):

for file in /usr/sbin/*
    ldd $file 2>/dev/null | grep -q && echo $file

I’ve selected all the files I want to look at, here in /usr/sbin, but you can look elsewhere if you want.

I suppress error output from ldd because it’s noisy.

UsingĀ -q causes grep to not output anything (because seeing a bunch of would be pointless). And by using && I only run echo if grep found a match.

So I get:

$ for file in /usr/sbin/*; do ldd $file 2>/dev/null | grep -q && echo $file; done

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.