#!/bin/bash # $Id: blacklist,v 1.137 2019/03/20 00:12:35 fulford Exp fulford $ # $Source: /src/admin/usr/local/etc/RCS/blacklist,v $ # $Revision: 1.137 $ # Author C W Fulford. # Copyright 2017 (c) C W Fulford. # Licensed for public use under the LGPL, . # For assistance contact fulford@fulford.net 0793 572 8612 ######################################################################## cmd=`basename $0` config=/usr/local/etc/blacklist.cf ver=`echo "$Id: blacklist,v 1.137 2019/03/20 00:12:35 fulford Exp fulford $"|awk '{print $3,$4,$5}'` sysadmin=fulford@fulford.net syntax="$cmd [-l] | [-V]" while [ $# -gt 0 ] ;do case $1 in -l) log=:;shift;; -V) echo "$cmd $Revision: 1.137 $ $Date: 2019/03/20 00:12:35 $"|awk '{print $1,$3,$6}';exit;; esac done export ADMINHOST=admin export MAILHOST=mailhost export LOG=/var/log/blacklist/blacklist.log export TARGET=access export SRCDIR=/src/$MAILHOST/etc/mail # CityLinux keeps RCS records of critical files in separate file system export TARGETDIR=/etc/mail export SRC=$SRCDIR/$TARGET export DEST=$TARGETDIR/$TARGET export TMP=/tmp/${TARGET} address=`grep "^Return-Path: " | sed -e 's/Return-Path: <\([^>]*\)>/\1/'` echo "address = $address" domain=`echo $address|sed -e 's/[^@]*@\(.*$\)/\1/g'` echo "domain = $domain" # Spare legitimate domains ldomains=`awk <$config '{printf "%s ",$1}'` if echo $address |grep -s fulford.net; then mailx -s "blacklist ALERT" $sysadmin <<- . Blackist has found fulford.net in the Return-Path $address . echo "Blacklist has found fulford.net in the Return-Path:" fi blacklist=$domain for ld in $ldomains ;do if [ "$domain" == $ld ] ;then blacklist=$address fi done echo -n "Blacklist ${blacklist} [y/n]? " read answer <&2 answer=${answer:-"y"} if [ "$answer" == "y" ];then export BLACKLIST=`echo $blacklist|sed -e 's/\(.*\)/\1\t REJECT/'` ssh $ADMINHOST " #echo \"pwd = `pwd`\" #echo $ADMINHOST #echo \"SRCDIR = $SRCDIR\" cd $SRCDIR hostname co -l -q $TARGET echo $BLACKLIST >$TMP cat $TARGET >>$TMP # makemap will fail if there are duplicate entries in the # access file cat $TMP|sort -k1,1 -u > $TARGET #2>/dev/null cat $TARGET|ssh $MAILHOST sudo dd of=$DEST &2>/dev/null /usr/bin/ci -m -q $TARGET rm $TMP exit " ssh $MAILHOST " hostname echo $TARGETDIR echo \"`date`: $BLACKLIST\" >>$LOG cd $TARGETDIR sudo /usr/bin/make access.db sudo /etc/rc.d/rc.sendmail restart sudo logger -p mail.info -t blacklist \"$blacklist blacklisted\" " echo "$blacklist blacklisted." else echo "$blacklist has not been blacklisted." fi echo -n 'Press "Return" to continue';read ought </dev/tty ###################################################################### # This program is free software: you can redistribute it and or # # modify it under the terms of the Lesser GNU General Public License # # as published by the Free Software Foundation, either version 3 of # # the License, or (at your option) any later version. # # # # 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. # # # # A copy of the Lesser GNU General Public License and the GNU # # General Public License is available at # # <http://www.gnu.org/licenses/>. # ######################################################################
Copyright
© 2003-2017
Clifford W Fulford.
Fulford Consulting Ltd.
Regd. Co. 4250037 in England & Wales.
Regd. office 162, Edward Rd. Nottingham NG2 5GF, England, UK.
Related web sites: City Linux | Flare Support | West Bridgford | Fulford Portal | Joan Mary Fulford (Nottingham Writer) | Fulford Gallery | Amharic Interpreter | Arabic Interpreter | Tigrinya Interpreter
The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.