9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: boyd@sdgm.net
To: 9fans@cse.psu.edu
Subject: [9fans] spamoff
Date: Thu, 25 Sep 2003 20:58:37 -0400	[thread overview]
Message-ID: <44a6a272ef706cf46bb77346bfe7a91b@sdgm.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]

here is a first cut.  if you can read rc you can work it out.

just change:

    user=boyd

to be:

    user=<you>

stick it in $home/bin/rc and then:

    spamoff -c

use it at your peril.  bugs/flames to me.

btw: it assumes $home/^(lib log) exist.

bbtw: it's chucked away 1000's of spams and has been in use for a week.

[-- Attachment #2.1: Type: text/plain, Size: 314 bytes --]

The following attachment had content that we can't
prove to be harmless.  To avoid possible automatic
execution, we changed the content headers.
The original header was:

	Content-Disposition: attachment; filename=spamoff.bundle
	Content-Type: text/plain; charset="US-ASCII"
	Content-Transfer-Encoding: 7bit

[-- Attachment #2.2: spamoff.bundle.suspect --]
[-- Type: application/octet-stream, Size: 3907 bytes --]

# To unbundle, run this file
echo spamoff
sed 's/.//' >spamoff <<'//GO.SYSIN DD spamoff'
-#!/bin/rc
-
-#
-# spamoff addr mbox
-#
-# to setup: spamoff -c
-#
-
-rfork en
-
-ramfs >[2] /dev/null
-
-# set user to be you
-user=boyd
-
-lib=/usr/$user/lib/mail		# somewhere to put the below
-log=/usr/$user/log/mail
-allow=$lib/allow		# addr's you'll accept mail from
-audit=$log/audit		# audit trail
-errors=$log/errors		# error log
-rejects=$log/rejects		# list of addresses and codes
-
-upas=upas			# upas bin
-mp=/tmp/upasfs.$pid		# upas mbox file-system mount point
-ctl=$mp/ctl
-mbox=$mp/mbox/1
-
-myname=`{basename $0}
-
-# install like mail -c
-
-switch ($#*^$1) {
-case 1-c
-	flag +e
-
-	pipeto=/mail/box/$user/pipeto
-
-	{
-		echo '#!/bin/rc'
-		echo
-		echo /usr/$user/bin/rc/$myname '$*'
-	} > $pipeto
-
-	chmod +x $pipeto
-
-	for (i in $lib $log) {
-		if (! test -d $i)
-			mkdir $i
-	}
-
-	for (i in $audit $allow $errors $rejects) > $i
-
-	for (i in $audit $errors $rejects) {
-		chmod 622 $i
-		chmod +al $i
-	}
-
-	echo 'postmaster
-'$user'
-local!$user
-' > $allow
-
-	exit
-}
-
-# get $upas/fs to smash the message into manageable pieces
-mkdir $mp || exit mkdir
-msgtmp=/tmp/pipeto.$pid
-bind -ac /mail/tmp /tmp
-cat > $msgtmp
-$upas/fs -f $msgtmp -m $mp
-
-# try to cleanp the mess we have made
-fn cleanup {
-	unmount $mp
-	rm -f $mp
-	rm -f $msgtmp
-	unmount /tmp
-}
-
-# report error and give up
-fn err {
-	echo $myname: $* > $errors
-	cleanup
-	exit ''
-}
-
-# match $1 against a 'white list'
-fn match {
-	awk -v 'addr='$1 '
-BEGIN { e = 1}
-
-$0 ~ /^#.*/ || $0 == "" { next }
-
-$0 == addr {
-	e = 0
-	exit
-}
-
-END { exit e }
-' $allow
-}
-
-# see if it had been rejected, but is ok now
-fn reject {
-	awk -v 'addr='$1 -v 'code='$2 '
-BEGIN {	e = 1 }
-
-$1 == addr && $2 == code {
-	e = 0
-	exit
-}
-
-END { exit e }
-' $rejects > $audit
-}
-
-# deliver it or bitch about it to the sender
-fn bitch {
-	to=$1
-	mfile=$2
-
-	# 822 addresses are case insensitive, so go for lower case
-	addr=`{tr A-Z a-z < $mbox/replyto >[2] /dev/null}
-
-	# this had better be ok
-	if (~ $addr '')
-		err null reply address
-
-	# spammers sometimes bounce 'em back
-	if (~ $addr /dev/null)
-		err bounce from '<'$addr'>'
-
-	if (match $addr || reject $addr `{cat $mbox/subject >[2] /dev/null}) {
-		$upas/deliver $to $mbox/replyto $mfile < $mbox/raw
-		cleanup
-		exit ''
-	}
-
-	code=`{echo $myname$pid$addr | md5sum}
-
-	echo $code
-
-	{
-		echo From: $user
-		echo Subject: $user''''s $myname autoresponder
-		echo
-		echo Either you''''re a spammer or I don''''t like you or I don''''t know you.
-		echo
-		echo Email me this rejected message with exactly this code:
-		echo
-		echo '    '$code
-		echo
-		echo in the Subject: line and I''''ll decide if I''''ll add you to my list
-		echo of people I''''ll accept mail from.
-		echo
-		echo '    ---- Original Message ----'
-		echo
-		cat $mbox/raw
-
-	} | $upas/send $addr
-
-	# so we can $upas/fs it later, if necessary
-	#
-	# this is lunacy, but correct
-	#$upas/deliver $to $mbox/replyto $audit < $mbox/raw
-
-	# this is manageable, but not correct
-	$upas/deliver $to $mbox/replyto $audit < $mbox/rawheader
-
-	echo $addr $code > $rejects
-	err rejected mail from $addr $code
-}
-
-# these files had better be setup right
-
-if (! test -w $errors -a -A $errors -a -L $errors) {
-	echo $myname: $errors: existance/mode/permission problem >[1=2]
-	exit $errors
-}
-
-for (i in $audit $rejects) {
-	if (! test -w $i -a -A $i -a -L $i) {
-		err $i: existance/permission problem
-	}
-}
-
-if (! test -r $allow) {
-	err $allow: existance/permission problem
-}
-
-switch ($#*) {
-case 2
-	bitch $*
-
-case *
-	err args: $*
-}
//GO.SYSIN DD spamoff

             reply	other threads:[~2003-09-26  0:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-26  0:58 boyd [this message]
2003-09-26  2:26 ` ron minnich
  -- strict thread matches above, loose matches on Subject: below --
2003-09-01 14:54 boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44a6a272ef706cf46bb77346bfe7a91b@sdgm.net \
    --to=boyd@sdgm.net \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).