INN commit: trunk (8 files)

INN Commit Russ_Allbery at isc.org
Sun Nov 30 12:37:19 UTC 2008


    Date: Sunday, November 30, 2008 @ 04:37:18
  Author: iulius
Revision: 8198

Add an optional third parameter to news2mail, specifying the envelope-from
address for e-mails sent to lists.
Also fix a long-standing bug about the use of the first argument (in To:).
Fix levels for syslog calls.

Thanks to D. Stussy for the patch.

Convert the documentation into POD.  Update the samples files.
Use "Ap" and an exclusion of the list owner domain in newsfeeds.

Added:
  trunk/doc/pod/news2mail.pod
Modified:
  trunk/MANIFEST
  trunk/backends/news2mail.in
  trunk/doc/man/	(properties)
  trunk/doc/pod/Makefile
  trunk/samples/news2mail.cf
  trunk/samples/newsfeeds.in
Deleted:
  trunk/doc/man/news2mail.8

-----------------------+
 MANIFEST              |    1 
 backends/news2mail.in |  191 ++++++++++++++++++++++++------------------------
 doc/man/news2mail.8   |   73 ------------------
 doc/pod/Makefile      |    3 
 doc/pod/news2mail.pod |   73 ++++++++++++++++++
 samples/news2mail.cf  |   49 +++++++-----
 samples/newsfeeds.in  |   10 +-
 7 files changed, 208 insertions(+), 192 deletions(-)

Modified: MANIFEST
===================================================================
--- MANIFEST	2008-11-29 20:07:27 UTC (rev 8197)
+++ MANIFEST	2008-11-30 12:37:18 UTC (rev 8198)
@@ -300,6 +300,7 @@
 doc/pod/motd.news.pod                 Master file for motd.news.5
 doc/pod/news.daily.pod                Master file for news.daily.pod.8
 doc/pod/news.pod                      Master file for NEWS
+doc/pod/news2mail.pod                 Master file for news2mail.8
 doc/pod/newsfeeds.pod                 Master file for newsfeeds.5
 doc/pod/newsgroups.pod                Master file for newsgroups.5
 doc/pod/newslog.pod                   Master file for newslog.5

Modified: backends/news2mail.in
===================================================================
--- backends/news2mail.in	2008-11-29 20:07:27 UTC (rev 8197)
+++ backends/news2mail.in	2008-11-30 12:37:18 UTC (rev 8198)
@@ -1,35 +1,35 @@
 #! /usr/bin/perl -w
 # fixscript will replace this line with code to load INN::Config
 
-# news to mail channel backend
+# $Id$
+# News to mail channel backend.
 #
 # INN gives us
-#	@token@ addrs
+#     @token@ lists
 # for each article that needs to be mailed.  We invoke sm on the
-# localhost to get the actual article and stuff
-# it down sendmail's throat.
+# localhost to get the actual article and stuff it down sendmail's throat.
 # 
-# This program expect to find a file that maps listname to listaddrs,
-#	<pathetc>/news2mail.cf
-# which must contain address mapping pairs such as
+# This program expects to find a file that maps listname to listaddrs:
+#     <pathetc>/news2mail.cf
+# which must contain address mapping lines such as:
 #
-#	big-red-ants at ucsd.edu	big-red-ants-digest at ucsd.edu		
+#    list-big-red-ants	big-red-ants at lists.ucsd.edu	news+big-red-ants at local.news.server.org
 #
-# where the first token is the name fed to us from INN, and which is
-# also placed in the To: header of the outgoing mail.  It's probably
-# the subscriber's list submittal address so that replies go to the
-# right place.  The second token is the actual address sendmail ships
-# the article to.
+# where the first token is the name fed to us from the INN's newsfeeds file.
+# The second token is the actual address sendmail ships the article to.
+# The third token is optional:  it sets the envelope-from address.
 #
-# In the INN newsfeeds file, you need to have a channel feed:
-#	n2m!:!*:Tc,Ac,Wn*:<pathbin>/news2mail
+# In the INN's newsfeeds file, you need to have a channel feed:
+#     news2mail!:!*:Ac,Tc,Wn*:<pathbin>/news2mail
 # and a site for each of the various mailing lists you're feeding,
 # such as
