INN commit: branches/2.4 (doc/pod/pullnews.pod frontends/pullnews.in)

INN Commit Russ_Allbery at isc.org
Sat Apr 26 08:36:58 UTC 2008


    Date: Saturday, April 26, 2008 @ 01:36:58
  Author: iulius
Revision: 7796

Fix bugs in pullnews because of a lack of parenthesis.
Update its documentation for -x (and also add this feature).

Modified:
  branches/2.4/doc/pod/pullnews.pod
  branches/2.4/frontends/pullnews.in

-----------------------+
 doc/pod/pullnews.pod  |    8 +++++++-
 frontends/pullnews.in |   32 +++++++++++++++++++++++---------
 2 files changed, 30 insertions(+), 10 deletions(-)

Modified: doc/pod/pullnews.pod
===================================================================
--- doc/pod/pullnews.pod	2008-04-26 08:28:08 UTC (rev 7795)
+++ doc/pod/pullnews.pod	2008-04-26 08:36:58 UTC (rev 7796)
@@ -4,7 +4,7 @@
 
 =head1 SYNOPSIS
 
-B<pullnews> [B<-hq>] [B<-c> I<config>] [B<-g> I<groups>] [B<-p> I<port>]
+B<pullnews> [B<-hqx>] [B<-c> I<config>] [B<-g> I<groups>] [B<-p> I<port>]
 [B<-r> I<file>] [B<-s> I<to-server>] [<from-server> ...]
 
 =head1 REQUIREMENTS
@@ -72,6 +72,12 @@
 server running on localhost.  To connect to a different host, specify a
 server with the B<-s> flag.
 
+=item B<-x>
+
+If the B<-x> flag is used, an Xref: header is added to any article
+that lacks one.  It can be useful for instance if articles are fed
+to a news server which has I<xrefslave> set in F<inn.conf>.
+
 =back
 
 =head1 CONFIG FILE

Modified: frontends/pullnews.in
===================================================================
--- frontends/pullnews.in	2008-04-26 08:28:08 UTC (rev 7795)
+++ frontends/pullnews.in	2008-04-26 08:36:58 UTC (rev 7796)
@@ -80,7 +80,7 @@
 my $defaultHost = "localhost";
 
 $usage =~ s!.*/!!;
-$usage .= " [ -h -q -r file -g groups -c config -s host -p port ]
+$usage .= " [ -h -q -x -r file -g groups -c config -s host -p port ]
 
   -g groups	specifies a collection of groups to get. The value must be 
 		a single argument with commas between group names:
@@ -102,6 +102,8 @@
   -r file	instead of feeding to a server $0 will instead
 		create an rnews-compatible file.
 
+  -x 		insert an Xref header in any article that lacks one.
+
   -q 		$0 will normally be verbose about what it's doing. This 
 		option will make it quiet.
 
@@ -109,8 +111,8 @@
 ";
 
 
-use vars qw($opt_q $opt_r $opt_s $opt_c $opt_g $opt_p $opt_h);
-getopts("r:c:s:qg:p:h") || die $usage;
+use vars qw($opt_q $opt_r $opt_x $opt_s $opt_c $opt_g $opt_p $opt_h);
+getopts("r:c:s:qxg:p:h") || die $usage;
 
 die $usage if $opt_h;
 
@@ -137,15 +139,15 @@
 my %passwd = ();
 
 if ($rnews) {
-    open RNEWS, ">$rnews" || 
+    open(RNEWS, ">$rnews") || 
 	die "cant open rnews-format ouptut: $rnews: $!\n";
     if ($rnews eq "-") {
-	open LOG, ">/dev/null" || die "can\'t open /dev/null!: $!\n";
+	open(LOG, ">/dev/null") || die "can\'t open /dev/null!: $!\n";
     } else {
-	open LOG, ">&STDOUT" || die "can't dup stdout!: $!\n";
+	open(LOG, ">&STDOUT") || die "can't dup stdout!: $!\n";
     }
 }  else {
-    open LOG, ">&STDOUT" || die "can't dup stdout!: $!\n";
+    open(LOG, ">&STDOUT") || die "can't dup stdout!: $!\n";
 }
 
 my $oldfh = select ;
@@ -173,7 +175,7 @@
     print LOG "\n";
 }
 
-open FILE, "<$groupFile" || die "cant open group file $groupFile\n" ;
+open(FILE, "<$groupFile") || die "can't open group file $groupFile\n" ;
 while (<FILE>) {
     next if m!^\s*\#! || m!^\s*$! ;
 
@@ -334,7 +336,7 @@
 sub saveConfig {
     $SIG{INT} = $SIG{QUIT} = 'IGNORE';
 
-    open FILE,">$groupFile" || die "cant open $groupFile: $!\n" ;
+    open(FILE,">$groupFile") || die "can't open $groupFile: $!\n" ;
     my $server ;
     my $group ;
 
@@ -413,6 +415,7 @@
 	my $article = $fromServer->article($i) ;
 	if ($article) {
 	    my $msgid ;
+	    my $xref = 0;
 	    my $headers = 1;
 	    my $idx;
 
@@ -421,6 +424,10 @@
 		    $msgid = $1 ;
 		}
 
+		if ($opt_x && $article->[$idx] =~ m!^xref:!i) {
+		    $xref = 1;
+		}
+
 		# catch some of the more common problems with articles.
 		if ($article->[$idx] =~ m!^\s+\n$!) {
 		    $article->[$idx] = "\n";
@@ -435,6 +442,13 @@
 		next ;
 	    }
 	    
+	    # some old servers lack Xref: which bothers a downstream INN if
+	    # it has xrefslave set, so add one just before the blank line.
+	    if ($opt_x && !$xref) {
+		warn "No xref found in article, adding\n";
+		splice(@{$article}, $idx, 0, "Xref: $server $group: $i\n");
+	    }
+
 	    $pulled->{$server}->{$group}++;
 	    
 	    if ($rnews) {



More information about the inn-committers mailing list