[lug] Bletcherous pipe, FIXME!
Jeffrey Haemer
jeffrey.haemer at gmail.com
Thu Apr 2 14:43:49 MDT 2009
Andrew
I'd find something like this is at least easier to maintain. YMMV.
{
printf "ALL: localhost"
route -n | egrep -v '^(0|169|[A-Z])' | # grab the
local hosts/masks
while read dest gateway genmask etc; do
printf ", $dest/$gateway" # turn into
comma-separated list
done
echo #
newline on the end
} >> /etc/hosts.allow # tack
onto the hosts.allow file
On Thu, Apr 2, 2009 at 12:55 PM, Andrew Gilmore <agilmore at skybeam.com> wrote:
>
> 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
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
--
Jeffrey Haemer <jeffrey.haemer at gmail.com>
720-837-8908 [cell]
303-997-1219 [Google Voice]
http://seejeffrun.blogspot.com
More information about the LUG
mailing list