-#	big-red-ants at ucsd.edu:rec.pets.redants.*:Tm:n2m!
+#     list-big-red-ants/lists.ucsd.edu:!*,rec.pets.red-ants:Ap,Tm:news2mail!
 #
 # Error handling is nearly nonexistent.
 #
-#	- Brian Kantor, UCSD Aug 1998
+#     - Brian Kantor for the initial script.  (UCSD, August 1998.)
+#     - D. Stussy added support for the third optional token for envelope-from
+#       address.  (June 2008.)
 
 require 5.006;
 
@@ -40,6 +40,7 @@
 my $sendmail = $INN::Config::mta ;
 my $sm = $INN::Config::pathbin . "/sm" ;
 my %maddr = ();
+my %saddr = ();
 my $use_syslog = 0;
 
 eval { require Sys::Syslog; import Sys::Syslog; $use_syslog = 1; };
@@ -54,105 +55,107 @@
 
 syslog('info', 'begin') if ($use_syslog);
 
-#
-# load the list names and their mail addresses from cf file
-# #comments and blank lines are ignored
-#
-unless (open CF, "< $cfFile") {
-		syslog('notice', 'CF open failed %m') if ($use_syslog);
-		die "bad CF";
-		}
 
-while ( <CF> ) {
-	next if /^#|^\s+$/;
-	my ( $ln, $ma ) = split /\s+/;
-	$maddr{ $ln } = $ma;
-	}
-close CF;
+# Load the list names and their mail addresses from the configuration file.
+# Comments and blank lines are ignored.
+unless (open(CF, "< $cfFile")) {
+    syslog('notice', 'CF open failed %m') if ($use_syslog);
+    die "bad CF";
+}
 
-#
-# for each incoming line from the INN channel
-#
-while ( <STDIN> ) {
-	chomp;
+while (<CF>) {
+    next if /^#|^\s+$/;
+    my ($ln, $ma, $sa) = split /\s+/;
+    $maddr{$ln} = $ma;
+    $saddr{$ln} = $sa if ($sa =~ /.+/);
+    $sa = $INN::Config::newsuser if (!defined($saddr{$ln}));
+    syslog('debug', "List=$ln, To=<$ma>, From=<$sa>") if ($use_syslog);
+}
+close(CF);
 
-	syslog('info', $_) if ($use_syslog);
 
-	my ($token, $lnames) = split /\s+/, $_, 2;
-	my @addrs = split /\s+/, $lnames;
+# For each incoming line from the INN channel.
+while (<STDIN>) {
+    chomp;
+    syslog('info', $_) if ($use_syslog);
 
-	my @good = grep {  defined $maddr{$_} } @addrs;
-	my @bad  = grep { !defined $maddr{$_} } @addrs;
+    my ($token, $lnames) = split(/\s+/, $_, 2);
+    my @addrs = split(/\s+/, $lnames);
+    my @good = grep {  defined($maddr{$_}) } @addrs;
+    my @bad  = grep { !defined($maddr{$_}) } @addrs;
 
-	if (! @good) {
-		syslog('notice', "unknown listname $_") if ($use_syslog);
-		next;
-		}
+    if (!@good) {
+        syslog('notice', "unknown list(s):  $lnames") if ($use_syslog);
+        next;
+    }
 
-	if (@bad) {
-		syslog('info', 'skipping unknown lists: ', join(' ', @bad)) if ($use_syslog);
-		}
-	mailto($token, $lnames, @maddr{@good});
-	}
+    if (@bad) {
+        syslog('info', 'skipping list(s):  ', join(' ', @bad)) if ($use_syslog);
+    }
 
+    my $sa = $INN::Config::newsuser;
+    my @src = grep { defined($saddr{$_}) } @good;
+    $sa = @saddr{@src} if (@src == 1);
+    mailto($token, $sa, @maddr{@good});
+}
+
 syslog("info", "end") if ($use_syslog);
 
 exit 0;
 
