#!/bin/sh # # authorize_email # # AUTHOR: # Dan Harkless # # COPYRIGHT: # This file is Copyright (C) 1998 by Dan Harkless, and is released under the # GNU General Public License . # # USAGE: # % authorize_email # # EXAMPLE: # % authorize_email MyFriend@aol.com dan-pop # # DESCRIPTION: # A script to be called automatically from your MH/nmh .maildelivery file to # allow someone at a specific email address to email you without having to go # through any challenge-response process. Adds the email address in $1 to the # list of people who are authorized to email you and delivers the message on # stdin to another of your accounts, $2. This script could be modified fairly # easily to work with procmail instead of MH's slocal. # # To use this script, your .maildelivery file must contain a section bounded # by the lines "# Allow email BEGIN" and "# Allow email END". authorize_email # will add authorized email addresses alphabetically to this section. # # DATE MODIFICATION # ========== ================================================================== # 1998-06-27 Previous copy of .maildelivery should be .prev, not ".bak". # 1997-11-04 Put MH/nmh library path in MH_LIB variable for easy customization. # 1997-06-18 Output variable number of TABs for pretty formatting. # 1997-05-29 Original. set -x # turn on trace mode so we can put the output of this script in a log # You may need to change this on your system! MH_LIB=/usr/local/lib/nmh # We use relative paths below, so make sure we're in our home directory. # We might not be if we're being run interactively for debugging purposes. cd # Wait for any other authorize_email invocations to finish. while [ -f authorize.lock ]; do sleep 10 done # Lock. trap 'rm -f authorize.lock maildelivery.new maildelivery.sort' 0 1 2 3 15 touch authorize.lock # Add to the list of people allowed to email. begin=`fgrep -n "Allow email BEGIN" .maildelivery | head -1 | cut -d: -f1` end=`fgrep -n "Allow email END" .maildelivery | head -1 | cut -d: -f1` head -$begin .maildelivery > maildelivery.new begin=`expr $begin + 1` lines=`expr $end - $begin` tail +$begin .maildelivery | head -$lines > maildelivery.sort email=`bin/email_address "$1"` length=`echo $email | awk '{print length}'` if [ $length -gt 18 ]; then tabs=' ' elif [ $length -gt 10 ]; then tabs=' ' elif [ $length -gt 2 ]; then tabs=' ' else tabs=' ' fi echo 'From '$email"$tabs"'^ ? "'$MH_LIB/rcvdist $2'"' \ >> maildelivery.sort sort maildelivery.sort | uniq >> maildelivery.new tail +$end .maildelivery >> maildelivery.new mv .maildelivery .maildelivery.prev mv maildelivery.new .maildelivery # Distribute the mail to a non-tainted account (it's on stdin). $MH_LIB/rcvdist $2