🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #73509

Re: alt.* control

#73509
From: Miquel van Smoorenburg
Date: Sat, 08 Apr 2006 23:40
114 lines
4986 bytes
In article <87odzflmhk.fsf@windlord.stanford.edu>,
Russ Allbery  <rra@stanford.edu> wrote:
>Bruce Esquibel <bje@e4500.ripco.com> writes:
>> Maybe for the next inn release some consideration can be taken to add
>> that in (no moderation status changed for an already existing alt group)
>> or something similar.
>
>I'm not willing to change INN to work around alt.*'s broken newsgroup
>creation policies, but a different parameter in control.ctl that doesn't
>accept moderation changes probably isn't a bad idea.  I don't have time to
>work it out and implement it, though.

Here's something that is mostly untested, though I did install it
on one reader server. It introduces a new keyword "updategroup" for
control.ctl. The updategroup entry is matched if the control message
is a newgroup for a group that already exists. If there is no matching
updategroup entry but there is a newgroup entry in control.ctl then
that one will be used so that everything is nicely backwards compatible.

I put this in control.ctl:

updategroup:*:alt.*:drop

.. that should stop the change-a-groups-moderation-status attacks.

Comments ? Does it work ? :)

--- inn-2.4.1/control/controlchan.in.ORIG	2004-01-07 23:47:19.000000000 +0100
+++ inn-2.4.1/control/controlchan.in	2006-04-09 01:20:56.000000000 +0200
@@ -254,12 +254,54 @@
     return $cachedctl = [ reverse @ctllist ];
 }
 
+sub findaction {
+    my ($ctllist, $type, $newsgroup, $sender) = @_;
+    my ($action, $hier);
+
+    foreach (@$ctllist) {
+        my @ctlline = split /:/;
+        # 0: type  1: from@addr  2: group.*  3: action
+        if ($type =~ /$ctlline[0]/ and $sender =~ /$ctlline[1]/i and
+            ($type !~ /(?:new|rm)group/ or $newsgroup =~ /$ctlline[2]/)) {
+            $action = $ctlline[3];
+            $action =~ s/\^(.+)\$/$1/;
+            $action =~ s/\\//g;
+            $hier = $ctlline[2] if $type eq 'checkgroups';
+            last;
+        }
+    }
+
+    ($action, $hier);
+}
+
+# Does the group exist in the active file ?
+sub group_exists {
+    my $group = shift;
+    my $found = 0;
+    local *ACTIVE;
+
+    unless (open(ACTIVE, $inn::active)) {
+	logdie("cannot open active file $inn::active");
+    }
+
+    while (<ACTIVE>) {
+	next unless (/^([^:]+):/);
+	if ($group eq $1) {
+	    $found = 1;
+	    last;
+	}
+    }
+    close ACTIVE;
+
+    $found;
+}
+
+
 # Parse a control message's permissions.
 sub ctlperm {
     my ($type, $sender, $newsgroup, $token, $headers, $body) = @_;
 
-    my $action = 'drop';    # default
-    my ($logname, $hier);
+    my ($logname, $action, $hier);
 
     # newgroup and rmgroup require newsgroup names; check explicitly for that
     # here and return drop if the newsgroup is missing (to avoid a bunch of
@@ -271,18 +313,14 @@
     }
 
     my $ctllist = readctlfile();
-    foreach (@$ctllist) {
-        my @ctlline = split /:/;
-        # 0: type  1: from@addr  2: group.*  3: action
-        if ($type =~ /$ctlline[0]/ and $sender =~ /$ctlline[1]/i and
-            ($type !~ /(?:new|rm)group/ or $newsgroup =~ /$ctlline[2]/)) {
-            $action = $ctlline[3];
-            $action =~ s/\^(.+)\$/$1/;
-            $action =~ s/\\//g;
-            $hier = $ctlline[2] if $type eq 'checkgroups';
-            last;
-        }
+    if (lc $type eq 'newgroup' && group_exists($newsgroup)) {
+	($action, $hier) = findaction($ctllist, 'updategroup',
+						$newsgroup, $sender);
+    }
+    if (!defined($action)) {
+	($action, $hier) = findaction($ctllist, $type, $newsgroup, $sender);
     }
+    $action ||= 'drop';	    # default if not found.
 
     ($action, $logname) = split(/=/, $action);
 

Technical Details
Message-ID: <e19hlu$bst$1@news.cistron.nl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.stueberl.de!newsgate.cistron.nl!news.cistron.nl!not-for-mail
References: <dvuak1$6g5$1@e250.ripco.com> <Xns979C7CEDC8245VeebleFetzer@127.0.0.1> <e11dq8$dai$1@e250.ripco.com> <87odzflmhk.fsf@windlord.stanford.edu>

Show Full Headers
Complete Article Headers
Message-ID: <e19hlu$bst$1@news.cistron.nl>
Subject: Re: alt.* control
Date: Sat, 08 Apr 2006 23:40:46 +0000
From: "Miquel van Smoorenburg" <miquels@netscum.invalid>
References: <dvuak1$6g5$1@e250.ripco.com> <Xns979C7CEDC8245VeebleFetzer@127.0.0.1> <e11dq8$dai$1@e250.ripco.com> <87odzflmhk.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.stueberl.de!newsgate.cistron.nl!news.cistron.nl!not-for-mail
Newsgroups: news.software.nntp
Organization: Cistron
Lines: 114
NNTP-Posting-Host: n2o.xs4all.nl
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
X-Trace: ncc1701.cistron.net 1144539646 12189 194.109.0.112 (8 Apr 2006
X-Complaints-To: abuse@cistron.nl
NNTP-Posting-Date: Sat, 8 Apr 2006 23:40:46 +0000 (UTC)
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
Originator: mikevs@n2o.xs4all.nl (Miquel van Smoorenburg)