+
 sub mailto {
-	my($t, $l, @a) = @_ ;
+    my($t, $s, @a) = @_;
 
-	my $sendmail = $INN::Config::mta ;
-	$sendmail =~ s!\s*%s!! ;
-	my @command = (split (' ', $sendmail), '-ee', '-fnews', '-odq', @a);
-#	@command[0] = '/usr/local/bin/debug';
+    my $sendmail = $INN::Config::mta;
+    $sendmail =~ s!\s*%s!!;
+    my @command = (split(' ', $sendmail), '-ee', '-odq', "-f$s",
+                   "-pNNTP:$INN::Config::pathhost", @a);
 
-	syslog('info', join(' ', @command)) if ($use_syslog);
+    syslog('debug', join(' ', @command)) if ($use_syslog);
 
-	unless (open(SM, '|-', @command)) {
-		syslog('notice', join(' ', '|', @command), 'failed!') if ($use_syslog);
-		die "bad $sendmail";
-		}
+    unless (open(SM, '|-', @command)) {
+        syslog('error', join(' ', '|', @command), 'failed!') if ($use_syslog);
+        die "bad $sendmail";
+    }
 
-	my $smgr = "$sm -q $t |";
+    my $smgr = "$sm -q $t |";
 
-	unless (open(SMGR, $smgr)) {
-	    syslog('notice', "$smgr failed!") if ($use_syslog);
-	    die "bad $smgr";
-	}
+    unless (open(SMGR, $smgr)) {
+        syslog('error', "$smgr failed!") if ($use_syslog);
+        die "bad $smgr";
+    }
 
-	# header
-	while ( <SMGR> ) {
-		chomp;
+    # Header.
+    while (<SMGR>) {
+        chomp;
 
-		# empty line signals end of header
-		if ( /^$/ ) {
-			print SM "To: $l\n\n";
-			last;	
-			}
+        # Empty line signals the end of header.
+        if (/^$/) {
+            print SM "To: @a\n\n";
+            last;
+        }
 
-		#
-		# skip unnecessary headers
-		#
-		next if /^NNTP-Posting-Date:/i;
-		next if /^NNTP-Posting-Host:/i;
-		next if /^X-Trace:/i;
-		next if /^Xref:/i;
-		next if /^Path:/i;
+        # Skip unnecessary headers.
+        next if /^X-/i;
+        next if /^To:/i;
+        next if /^NNTP-Posting-Date:/i;
+        next if /^NNTP-Posting-Host:/i;
+        next if /^Lines:/i;
+        next if /^Xref:/i;
+        next if /^Path:/i;
 
-		#
-		# convert Newsgroups header into X-Newsgroups
-		#
-		s/^Newsgroups:/X-Newsgroups:/i;
+        # Convert Newsgroups: header into X-Newsgroups:.
+        s/^Newsgroups:/X-Newsgroups:/i;
 
-		print SM "$_\n";
-		}
+        print SM "$_\n";
+    }
 
-	# body
-	while ( <SMGR> ) {
-		print SM $_;
-	}
+    # Body.
+    while (<SMGR>) {
+        print SM $_;
+    }
 
-	close(SMGR);
-	close(SM);
-	}
+    close(SMGR);
+    close(SM);
+}


Property changes on: trunk/doc/man
___________________________________________________________________
Modified: svn:ignore
   - active.5
active.times.5
actsync.8
archive.8
auth_krb5.8
auth_smb.8
batcher.8
buffchan.8
buffindexed.conf.5
ckpasswd.8
control.ctl.5
convdate.1
ctlinnd.8
cycbuff.conf.5
distrib.pats.5
distributions.5
docheckgroups.8
domain.8
expire.ctl.5
expireover.8
fastrm.1
getlist.1
grephistory.1
ident.8
incoming.conf.5
inews.1
inn.conf.5
INN__Config.3pm
innbind.8
innconfval.1
innd.8
inndf.8
innmail.1
innupgrade.8
libauth.3
libinnhist.3
list.3
mailpost.8
makehistory.8
moderators.5
motd.news.5
newsfeeds.5
news.daily.8
newslog.5
newsgroups.5
ninpaths.8
nnrpd.8
ovdb.5
ovdb_init.8
ovdb_monitor.8
ovdb_server.8
ovdb_stat.8
overchan.8
passwd.nntp.5
perl-nocem.8
pgpverify.1
pullnews.1
qio.3
radius.8
radius.conf.5
rc.news.8
readers.conf.5
rnews.1
sasl.conf.5
scanlogs.8
send-uucp.8
sendinpaths.8
shlock.1
simpleftp.1
sm.1
storage.conf.5
subscriptions.5
tally.control.8
tdx-util.8
tinyleaf.8
tst.3
uwildmat.3

   + active.5
