#!/bin/ksh # $Id: mailaccept,v 1.8 2008/10/26 18:53:16 ksb Exp $ # We're a netlint plugin that reports who we accept mail for. (petef,ksb) # We cross-reference this with everyone who thinks we accept # mail for them. #****p* netlint/mail # NAME # mail # DESCRIPTION # Netlint records some aspects of the sendmail configuration for a host: the # list of hosts that the node accepts for mail devlivery and the list of MX # record this host advertises. Neither of these are errors without looking # at peers' nodes to integrate for mis-matches. #*** #****a* mail/MAIL_FOR # NAME # MAIL_FOR # FORMAT # MAIL_FOR: curly_expression # DESCRIPTION # There can be many lines of this type. This host accepts mail for each host # on the line. The line is compressed with unculry to form csh(1)-like # expressions which unpack to the list (use curly to unpack them). # REMEDIATION # The list comes from one of these file: # * $MAIL_CW # * /etc/mail/local-host-names # * /etc/mail/sendmail.cw # * /etc/sendmail.cw # # To remediate missing hosts, or non-existant ones, edit the file (in a # controlled manner, e.g. with vinst) to update it. #*** PROGNAME=`basename $0` : ${CARP:=echo} if [ -s /etc/mail/local-host-names ]; then : ${MAIL_CW:=/etc/mail/local-host-names} elif [ -s /etc/mail/sendmail.cw ] ; then : ${MAIL_CW:=/etc/mail/sendmail.cw} else : ${MAIL_CW:=/etc/sendmail.cw} fi if [ _"$1" = _"-V" ]; then echo "$PROGNAME: "'$Id: mailaccept,v 1.8 2008/10/26 18:53:16 ksb Exp $' echo "$PROGNAME: MDA local host names: $MAIL_CW" exit 0 fi [ -s $MAIL_CW ] || exit 0 TFILE=/tmp/mlc$$.$((RANDOM%1000)) while [ -f $TFILE ] ; do TFILE="$TFILE,$((RANDOM%100))" done (hostname; grep -v '#' $MAIL_CW) | sort -u >$TFILE export MAIL_CW TFILE cut -c1 $TFILE | sort -u | xapply -f 'grep "^%1" $TFILE |sort -u |uncurly' - | sed -e 's,^,MAIL_FOR: ,' | xapply -f "$CARP '%1'" - rm $TFILE exit 0