#!/bin/bash USER="CHANGEME" HOST="CHANGEME" # hostname of your mail (the part after @) TMP="/tmp/checkacc.$$" # filename of tmp-file (use $$ in filename to # suppress race-conditions ALIASES="/etc/aliases" # path to your aliases file ADD="" VERSION="0.1-release" DATE="Sun Apr 27 15:44:25 CEST 2003" # ChangeLog # Sun Apr 27 15:44:25 CEST 2003 # Benjamin Schieder # - released V0.1-release # --- NO NEED TO CHANGE ANYTHING BEYOND THIS LINE --- # if [ ! -x `which egrep` ] ; then echo "ERROR! Can't find egrep on this system!" exit 1 fi if [ ! -x `which perl` ] ; then echo "ERROR! Can't find perl on this system!" exit 1 fi if [ "$HOST" == "CHANGEME" ] ; then echo "ERROR! checkaccs.sh has not yet been configured!" exit 1 fi touch $TMP if [ ! -w $TMP ] ; then echo "ERROR! Can't write to $TMP! Please check!" >&2 exit 1 fi if [ ! -r $ALIASES ] ; then echo "ERROR! Can't read $ALIASES!" >&2 exit 1 fi STDIN="/dev/fd/0" if [ ! -r $STDIN ] ; then STDIN="/dev/stdin" if [ ! -r $STDIN ] ; then echo "ERROR! Can't access /dev/fd/0 or /dev/stdin! Can't continue!" >&2 exit 1 fi fi cat $STDIN > $TMP accs=`grep $USER $ALIASES | tr ':' ' ' | cut -f1 ` accs="$USER $accs" for x in $accs ; do if egrep -iq "^(To|CC):.*$x\@$HOST" $TMP ; then rm -rf $TMP exit 1 fi done for x in $ADD ; do if egrep -iq "^(To|CC):.*$x" $TMP ; then rm -rf $TMP exit 1 fi done cat $TMP | perl -e "while () { s/^Subject/X-Suspicious: yes\nSubject/; print; }" rm -f $TMP exit 0