[lug] Bletcherous pipe, FIXME!

Andrew Gilmore agilmore at skybeam.com
Thu Apr 2 12:55:32 MDT 2009


I discovered this nastiness in something I recommended in a benchmark, and before I got it published, thought I'd see if anyone cared to try to fix it...

The goal is to generate a sane default hosts.allow tcp wrappers only allowing hosts on the local networks.

printf "ALL: localhost" >> /etc/hosts.allow              
for I in `route -n |tail -n +3 |sed -e 's/ */ /g'| cut -f1,3 -d ' '
   --output-delimiter=/ | grep -vE "^(0|169)" |sort -n`; do
   printf ", $I" >> /etc/hosts.allow;
done
echo >> /etc/hosts.allow

Ouch, I know.

Anyone for a game of bash golf? :-)

Andrew



More information about the LUG mailing list