1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
#! /bin/sh
:
#$Id: x_command,v 1.23 1999/11/22 05:40:50 guenther Exp $
echo=echo # /bin/echo
test=test # /bin/test
cat=cat # /bin/cat
rm=rm # /bin/rm
formail=formail # /usr/local/bin/formail
subscribe=subscribe # ../SedBinDir/subscribe
unsubscribe=unsubscribe # ../SedBinDir/unsubscribe
multigram=multigram # ../SedBinDir/multigram
showlist=showlist # ../SedBinDir/showlist
tmprequest=tmp.request
tmpfrom=tmp.from
dist=dist
log=log
$test -z "$listaddr" &&
$echo "Don't start this script directly, it is used in rc.request" && exit 64
X_ENVELOPE_TO=$list-request # to convince (un)subscribe we used the right
export X_ENVELOPE_TO # address
$cat >$tmprequest
$formail -R$X_COMMAND: X-Processed: <$tmprequest
set dummy `$formail -x$X_COMMAND: <$tmprequest`
shift; shift
test "_$X_COMMAND_PASSWORD" = "_$1" && shift
while $test $# != 0
do
case "_$1" in
_subscribe|_unsubscribe|_checkdist)
if $test $# = 1
then
$echo "X-Diagnostic: Missing argument for $1"
set help
fi;;
esac
case "_$1" in
_subscribe)
$echo "The prospective subscriber address generates the following"
$echo "multigram matches to the current list:"
$echo ""
$echo "From $2" | $multigram -m -b8 -l-32767 dist
$echo ""
if $echo "From $2" | $multigram -l$match_threshold dist >$tmpfrom
then
$echo ""
$echo "$2 appears to already be subscribed:"
$cat $tmpfrom
else
$echo "From $2 " >$tmprequest
$echo "From: request ($listreq)" >>$tmprequest
$echo "Reply-To: $2" >>$tmprequest
$echo "To: $listreq" >>$tmprequest
$echo "Subject: subscribe $2" >>$tmprequest
$echo "$2" >$tmpfrom
$test -z "$subscribe_log" ||
$echo "x_command: subscribe" >>$subscribe_log
$subscribe <$tmprequest ||
$echo "X-Diagnostic: Unscreened, not subscribed"
fi
shift ;;
_unsubscribe)
$echo "The address that is about to unsubscribed generates the"
$echo "following multigram matches to the current list:"
$echo ""
$echo "From $2" | $multigram -m -b8 -l-32767 dist
$echo ""
$echo "From $2 " >$tmprequest
$echo "From: $listreq" >>$tmprequest
$echo "Reply-To: $2" >>$tmprequest
$echo "To: $listreq" >>$tmprequest
$echo "Subject: unsubscribe $2" >>$tmprequest
$echo "$maintainer" "$2" >$tmpfrom
$test -z "$subscribe_log" ||
$echo "x_command: unsubscribe" >>$subscribe_log
$unsubscribe -D <$tmprequest | $SENDMAIL $sendmailOPT `cat $tmpfrom`
shift ;;
_checkdist)
$echo "Multigram checking the dist file for matches with"
$echo "$2:"
$echo ""
$echo "From $2" | $multigram -m -b8 -l-32767 dist
$echo ""
shift ;;
_showlist)
$showlist -l $list ;;
_showdist)
$echo "--- Current subscribers:"
$cat $dist
$echo "--- End of subscriber list" ;;
_showlog)
$echo "--- Current log:"
$cat $log
$echo "--- End of log" ;;
_wipelog)
$cat /dev/null >$log ;;
_version)
flist -v 2>&1
echo ""
procmail -v 2>&1 ;;
_help|_info)
$echo "Known $X_COMMAND keywords:"
$echo " subscribe mailaddress"
$echo " unsubscribe mailaddress"
$echo " checkdist mailaddress"
$echo " showdist"
$echo " showlist"
$echo " showlog"
$echo " wipelog"
$echo " version"
$echo " help"
$echo " info" ;;
*) $echo "X-Diagnostic: Unknown command $1" ; set dummy help ;;
esac
shift
done
|