#!/bin/ksh # # mail_all_our_NSI_DNS_customers # # AUTHOR: # Dan Harkless # # COPYRIGHT: # This file is Copyright (C) 2000 by Dan Harkless, and is released under the # GNU General Public License . # # USAGE: # % mail_all_our_NSI_DNS_customers # # EXAMPLE: # % mail_all_our_NSI_DNS_customers warning_to_DNS_customers "ns.\.speed\.net" # # DESCRIPTION: # Goes through all the /var/named/db.* files to find the domains you host. # Does a whois -h whois.networksolutions.com to find contact addresses for # each domain registered through NSI. Puts these all in a file and sorts and # uniquifies them, then sends file $1 to each person. Note that $1 should be # a mail draft all ready to go, except without a To: line. # # The reason I wrote this was to let all our customers know about the dangers # inherent in Network Solutions' default MAIL-FROM security method. # # DATE MODIFICATION # ========== ================================================================== # 2000-04-05 Original. progname=${0##*/} # get the root name of the script as installed, for printing if [[ $# != 2 ]]; then print "Usage: $progname " exit 1 fi if [[ $1 = /* ]]; then mail_body=$1 else mail_body=$PWD/$1 fi cd /var/named address_tmpfile=/tmp/$progname.$$.address non_cust_file="$mail_body"_not_sent_to_these_non_DNS_customers whois_tmpfile=/tmp/$progname.$$.whois rm -f $address_tmpfile $non_cust_file $whois_tmpfile trap 'rm -f $address_tmpfile $whois_tmpfile; exit 1' 0 1 2 3 15 last_was_a_non_DNS_customer=FALSE for d in db.*.*[a-zA-Z]*; do d=`print "$d" | cut -c4-` whois $d > $whois_tmpfile if fgrep "query limit has been exceeded" $whois_tmpfile; then exit 1 fi if egrep -i "$2" $whois_tmpfile > /dev/null; then whois -h whois.networksolutions.com $d > $whois_tmpfile if fgrep "query limit has been exceeded" $whois_tmpfile; then exit 1 fi print -n "$d: " count=1 for a in `fgrep @ $whois_tmpfile | sed "s/.* \([^ ]*@.*\)/\1/g"`; do if [[ $count -gt 1 ]]; then print -n ", " fi print -n "$a" print "$a" >> $address_tmpfile count=$(($count + 1)) done print last_was_a_non_DNS_customer=FALSE else if [[ $last_was_a_non_DNS_customer = FALSE ]]; then print fi print "$d: Not a DNS customer! Please remove /var/named/db.$d!\n" print "$d" >> $non_cust_file last_was_a_non_DNS_customer=TRUE fi done print for a in `sort -u $address_tmpfile`; do print "$a: Mailing." print "To: $a" | cat - $mail_body | sendmail -t done