active.times.5
actsync.8
archive.8
auth_krb5.8
auth_smb.8
batcher.8
buffchan.8
buffindexed.conf.5
ckpasswd.8
control.ctl.5
convdate.1
ctlinnd.8
cycbuff.conf.5
distrib.pats.5
distributions.5
docheckgroups.8
domain.8
expire.ctl.5
expireover.8
fastrm.1
getlist.1
grephistory.1
ident.8
incoming.conf.5
inews.1
inn.conf.5
INN__Config.3pm
innbind.8
innconfval.1
innd.8
inndf.8
innmail.1
innupgrade.8
libauth.3
libinnhist.3
list.3
mailpost.8
makehistory.8
moderators.5
motd.news.5
newsfeeds.5
news.daily.8
news2mail.8
newslog.5
newsgroups.5
ninpaths.8
nnrpd.8
ovdb.5
ovdb_init.8
ovdb_monitor.8
ovdb_server.8
ovdb_stat.8
overchan.8
passwd.nntp.5
perl-nocem.8
pgpverify.1
pullnews.1
qio.3
radius.8
radius.conf.5
rc.news.8
readers.conf.5
rnews.1
sasl.conf.5
scanlogs.8
send-uucp.8
sendinpaths.8
shlock.1
simpleftp.1
sm.1
storage.conf.5
subscriptions.5
tally.control.8
tdx-util.8
tinyleaf.8
tst.3
uwildmat.3


