From owner-postfix-users@postfix.org Wed Mar 5 14:39:35 2003 Return-Path: Delivered-To: bet@tinho.net Received: from localhost.localdomain [127.0.0.1] by localhost with IMAP (fetchmail-6.2.0) for bet@localhost (single-drop); Wed, 05 Mar 2003 01:18:43 -0500 (EST) Received: from pink.rahul.net (pink.rahul.net [66.237.72.7]) by absinthe.tinho.net (Postfix) with ESMTP id 8A0C941FE6 for ; Tue, 4 Mar 2003 20:14:01 -0500 (EST) Received: from violet.rahul.net (violet.rahul.net [66.237.72.28]) by pink.rahul.net (Postfix) with ESMTP id 2E5DF2FE88 for ; Tue, 4 Mar 2003 17:14:01 -0800 (PST) Received: by violet.rahul.net (Postfix) id 9476BBC44; Tue, 4 Mar 2003 17:14:12 -0800 (PST) Delivered-To: bet@rahul.net Received: from mail.cloud9.net (camomile.cloud9.net [168.100.1.3]) by violet.rahul.net (Postfix) with ESMTP id C8D7BBC2D; Tue, 4 Mar 2003 17:14:06 -0800 (PST) Received: by mail.cloud9.net (Postfix) id BCDED64C38; Tue, 4 Mar 2003 20:13:31 -0500 (EST) Delivered-To: postfix-users-outgoing@cloud9.net Received: by mail.cloud9.net (Postfix, from userid 54) id B7DFE64C2B; Tue, 4 Mar 2003 20:13:31 -0500 (EST) X-Original-To: postfix-users@cloud9.net Delivered-To: postfix-users@cloud9.net Received: from localhost.cloud9.net (localhost.cloud9.net [127.0.0.1]) by mail.cloud9.net (Postfix) with ESMTP id 305C064C11 for ; Tue, 4 Mar 2003 20:13:31 -0500 (EST) Received: from mail.cloud9.net (localhost.cloud9.net [127.0.0.1]) by localhost.cloud9.net (VaMailArmor-2.0.1.7) id 00934-1708A553; Tue, 04 Mar 2003 20:13:31 -0500 Received: from malasada.lava.net (malasada.lava.net [64.65.64.17]) by mail.cloud9.net (Postfix) with ESMTP id BE25C64C00 for ; Tue, 4 Mar 2003 20:13:30 -0500 (EST) Received: by malasada.lava.net (Postfix, from userid 102) id 36BF1179F89; Tue, 4 Mar 2003 15:13:30 -1000 (HST) Date: Tue, 4 Mar 2003 15:13:30 -1000 From: Clifton Royston To: Jim Trigg Cc: postfix-users@postfix.org Subject: Re: DISCLAIMER statetment Message-ID: <20030304151330.D16618@lava.net> References: <20030304214636.GA3558@scadian.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20030304214636.GA3558@scadian.net>; from jtrigg@spamcop.net on Tue, Mar 04, 2003 at 04:46:36PM -0500 X-AntiVirus: checked by Vexira MailArmor (version: 2.0.1.7; VAE: 6.18.0.2; VDF: 6.18.0.10; host: camomile.cloud9.net) Sender: owner-postfix-users@postfix.org Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: On Tue, Mar 04, 2003 at 04:46:36PM -0500, Jim Trigg wrote: > On Tue, Mar 04, 2003 at 08:16:27PM +0100, Ralph Seichter wrote: > > Clifton Royston wrote: > > > [If] a generally useful mechanism for adding headers can be > > > implemented and if (big if!) it ends up accepted, you *might* > > > get your X-Disclaimer functionality as a spin-off. > > > > Then maybe we should ask ourselves if there's a need for such a mechanism. > > What kind of headers would be useful to add? I hope that headers like the > > I am not looking to add a disclaimer; the type of thing I want to add is > similar to what the webhost I use adds to my outgoing emails: > > X-AntiAbuse: This header was added to track abuse, please include it with any abuse report > X-AntiAbuse: Primary Hostname - dozer.liquidweb.com > X-AntiAbuse: Original Domain - spamcop.net > X-AntiAbuse: Originator/Caller UID/GID - [32225 747] / [32225 747] > X-AntiAbuse: Sender Address Domain - dozer.liquidweb.com > > (This off of an email sent from my huiekin.org domain, hosted by > liquidweb, to my spamcop email address.) > > Putting information of this nature into any messages sent out by my > postfix environment (that is, received either with authenticated SMTP > or through sendmail) would be very useful. OK, here are the fruits of a couple hours work on smtpprox. This was not hard at all, and I needed to do something like this to help me debug my real code anyway. The following enhancements enable it when plugged in as a content filter to add an arbitrary constant set of headers to every message, taken from a file specified on the command line. I have given it some simple testing, though I have not tried to stress-test it in any way. If you uncomment the spew(APPEND) lines and make a fairly obvious change to the MSDW::SMTP::Client yammer routine, you can make it append the contents of a different file to the end of the message, whether or not this is a good idea. -- Clifton --- smtpprox Fri Nov 1 03:00:45 2002 +++ dumbprox Tue Mar 4 15:08:43 2003 @@ -11,6 +11,13 @@ # GNU General Public License for more details. # # Written by Bennett Todd +# +# File insertion modifications by Clifton Royston +# and Copyright (C) 2003 LavaNet, contributed according to the terms of +# the GNU Public License with the restrictions found above. +# (Ordinarily I prefer to place my additions under a BSD-style license, +# but this is such a quick hack I see no need to quibble about it.) +# use strict; use Getopt::Long; @@ -21,12 +28,14 @@ =head1 NAME - smtprox -- Transparent SMTP proxy + smtpprox -- Transparent SMTP proxy =head1 SYNOPSIS smtpprox [options] listen.addr:port talk.addr:port options: + --prependheader=filename + --appendtrailer=filename --children=16 --minperchild=100 --maxperchild=200 @@ -58,7 +67,7 @@ =head1 EXAMPLE - smtpprox 127.0.0.1:10025 127.0.0.1:10026 + smtpprox 127.0.0.1:10025 127.0.0.1:10026 --prependheader=header.cf =head1 WARNING @@ -93,8 +102,12 @@ my $children = 16; my $minperchild = 100; my $maxperchild = 200; +my $prependheader = undef; +my $appendtrailer = undef; my $debugtrace = undef; GetOptions("children=n" => \$children, + "prependheader=s" => \$prependheader, + "appendtrailer=s" => \$appendtrailer, "minperchild=n" => \$minperchild, "maxperchild=n" => \$maxperchild, "debugtrace=s" => \$debugtrace) or die $syntax; @@ -104,6 +117,14 @@ my ($dstaddr, $dstport) = split /:/, $ARGV[1]; die $syntax unless defined($srcport) and defined($dstport); +if ( defined($prependheader) ) { + die "Can't open file $prependheader\n" unless open PREPEND, "<$prependheader"; +} + +if ( defined($appendtrailer) ) { + die "Can't open file $appendtrailer\n" unless open APPEND, "<$appendtrailer"; +} + my $server = MSDW::SMTP::Server->new(interface => $srcaddr, port => $srcport); # This should allow a kill on the parent to also blow away the @@ -150,7 +171,13 @@ $server->ok($banner); while (my $what = $server->chat) { if ($what eq '.') { + spew ( $client, *PREPEND ) if defined($prependheader); $client->yammer($server->{data}); + + # This next doesn't work, because yammer is defined to send + # the final "." to close the connection. Requires a change + # to MSDW::SMTP::Client. + # spew ( APPEND ) if defined($appendtrailer); } else { $client->say($what); } @@ -159,4 +186,15 @@ $client = undef; delete $server->{"s"}; exit 0 if $lives-- <= 0; +} + +sub spew { + my ($client, $fh ) = @_; + seek( $fh, 0, 0); + local( *_ ); + local( $/ ) = "\r\n"; + while ( <$fh> ) { + s/[\r\n]*$//; + $client->say($_); + } } -- Clifton Royston -- LavaNet Systems Architect -- cliftonr@lava.net "If you ride fast enough, the Specialist can't catch you." "What's the Specialist?" Samantha says. "The Specialist wears a hat," says the babysitter. "The hat makes noises." She doesn't say anything else. Kelly Link, _The Specialist's Hat_