#!/bin/sh # # smtpcheck # John Simpson 2005-10-07 # # djb's "tcprulescheck" program relies on environment variables being # set, which is a pain when you're working on a command line. # # this script reads an IP address from the command line, does a dns # query to find out what name corresponds to the IP, and sets up the # environment variables so that tcprulescheck can do its job. # ############################################################################### # # Copyright (C) 2005 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # or visit http://www.gnu.org/licenses/gpl.txt # ############################################################################### # the cdb file against which you want to check the IP addresses. CDB="/etc/tcp/smtp.cdb" TCPREMOTEIP=${1:?No IP address specified} export TCPREMOTEIP while [ -n "$TCPREMOTEIP" ] do echo "(checking $TCPREMOTEIP)" n=`dnsname $TCPREMOTEIP` if [ -n "$n" ] then TCPREMOTEHOST=$n export TCPREMOTEHOST else export -n TCPREMOTEHOST fi tcprulescheck $CDB shift TCPREMOTEIP=${1:-} if [ -n "$TCPREMOTEIP" ] then echo "" fi done