Deleted: doc/man/news2mail.8
===================================================================
--- doc/man/news2mail.8	2008-11-29 20:07:27 UTC (rev 8197)
+++ doc/man/news2mail.8	2008-11-30 12:37:18 UTC (rev 8198)
@@ -1,73 +0,0 @@
-.\" -*- nroff -*-
-.\" $Revision$
-.TH NEWS2MAIL 8
-.SH NAME
-news2mail \- a channel script to gateway news into e\-mail.
-.SH SYNOPSIS
-.I news2mail
-.SH DESCRIPTION
-.I news2mail
-runs as a channel process underneath innd. It is set up as channel feed in
-newsfeeds, with different mailing lists as funnel entries pointing to it (see
-below).
-.PP
-.I news2mail
-uses a config file 
-.PP
-.RS
-.I <pathetc\ in\ inn.conf>/news2mail.cf
-.RE
-.PP
-to map mailing list names to e\-mail addresses.
-.PP
-.I news2mail
-causes sendmail to queue the messages for later delivery (to avoid DOS attacks
-by mass postings). You must run 'sendmail -q' periodically to get the queue
-processed.
-.SH CONFIG FILE
-The config file format is simple: comments (start with ``#'') and blank lines
-are ignored. All other lines have two fields on them. The first is the list
-name and is what innd uses (i.e. the site field of the entry in the newsfeeds
-file). The second field is the actual e\-mail address to send the article to. In
-the e\-mail message, the ``To'' header will have the mailing list name (i.e. the
-first field).
-.PP
-.RS
-.nf
-# list-name             address
-big-red-ants at ucsd.edu   big-red-ants-digest at ucsd.edu		
-news-software at ucsd.edu  news-software-digest at ucsd.edu
-.fi
-.RE
-.PP
-a set of newsfeeds entries for these lists would be:
-.PP
-.RS
-.nf
-.ds R$ <pathbin in inn.conf>
-n2m!:!*:Tc,Ac,Wn*:\*(R$/news2mail
-
-big-red-ants at ucsd.edu:rec.pets.redants.*:Tm:n2m!
-
-news-software at ucsd.edu:news.software.nntp:Tm:n2m!
-.fi
-.RE
-.PP
-.I news2mail
-strips most article headers from the article before mailing. It leaves: From, Subject
-Date, Organization and Message-ID in there. It add a To header with the mailing 
-list name in it.
-.SH HISTORY
-news2mail was written by Brian Kantor. This man page was written by James
-Brister.
-.de R$
-This is revision \\$3, dated \\$4.
-..
-.R$ $Id$
-.SH "SEE ALSO"
-ctlinnd(8),
-inn.conf(5),
-innd(8),
-newsfeeds(5),
-shlock(1).
-

Modified: doc/pod/Makefile
===================================================================
--- doc/pod/Makefile	2008-11-29 20:07:27 UTC (rev 8197)
+++ doc/pod/Makefile	2008-11-30 12:37:18 UTC (rev 8198)
@@ -33,7 +33,7 @@
 	../man/domain.8 \
 	../man/expireover.8 ../man/ident.8 ../man/innd.8 ../man/inndf.8 \
 	../man/nnrpd.8 ../man/innbind.8 ../man/innupgrade.8 \
-	../man/makehistory.8 ../man/news.daily.8 ../man/ninpaths.8 \
+	../man/makehistory.8 ../man/news.daily.8 ../man/news2mail.8 ../man/ninpaths.8 \
 	../man/ovdb_init.8 ../man/ovdb_monitor.8 ../man/ovdb_server.8 \
 	../man/ovdb_stat.8 ../man/overchan.8 ../man/radius.8 \
 	../man/rc.news.8 ../man/scanlogs.8 ../man/sendinpaths.8 \
@@ -118,6 +118,7 @@
 ../man/innupgrade.8:	innupgrade.pod		; $(POD2MAN) -s 8 $? > $@
 ../man/makehistory.8:	makehistory.pod		; $(POD2MAN) -s 8 $? > $@
 ../man/news.daily.8:	news.daily.pod		; $(POD2MAN) -s 8 $? > $@
+../man/news2mail.8:	news2mail.pod		; $(POD2MAN) -s 8 $? > $@
 ../man/ninpaths.8:	ninpaths.pod		; $(POD2MAN) -s 8 $? > $@
 ../man/nnrpd.8:		nnrpd.pod		; $(POD2MAN) -s 8 $? > $@
 ../man/ovdb_init.8:	ovdb_init.pod		; $(POD2MAN) -s 8 $? > $@

Added: doc/pod/news2mail.pod
===================================================================
--- doc/pod/news2mail.pod	                        (rev 0)
+++ doc/pod/news2mail.pod	2008-11-30 12:37:18 UTC (rev 8198)
@@ -0,0 +1,73 @@
+=head1 NAME
+
+news2mail - Channel script to gateway news into e-mails
+
+=head1 SYNOPSIS
+
+B<news2mail>
+
+=head1 DESCRIPTION
+
+B<news2mail> runs as a channel process underneath B<innd>.  It is set
+up as channel feed in F<newsfeeds>, with different mailing-lists as funnel
+entries pointing to it (see below); B<news2mail> expects the token of an
+article followed by a sequence of list names.
+
+B<news2mail> uses the configuration file I<pathetc>/news2mail.cf to map
+mailing-list names to e-mail addresses.  B<news2mail> causes B<sendmail>
+to queue the messages for later delivery (to avoid DOS attacks by mass
+postings).  You must run C<sendmail -q> periodically to get the queue
+processed.
+
+=head1 CONFIGURATION FILE
+
+The configuration file format is simple:  comments (starting with a hash sign
+C<#>) and blank lines are ignored.  All other lines have two or three fields
+on them.  The first is the list name and is what B<innd> uses (i.e. the site
+field of the entry in the F<newsfeeds> file).  The second field is the
+actual e-mail address to send the article to.  The third field is optional:
+it sets the envelope-from address (for instance a list member's address;
+if not set, it defaults to the C<news> user).
+
+In e-mail messages, the To: header will have the mailing-list address
+(i.e. the second field).  Besides, B<news2mail> strips most article headers
+from the article before mailing.
+
+In F<newsfeeds>, the channel feed should look like:
+
+    news2mail!:!*:Ac,Tc,Wn*:<pathbin>/news2mail
+
+and for each mailing-list, you only have to add to F<newsfeeds> an entry list
+like:
+
+    list-big-red-ants/lists.ucsd.edu:!*,rec.pets.red-ants:Ap,Tm:news2mail!
+
+Please note the use of C<Ap> and the exclusion of the list owner domain
+to protect the list from feeding back new arrivals from the list.
+The site name used in the F<newfeeds> entry for a mailing-list (above
+C<list-big-red-ants>) must be the same as the first field in an entry in
+F<news2mail.cf>.  For instance:
+
+    # Newsfeeds-name      List-to-address                 [List-sender-address]
+    list-big-red-ants     big-red-ants at lists.ucsd.edu     news+big-red-ants at local.news.server.org
+
+=head1 BUGS
+
+The B<news2mail> program is set up as a funneled channel in F<newsfeeds>,
+implying multiple matches should be handled as one S<- and> multiple matching
+funneled feeds will result in a single call to the script.  Therefore,
+since only one mail is sent, crossposts are not currently properly handled
+as for the envelope-from address (which then defaults to the C<news> user).
+
+=head1 HISTORY
+
+B<news2mail> was written by Brian Kantor in 1998.  This man page was written
+by James Brister and converted to POD by Julien Elie.
+
+$Id$
+
+=head1 SEE ALSO
+
+innd(8), newsfeeds(5).
+
+=cut


Property changes on: trunk/doc/pod/news2mail.pod
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Modified: samples/news2mail.cf
===================================================================
--- samples/news2mail.cf	2008-11-29 20:07:27 UTC (rev 8197)
+++ samples/news2mail.cf	2008-11-30 12:37:18 UTC (rev 8198)
@@ -1,20 +1,29 @@
-# Sample config file for news2mail. Format is:
-#
-#	mailing-list-name	address
-#
-#
-# In newsfeeds put an entry like:
-#
-#	n2m!:!*:Tc,Ac,Wn*:/usr/news/bin/news2mail
-# 
-# and for each mailing list have an entry list:
-#
-#	news-software at localhost.our.domain.com:rec.pets.redants.*:Tm:n2m!
-#
-# The site name used in the newfeeds entry for a mailing list (above 
-# ``news-software at localhost.our.domain.com'') must be the same as the first
-# field in an entry in this file. It is what is put into the ``To'' header of 
-# mailed messages.
-#
-#
-news-software at localhost.our.domain.com	news-software at real-host.somewhere.com
+##  $Id$
+##
+##  Sample news2mail configuration file.
+##
+##  Format is:
+##
+##      Newsfeeds-name      List-to-address      [List-sender-address]
+##
+##  Newsfeeds-name:       Name used in the newsfeeds file for the gateway feed
+##                        (required).
+##  List-to-address:      List address to send articles to (required).
+##  List-sender-address:  Envelope-from address to use (a list member's
+##                        address; optional).
+##
+##  In newsfeeds, put an entry like:
+##
+##      news2mail!:!*:Ac,Tc,Wn*:<pathbin>/news2mail
+## 
+##  and for each mailing-list, have an entry list like:
+##
+##      list-big-red-ants/lists.ucsd.edu:!*,rec.pets.red-ants:Ap,Tm:news2mail!
+##
+##  The site name used in the newfeeds entry for a mailing-list (above 
+##  "list-big-red-ants") must be the same as the first field in an entry in
+##  this file.
+##
+##  See the news2mail man page for more information.
+
+#list-big-red-ants	big-red-ants at lists.ucsd.edu	news+big-red-ants at local.news.server.org

Modified: samples/newsfeeds.in
===================================================================
--- samples/newsfeeds.in	2008-11-29 20:07:27 UTC (rev 8197)
+++ samples/newsfeeds.in	2008-11-30 12:37:18 UTC (rev 8198)
@@ -122,10 +122,12 @@
 
 # News to mail gateway.  Similar to innfeed, this uses a master feed and
 # then individual feeds for every separate address that news is being
-# gated to.  This sends all posts to rec.pets.redants.* to the address
-# news-software at example.com.
-#news2mail!:!*:Tc,Ac,Wn*:@bindir@/news2mail
-#news-software at example.com:rec.pets.redants.*:Tm:news2mail!
+# gated to.  This sends all posts to rec.pets.red-ants to the address
+# listed in @sysconfdir@/news2mail.cf for list-big-red-ants.
+# Posts from the domain list owner are excluded (path for that example:
+# lists.ucsd.edu).
+#news2mail!:!*:Ac,Tc,Wn*:@bindir@/news2mail
+#list-big-red-ants/lists.ucsd.edu:!*,rec.pets.red-ants:Ap,Tm:news2mail!
 
 # Capture all local postings (with a distribution of "foo" and no more
 # than two sites in the Path: header) using a local program (that doesn't




More information about the inn-committers mailing list