-1

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?

0

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

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

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

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 libwrap.so 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 libwrap.so && echo $file; done
/usr/sbin/auditd
/usr/sbin/exportfs
/usr/sbin/rpcbind
/usr/sbin/rpcinfo
/usr/sbin/rpc.mountd
/usr/sbin/rpc.statd
/usr/sbin/sshd
1
  • Thanks Michael. I learn -q and && today from this. I was thinking that it's normal for one who started to learn tcp-wrapper would be interested in knowing what are linked to it and hence there would be a common & easy method to list it out, no scripting required. I installed nfs to see do if I got the same result as you. Now I wonder, are the services "pre-linked" or linked during installation of nfs-utils?
    – Yew Hang
    May 5 '18 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.