Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!mailrus!umix!honey From: honey@umix.cc.umich.edu (Peter Honeyman) Newsgroups: comp.mail.uucp Subject: Re: BSMTP - Its time has come Message-ID: <4124@umix.cc.umich.edu> Date: 18 Jun 88 03:33:01 GMT References: <2300@ncr-sd.SanDiego.NCR.COM> Reply-To: honey@citi.umich.edu (Peter Honeyman) Organization: Center for Information Technology Integration, Univ of Michigan Lines: 103 UUCP-Path: {uunet,rutgers}!umix!honey here's an idea, inspired by matt's note. # usage bmail host. input from pipe. JOBDIR=/usr/spool/uucppublic/bsmtp # check args, grab host name. if [ $# != 1 ]; then echo usage: `basename $0` host 2>&1 exit 1 fi host=$1 if [ ! -d $JOBDIR/$host ]; then mkdir $JOBDIR/$host # should check error status fi # make a uucp lock for $host. uucplock $host $$ newbatchfile=$? # clean old spooled stuff. bsmtpclean $host # get name of batch file. if [ $newbatchfile = 0 ]; then suffix=`oldbatchfile host` else suffix=`newbatchfile host` fi batchfile=batch.$suffix statfile=stat.$suffix controlfile=control.$suffix # dump new mail into the batch file. (from stdin.) addtobatch $batchfile # if new, spool it. store the jobid for later reference. if [ $newbatchfile != 0 ]; then uux -s $JOBDIR/$host/$statfile host!bsmtpunpack '<' !$batchfile if [ $? != 0 ]; then exit 101 fi echo $batchfile $statfile > $controlfile fi exit 0 bsmtpclean, uucplock, uucpunlock, oldbatchfile, newbatchfile, and addtobatch are not hard -- one or more of them are appended. (these too are just sketches, but they should get the idea across.) i haven't thought this through entirely, so access protection is not addressed here. but some combination of ruid, euid, file modes, and PERMISSIONS entries are needed to flesh this out. peter # usage: bsmtpclean host JOBDIR=/usr/spool/uucppublic/bsmtp # check args, grab host name. if [ $# != 1 ]; then echo usage: `basename $0` host 2>&1 exit 1 fi host=$1 cd $JOBDIR/$host # should check for error # clean up. for controlfile in $control.*; do set `cat $i` batchfile=$1 statfile=$2 if [ grep -s 'exited normally' $statfile ]; then rm -f $batchfile $statfile $controlfile fi done exit # usage: uucplock host pid # make a uucp lock for host. return 0 if successful, # return 1 if a lock already exists. LOCKDIR=/usr/spool/locks # check args, grab host name. if [ $# != 1 ]; then echo usage: `basename $0` host 2>&1 exit 1 fi host=$1 pid=$2 # make a lock if one does not exist. uucp will eventually clean up. # this can be improved to override a dead lock. cd $LOCKDIR locklink=bsmtp-lock.$$ trap "rm -f $locklink" 0 echo $pid | awk '{printf("%10d\n", $1)}' > $locklink lockfile=`echo LCK..$host|cut -c1-14` # or colrm 15 ln $locklink $lockfile if [ $? != 0 ]; then exit 101 fi exit 0 exit $? # redundant