#!/usr/bin/perl # Original email accompanying letter at the end # Written by Arnt Gulbrandsen and copyright 1996 Troll # Tech AS, Postboks 6133 Etterstad, 0602 Oslo, Norway, fax +47 22646949. # # Use, modification and distribution is allowed without limitation, # warranty, or liability of any kind. # This script requires perl 5. use FileHandle; use Socket; ($j, $j, $proto) = getprotobyname("tcp"); # you MUST change the hostname below ($name, $j, $j, $j, $hisaddr) = gethostbyname("your.local.web.proxy"); if ($name eq "") { die "can't find address for web proxy\n"; } # you probably must change the port number. 3128 is the default for squid. $squid = pack('S n a4 x8', &AF_INET, 3128, $hisaddr); # you probably must change this directory too $zmailerdir = "/local/zmailer"; # Who is using this. $fromaddr = "postmaster@your.domain.name"; sub urlget { local( $_, $/ ); my( $url ) = @_; $_ = $url; undef $/; $SIG{'ALRM'} = \&timeout; alarm( 20 ); if (!(socket(SOCKET, &AF_INET, &SOCK_STREAM, $proto))) { print "couldn't create socket\n"; } elsif (!connect(SOCKET, $squid)) { die "connection to $_ failed (for $url): $!\n"; } else { my ( $head, $body ); alarm(0); SOCKET->autoflush(1); print SOCKET "GET $url HTTP/1.0\r\nFrom: $fromaddr\r\n\r\n"; $head = ; $head =~ s/\r+\n/\n/gs; $body = $head; $head =~ s/\n+\n.*/\n/s; $body =~ s/.*?\n\n//s; if ( $head =~ /^\S+\s+200\s+/s ) { undef %relocated; return $body; } elsif ( $head =~ /^\S+\s+30[12]\s+/ && $head =~ /\nLocation:\s*(http:.*?)\n/s ) { $_ = $1; if ( defined($relocated{$url}) ) { print STDERR "looping redirect for $url (to $_)\n"; return undef; } $relocated{$url} = $_; print STDERR "redirect to $_ for $url\n", return &urlget( $_ ); } elsif ( $head =~ /^\S+\s+304\s+/ ) { print STDERR $url, " not modified\n"; return undef; } else { print $url, "\n", $head; return undef; } } } undef $/; $_ = &urlget( "http://www.idot.aol.com/preferredmail/" ) || die "can't open PreferredMail list, stopped"; s/^.*//si; s- $zmailerdir/db/smtp-policy.spam" ) ) { foreach ( sort keys %reason ) { if ( /^([-a-z0-9]+\.)+[a-z]{2,3}$/ ) { print O "\043", $reason{$_}, ":\n.$_ = _bulk_mail\n"; } elsif ( /^\S+@([-a-z0-9]+\.)+[a-z]{2,3}$/ ) { print O "\043", $reason{$_}, ":\n$_ = _bulk_mail\n"; } } } #From: Arnt Gulbrandsen #To: Matti Aarnio #Cc: zmailer@nic.funet.fi #Subject: Re: DSN bug #Date: 21 Oct 1997 00:21:57 +0200 # #Matti Aarnio #> /Matti Aarnio -- in process of doing 2.99.49p8 release. # #Cool. Could you perhaps put this little ditty in contrib? It needs #perl and some trivial changes to policy-builder.sh, so I don't think #it should be in the default setup. # #It's a script to read four spam databases, combine them, and write the #result in a format zmailer can accept. # #--Arnt (who made sure that there was no more unread zmailer mail this time)