🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
31 messages
31 total messages Started by Aioe Mon, 04 May 2009 07:17
filter_nnrpd.pl (maybe a bug)
#80863
Author: Aioe
Date: Mon, 04 May 2009 07:17
45 lines
2103 bytes
1. With INN 2.5 and perl 5.10.0, a strange thing happens:

with the following filter_nnrpd.pl

sub filter_post()
{
        $modify_headers = 1;
        delete $hdr{'X-Trace'};
}

this is the result:

# telnet localhost 119
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
200 localhost InterNetNews server INN 2.4.5 ready
mode reader
200 localhost InterNetNews NNRP server INN 2.4.5 ready (posting ok).
post
340 Ok, recommended ID <gtm3v9$6ta$1@aioe-casa.aioe.org>
Newsgroups: local.test
From: a@b.c
Subject: test

amamam
as
..
441 aioe-casa.aioe.org 1241420592 7082 127.0.0.1 (4 May 2009 07:03:12 GMT)
quit
205 .
Connection closed by foreign host.

2. filter_nnrpd.pl should be able to detect which program is invoking it; 
some user is making confusion between filter_nnrpd.pl and filter_innd.pl and 
each script currently is *not* able to detect whether it is invoked by the 
/right/ program. At the same time - imho - pathfilter should be reorganized 
with separate directories for each program (like this:

/etc/news/filter/innd/filter_innd.pl
/etc/news/filter/nnrpd/filter_nnrpd.pl
...


Re: filter_nnrpd.pl (maybe a bug)
#80864
Author: Aioe
Date: Mon, 04 May 2009 07:21
55 lines
2457 bytes
Aioe wrote:

> 1. With INN 2.5 and perl 5.10.0, a strange thing happens:

with the following filter_nnrpd.pl:

sub filter_post()
{
        $modify_headers = 1;
        delete $hdr{'X-Trace'};
        return "";
}

this is the result (nnrpd doesn't cancel X-Trace (and only X-Trace)):

# telnet localhost 119
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
200 localhost InterNetNews server INN 2.4.5 ready
mode reader
200 localhost InterNetNews NNRP server INN 2.4.5 ready (posting ok).
post
340 Ok, recommended ID <gtm4s7$850$1@aioe-casa.aioe.org>
Newsgroups: local.test
From: a@b.c
Subject: test

amamam
as
..
240 Article posted <gtm4s7$850$1@aioe-casa.aioe.org>
group local.test
211 49 1 49 local.test
head 49
221 49 <gtm4s7$850$1@aioe-casa.aioe.org> head
Path: localhost!not-for-mail
From: a@b.c
Newsgroups: local.test
Subject: test
Date: Mon, 4 May 2009 07:18:48 +0000 (UTC)
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <gtm4s7$850$1@aioe-casa.aioe.org>
NNTP-Posting-Host: localhost.aioe.org
X-Trace: aioe-casa.aioe.org 1241421528 8352 127.0.0.1 (4 May 2009 07:18:48 
GMT)
X-Complaints-To: usenet@aioe-casa.aioe.org
NNTP-Posting-Date: Mon, 4 May 2009 07:18:48 +0000 (UTC)
..
quit
205 .
Connection closed by foreign host.

Re: filter_nnrpd.pl (maybe a bug)
#80868
Author: Kelb tal-Fenek
Date: Mon, 04 May 2009 07:47
21 lines
1146 bytes
Aioe wrote:
> Aioe wrote:
>
>> 1. With INN 2.5 and perl 5.10.0, a strange thing happens:
>
> with the following filter_nnrpd.pl:
>
> sub filter_post()
> {
>         $modify_headers = 1;
>         delete $hdr{'X-Trace'};
>         return "";
> }
>
> this is the result (nnrpd doesn't cancel X-Trace (and only X-Trace)):

Have you tried: 
 undef $hdr{'X-Trace'};
or
 $hdr{'X-Trace'} = "";
Re: filter_nnrpd.pl (maybe a bug)
#80888
Author: Aioe
Date: Mon, 04 May 2009 14:50
11 lines
1243 bytes
 wrote:

> Have you tried:
> undef $hdr{'X-Trace'};
> or
> $hdr{'X-Trace'} = "";

yes, of course
$hdr{'X-Trace'} = undef works but X-Trace in the *only* header that can't be 
deleted using 'delete'.
Re: filter_nnrpd.pl (maybe a bug)
#80881
Author: Julien ÉLIE
Date: Mon, 04 May 2009 18:58
52 lines
2830 bytes
Hi,

> 1. With INN 2.5 and perl 5.10.0, a strange thing happens:
>
> with the following filter_nnrpd.pl
>
> sub filter_post()
> {
>        $modify_headers = 1;
>        delete $hdr{'X-Trace'};
> }
>
> post
>
> 441 aioe-casa.aioe.org 1241420592 7082 127.0.0.1 (4 May 2009 07:03:12 GMT)

According to Perl documentation, delete() returns the value of the last
element deleted.  We are in scalar context here in filter_post(), which
expects a return value.

INN sends 441 followed by the reason of the reject.  Here, it is as
though you wrote:

    $result = delete $hdr{'X-Trace'};
    return $result;

In your case, $result contains
'aioe-casa.aioe.org 1241420592 7082 127.0.0.1 (4 May 2009 07:03:12 GMT)'.



> 2. filter_nnrpd.pl should be able to detect which program is invoking it;
> some user is making confusion between filter_nnrpd.pl and filter_innd.pl and
> each script currently is *not* able to detect whether it is invoked by the
> /right/ program. At the same time - imho - pathfilter should be reorganized
> with separate directories for each program (like this:
>
> /etc/news/filter/innd/filter_innd.pl
> /etc/news/filter/nnrpd/filter_nnrpd.pl
> ...

It is not filter_nnrpd.pl that detects the caller.  It is called by nnrpd.
Only nnrpd calls it.
I do not believe using <pathfilter>/innd/xxx and <pathfilter>/nnrpd/xxx
will help much...

-- 
Julien ÉLIE

« Mais pourquoi courent-ils si vite ? Pour gagner du temps ! Comme le temps,
  c'est de l'argent... plus ils courent vite, plus ils en gagnent. » (Raymond Devos) 
Re: filter_nnrpd.pl (maybe a bug)
#80882
Author: Julien ÉLIE
Date: Mon, 04 May 2009 19:07
39 lines
2294 bytes
Hi Aioe,

> $hdr{'X-Trace'} = undef works

as well as
  $hdr{'X-Trace'} = '';


> but X-Trace in the *only* header that can't be deleted using 'delete'.

No, there are other headers like X-Complaints-To, Keywords, Organization,
Path, Subject, etc.

nnrpd has a list of "known" headers.  They are treated separately
and delete is not enough to remove them.  In fact, nnrpd does not
see removed headers (delete $hdr{'X-Trace'} removes this entry from
%hdr whereas other operations like assigning it to '' or undefining it
keeps the entry in %hdr and therefore nnrpd can catch it).

I have just changed the documentation of Perl hooks to say how to
delete a header.

Incidentally, I have also fixed a bug when you do:

  $hdr{'In-Reply-To'} = '';
or
  $hdr{'In-Reply-To'} = undef;

It generated an *empty* header :

  In-Reply-To: \r\n

Now, it totally removes it.

-- 
Julien ÉLIE

« Timeo Danaos et dona ferentes. » (Laocoon de Virgile)
Re: filter_nnrpd.pl (maybe a bug)
#80883
Author: Aioe
Date: Mon, 04 May 2009 20:18
39 lines
2334 bytes
Julien ÉLIE wrote:

> According to Perl documentation, delete() returns the value of the last
> element deleted.  We are in scalar context here in filter_post(), which
> expects a return value.

it's clear now.

> It is not filter_nnrpd.pl that detects the caller.  It is called by nnrpd.
> Only nnrpd calls it.
> I do not believe using <pathfilter>/innd/xxx and <pathfilter>/nnrpd/xxx
> will help much...

there're people, beginners, that install postfilter instead of cleanfeed, 
cleanfeed instead of postfilter. This error is common because both scripts 
need to be linked with a file in pathetc, filter_nnrpd.pl and filter_innd.pl 
have got similar names and there're two other files in the same directory  
that starts with "nnrpd_".
Neither innd nor nnrpd currently detect this error and it's hard for a 
beginner to find it because the nnrpd or innd logs include only a generic 
failure. More directories (one per program) imho make the filters easier to 
use and help to avoid errors (at that point filenames will be much simpler 
(filter.pl, access.pl, auth.pl) and there will be a clear distinction among 
programs). btw it's only an idea.

Re: filter_nnrpd.pl (maybe a bug)
#80884
Author: Aioe
Date: Mon, 04 May 2009 20:21
17 lines
1767 bytes
Julien ÉLIE wrote:

> No, there are other headers like X-Complaints-To, Keywords, Organization,
> Path, Subject, etc.
> 
> nnrpd has a list of "known" headers.  They are treated separately
> and delete is not enough to remove them.  In fact, nnrpd does not
> see removed headers (delete $hdr{'X-Trace'} removes this entry from
> %hdr whereas other operations like assigning it to '' or undefining it
> keeps the entry in %hdr and therefore nnrpd can catch it).

this should be added inside the perl filter documentation or removed. It's a 
really strange behaviour under the perl programmer's point of view.
Re: filter_nnrpd.pl (maybe a bug)
#80885
Author: Julien ÉLIE
Date: Mon, 04 May 2009 21:07
28 lines
2509 bytes
Hi Paolo,

> there're people, beginners, that install postfilter instead of cleanfeed,
> cleanfeed instead of postfilter. This error is common because both scripts
> need to be linked with a file in pathetc, filter_nnrpd.pl and filter_innd.pl
> have got similar names and there're two other files in the same directory
> that starts with "nnrpd_".
> Neither innd nor nnrpd currently detect this error and it's hard for a
> beginner to find it because the nnrpd or innd logs include only a generic
> failure.

I understand your suggestion.  It implies a bit of reorganization (code,
samples, build, upgrade, doc [and also docs outside INN]).  Well, hmmm...
In case you want to solve the issue you report, why not define in postfilter
three dumb functions filter_art, filter_messageid and filter_mode which
return '' and which also write a more helpful message to syslog?

Another possibility would be to check whether these functions are defined
when filter_nnrpd.pl is loaded; nnrpd would then log something useful
in news.notice.  Same thing for innd.

Would it be fine?

-- 
Julien ÉLIE

« C'est la goutte d'eau qui fait déborder le vase et qui met le feu aux poudres. »
Re: filter_nnrpd.pl (maybe a bug)
#80901
Author: Aioe
Date: Tue, 05 May 2009 07:48
7 lines
1154 bytes
Julien ÉLIE wrote:

> Would it be fine?

yes, thank you :-)

Re: filter_nnrpd.pl (maybe a bug)
#80903
Author: Julien ÉLIE
Date: Tue, 05 May 2009 18:30
38 lines
2583 bytes
Hi Paolo,

> this should be added inside the perl filter documentation or removed. It's a
> really strange behaviour under the perl programmer's point of view.

Modified: hook-perl.pod
===================================================================
--- hook-perl.pod 2009-05-04 19:11:52 UTC (rev 8442)
+++ hook-perl.pod 2009-05-04 19:18:50 UTC (rev 8443)
@@ -336,6 +336,21 @@
 then be rejected by innd).  If $modify_headers is set, I<everything> in
 the %hdr hash is taken to be article headers and added to the article.

+To modify the contents of the Organization: header, you can use:
+
+  $hdr{'Organization'} = 'My new organization';
+  $modify_headers = 1;
+
+To delete the Organization: header, you can use:
+
+  $hdr{'Organization'} = undef;
+  $modify_headers = 1;
+
+or:
+
+  $hdr{'Organization'} = '';
+  $modify_headers = 1;
+
 If filter_post() returns something other than the empty string, this
 message is normally returned to the client as an error.  There are three
 exceptions:

-- 
Julien ÉLIE

« Il y a des sciences bonnes dont l'existence est nécessaire
  et dont la culture est inutile. Telles sont les mathématiques. » (Joseph Joubert) 
Re: filter_nnrpd.pl (maybe a bug)
#80904
Author: Julien ÉLIE
Date: Tue, 05 May 2009 18:34
66 lines
4111 bytes
Hi Paolo,

>> Another possibility would be to check whether these functions are defined
>> when filter_nnrpd.pl is loaded; nnrpd would then log something useful
>> in news.notice.  Same thing for innd.
>>
>> Would it be fine?
>
> yes, thank you :-)

Index: lib/perl.c
===================================================================
--- lib/perl.c (révision 8431)
+++ lib/perl.c (copie de travail)
@@ -157,6 +157,21 @@
     } else {
         PERLreadfilter (filterfile,function) ;
     }
+
+    /* We try to find an inversion between filter_innd.pl
+     * and filter_nnrpd.pl. */
+    if (function != NULL) {
+        if ((strncmp(function, "filter_art", 10) == 0)
+            && (perl_get_cv("filter_post", false) != NULL)) {
+            syslog(L_NOTICE, "filter_innd.pl defines a filter_post function"
+                             " -- maybe a confusion with filter_nnrpd.pl?");
+        }
+        if ((strncmp(function, "filter_post", 11) == 0)
+            && (perl_get_cv("filter_art", false) != NULL)) {
+            syslog(L_NOTICE, "filter_nnrpd.pl defines a filter_art function"
+                             " -- maybe a confusion with filter_innd.pl?");
+        }
+    }
 }



I hope it will help your users of postfilter.
Extract from my logs:

May  5 20:31:04 news innd: controlchan! spawned controlchan!:21:proc:10235
May  5 20:31:04 news innfeed[10236]: ME starting at Tue May 05 20:31:04 2009  (INN 2.5.0 (20090505 prerelease))
May  5 20:31:04 news innfeed[10236]: loading /home/news/etc/innfeed.conf
May  5 20:31:04 news innd: innfeed! spawned innfeed!:22:proc:10236
May  5 20:31:04 news innd: news.litech.org opened news.litech.org:20:file
May  5 20:31:04 news innd: inpaths! spawned inpaths!:24:proc:10237
May  5 20:31:04 news innd: source-archive! spawned source-archive!:25:proc:10238
May  5 20:31:04 news innd: nocem! spawned nocem!:26:proc:10239
May  5 20:31:04 news innd: filter: Restored EMP database.
May  5 20:31:04 news innd: filter_innd.pl defines a filter_post function -- maybe a confusion with filter_nnrpd.pl?
May  5 20:31:04 news innd: SERVER perl filtering enabled
May  5 20:31:05 news innd: python: First load, so I can do initialization stuff.
May  5 20:31:05 news innd: python: spamfilter successfully hooked into INN
May  5 20:31:05 news innd: SERVER Python filtering enabled
May  5 20:31:05 news innd: python method filter_mode not found
May  5 20:31:05 news innd: defined python methods
May  5 20:31:05 news innd: python interpreter initialized OK
May  5 20:31:05 news innd: SERVER starting

-- 
Julien ÉLIE

« -- Vite, vous deux ! Allez ouvrir les portes !
  -- D'accord chef !
  -- Tenez bien le bouclier chef ! » (Astérix) 
Re: filter_nnrpd.pl (maybe a bug)
#80905
Author: Aioe
Date: Tue, 05 May 2009 20:26
7 lines
1247 bytes
Julien ÉLIE wrote:

> I hope it will help your users of postfilter.

thank you very much :-)

Re: filter_nnrpd.pl (maybe a bug)
#80906
Author: Aioe
Date: Tue, 05 May 2009 20:28
10 lines
1457 bytes
Julien ÉLIE wrote:

> +  $hdr{'Organization'} = undef;

a list of all articles that can't be deleted through 
'delete $hdr{'somewhat'}' seems to be missing?

can i help you in some way?
if i can contribute in some way, i'm happy to help inn developers.
Re: filter_nnrpd.pl (maybe a bug)
#80907
Author: Julien ÉLIE
Date: Tue, 05 May 2009 20:52
86 lines
5269 bytes
Hi Paolo,

>> + $hdr{'Organization'} = undef;
>
> a list of all articles that can't be deleted through
> 'delete $hdr{'somewhat'}' seems to be missing?

Yeah, that's why I only mentioned:

  To delete the Organization: header, you can use:

    $hdr{'Organization'} = undef;
    $modify_headers = 1;

  or:

    $hdr{'Organization'} = '';
    $modify_headers = 1;

:)


delete $hdr{'Organization'} could be made to work.  It would require
to parse all headers in an n² algorithm (for each initial "C struct" header,
check whether a "Perl hash" header exists -- if not, remove the "C struct"
corresponding header).
I don't know if it's worthwhile doing.


> can i help you in some way?

I wonder whether we should really give the list.  It is more
confusing than anything...

The list is at the beginning of nnrpd/post.c:

HEADER Table[] = {
    /*  Name                    CanSet  Type    Size  Value */
    {   "Path",                 true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "From",                 true,   HTreq,  0,    NULL,    NULL, 0 },
    {   "Newsgroups",           true,   HTreq,  0,    NULL,    NULL, 0 },
    {   "Subject",              true,   HTreq,  0,    NULL,    NULL, 0 },
    {   "Control",              true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Supersedes",           true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Followup-To",          true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Date",                 true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Organization",         true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Lines",                true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Sender",               true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Approved",             true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Distribution",         true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Expires",              true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Message-ID",           true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "References",           true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Reply-To",             true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "NNTP-Posting-Host",    false,  HTstd,  0,    NULL,    NULL, 0 },
    {   "Mime-Version",         true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Content-Type",         true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Content-Transfer-Encoding", true, HTstd,  0,    NULL,    NULL, 0 },
    {   "X-Trace",              false,  HTstd,  0,    NULL,    NULL, 0 },
    {   "X-Complaints-To",      false,  HTstd,  0,    NULL,    NULL, 0 },
    {   "NNTP-Posting-Date",    false,  HTstd,  0,    NULL,    NULL, 0 },
    {   "Xref",                 false,  HTstd,  0,    NULL,    NULL, 0 },
    {   "Injector-Info",        false,  HTstd,  0,    NULL,    NULL, 0 },
    {   "Summary",              true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Keywords",             true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Date-Received",        false,  HTobs,  0,    NULL,    NULL, 0 },
    {   "Received",             false,  HTobs,  0,    NULL,    NULL, 0 },
    {   "Posted",               false,  HTobs,  0,    NULL,    NULL, 0 },
    {   "Posting-Version",      false,  HTobs,  0,    NULL,    NULL, 0 },
    {   "Relay-Version",        false,  HTobs,  0,    NULL,    NULL, 0 },
    {   "Cc",                   true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "Bcc",                  true,   HTstd,  0,    NULL,    NULL, 0 },
    {   "To",                   true,   HTstd,  0,    NULL,    NULL, 0 },
};




That's why I was surprised to read that only X-Trace: was not deletable :)

-- 
Julien ÉLIE

« Quand tu auras lu ces lignes, le papyrus s'autodétruira. » (Astérix) 
Re: filter_nnrpd.pl (maybe a bug)
#80914
Author: Aioe
Date: Wed, 06 May 2009 13:52
15 lines
1630 bytes
Julien ÉLIE wrote:

> I wonder whether we should really give the list.  It is more
> confusing than anything...

you could simply write in the documentation somewhat like:

"do not use 'delete $hdr{'somewhat'}' in order to delete an header, this may 
work with some header, don't work with the others."

btw postfilter will be updated asap

it's faster.
Re: filter_nnrpd.pl (maybe a bug)
#80916
Author: Julien ÉLIE
Date: Wed, 06 May 2009 17:54
23 lines
1988 bytes
Hi Paolo,

>> I wonder whether we should really give the list. It is more
>> confusing than anything...
>
> you could simply write in the documentation somewhat like:
>
> "do not use 'delete $hdr{'somewhat'}' in order to delete an header, this may
> work with some header, don't work with the others."

Adopted.


> btw postfilter will be updated asap
> it's faster.

Thanks :)

-- 
Julien ÉLIE

« Non qui parum habet, sed qui plus cupit, pauper est. » (Senèque) 
Re: filter_nnrpd.pl (maybe a bug)
#80921
Author: Aioe
Date: Wed, 06 May 2009 20:51
32 lines
2096 bytes
Julien ÉLIE wrote:

> Thanks :)

:-)

BTW, http://www.eyrie.org/~eagle/software/inn/docs/hook-perl.html seems 
outdated in the last section:

>   Cleanfeed               Jeremy Nixon <jeremy@exit109.com>
>   <URL:http://www.mixmin.net/cleanfeed/> (maintained by Steve Crook)
>   
>   <URL:http://www.bofh.it/~md/cleanfeed/> 
>   <URL:http://www.exit109.com/~jeremy/news/cleanfeed.html> 

these  links should be removed since they are too old (imho)

>   News Gizmo              Aidan Cully <aidan@panix.com>
>   <URL:http://www.panix.com/gizmo/>

two answers:
1. are you sure that gizmo still works? It was an old program when i was 
young :-) 
2. assuming that it works, which is the *current* use of an USENET II filter?

could postfilter be added?
 

Re: filter_nnrpd.pl (maybe a bug)
#80922
Author: Julien ÉLIE
Date: Wed, 06 May 2009 21:19
52 lines
3143 bytes
Hi Paolo,

>   Cleanfeed               Jeremy Nixon <jeremy@exit109.com>
>   <URL:http://www.mixmin.net/cleanfeed/> (maintained by Steve Crook)
>
>   <URL:http://www.bofh.it/~md/cleanfeed/>
>   <URL:http://www.exit109.com/~jeremy/news/cleanfeed.html>
>
> these  links should be removed since they are too old (imho)

It is true that Steve's version is now far better than the legacy
one Marco used to maintain.


> could postfilter be added?

Of course!
Could you please provide a description?  (Otherwise, I will take
the one in the summary section of your INSTALL file.)



I changed the section to:

=over 4

=item Cleanfeed

URL:  L<http://www.mixmin.net/cleanfeed/> (maintained by Steve Crook)
URL:  L<http://www.bofh.it/~md/cleanfeed/> (previous version by Marco d'Itri)

Cleanfeed is an extremely powerful spam filter, probably the most widely
used spam filter on Usenet currently.  It catches excessive multiposting
and a host of other things, and is highly configurable.  It uses
F<filter_innd.pl> exclusively and requires the MD5 Perl module.

=item News Gizmo

URL:  L<URL:http://www.panix.com/gizmo/> (by Aidan Cully)

A posting filter for helping a site enforce Usenet-II soundness,
and for quotaing the number of messages any user can post to
Usenet daily.  It uses F<filter_nnrpd.pl>.

=back

-- 
Julien ÉLIE

« Le vrai danger, ce n'est pas quand les ordinateurs penseront comme les hommes,
  c'est quand les hommes penseront comme les ordinateurs. » 
Re: filter_nnrpd.pl (maybe a bug)
#80929
Author: Aioe
Date: Thu, 07 May 2009 21:27
60 lines
2831 bytes
Julien ÉLIE wrote:

> Of course!
> Could you please provide a description?  (Otherwise, I will take
> the one in the summary section of your INSTALL file.)

About postfilter you could use:

Postfilter is an NNRPD perl filter (filter_nnrpd.pl) which scans all 
messages sent by local users in order to block abuses. Postfilter can limit 
the number of messages per user, IP or domain, provides a set of powerful 
banlists, supports RBLs and URIBls, can handle connections that come from 
TOR and is able to deeply modify the headers. It's designed for large site.

use http://code.google.com/p/postfilter/ as url.


Another strange thing with filter_nnrpd.pl

with:

sub filter_post()
{
        $modify_headers = 1;
        $hdr{'X-Newsreader'} = undef;
        return "";
}

$ telnet localhost 119
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
200 localhost InterNetNews server INN 2.4.5 ready
mode reader
200 localhost InterNetNews NNRP server INN 2.4.5 ready (posting ok).
post
340 Ok, recommended ID <gtvjc4$841$1@aioe-casa.aioe.org>
Newsgroups: local.test
X-Newsreader: pppp    
From: a@b.c
Subject: test

ammama
aanb
..
441 437 Body of header is all blanks in "X-Newsreader" header
quit
205 .


Same thing happens with X-Mailer and *User-Agent* 
This makes impossible to hide the user agent (which could reveal local 
vulnerabilities)
Re: filter_nnrpd.pl (maybe a bug)
#80930
Author: Aioe
Date: Thu, 07 May 2009 21:28
6 lines
1409 bytes
Aioe wrote:

> It's designed for large site.

'sites' is probably better...
Re: filter_nnrpd.pl (maybe a bug)
#80931
Author: Julien ÉLIE
Date: Thu, 07 May 2009 22:02
39 lines
2893 bytes
Hi Paolo,

> About postfilter you could use:
>
> Postfilter is an NNRPD perl filter (filter_nnrpd.pl) which scans all
> messages sent by local users in order to block abuses. Postfilter can limit
> the number of messages per user, IP or domain, provides a set of powerful
> banlists, supports RBLs and URIBls, can handle connections that come from
> TOR and is able to deeply modify the headers. It's designed for large sites.

OK, thanks.


> $hdr{'X-Newsreader'} = undef;
>
> 200 localhost InterNetNews server INN 2.4.5 ready
> 441 437 Body of header is all blanks in "X-Newsreader" header
>
> This makes impossible to hide the user agent (which could reveal local
> vulnerabilities)

Oh, that will be difficult to handle in Postfilter...

INN 2.4.x does not accept empty headers and only "delete" will work
(but *not* on all headers!).  "undef" does not delete the header but
empties it for INN 2.4.x...

With INN 2.5.0, "undef" works pretty fine...

Sorry, I do not know how you will manage to do it (you could try to
get INN's version with innshellvars/INN::Config).
Annoying to have that INN 2.4.x bug with "undef" :-/

-- 
Julien ÉLIE

« The best preparation for tomorrow is to do
  today's work superbly well. » (William Osler) 
Re: filter_nnrpd.pl (maybe a bug)
#80935
Author: Aioe
Date: Fri, 08 May 2009 13:56
45 lines
2518 bytes
Julien ÉLIE wrote:

> INN 2.4.x does not accept empty headers and only "delete" will work
> (but not on all headers!).  "undef" does not delete the header but
> empties it for INN 2.4.x...

i'm not sure to have understood.

if $system_headers = "Path|From|Newsgroups|Subject|Control|Supersedes|
Followup\-To|Date|Organization|Lines|Sender|Approved|Distribution|Expires|
Message\-ID|References|Reply\-To|NNTP\-Posting\-Host|Mime\-Version|Content\-
Type|Content\-Transfer\-Encoding|X\-Trace|X\-Complaints\-To|NNTP\-Posting\-
Date|Xref|Injector\-Info|Summary|Keywords|Date\-Received|Received|Posted|
Posting\-Version|Relay\-Version|Bcc";

and

$user_agents = "X\-Newsreader|X\-Mailer|User\-Agent"; 



		2.4	2.5

$system_headers	undef	undef

$user_agents	delete	undef
			(delete?)

In-Reply-To		delete	undef

$all_others		delete	(delete?)
		undef	(undef)


is this right?

postfilter is able to detect which inn version is running so it's simple to 
write the code but i prefer to be sure before starting.
Re: filter_nnrpd.pl (maybe a bug)
#80937
Author: Julien ÉLIE
Date: Fri, 08 May 2009 21:30
71 lines
4010 bytes
Hi Paolo,

> $user_agents = "X\-Newsreader|X\-Mailer|User\-Agent";
>
> $system_headers = "Path|From|Newsgroups|Subject|Control|Supersedes|
> Followup\-To|Date|Organization|Lines|Sender|Approved|Distribution|Expires|
> Message\-ID|References|Reply\-To|NNTP\-Posting\-Host|Mime\-Version|Content\-
> Type|Content\-Transfer\-Encoding|X\-Trace|X\-Complaints\-To|NNTP\-Posting\-
> Date|Xref|Injector\-Info|Summary|Keywords|Date\-Received|Received|Posted|
> Posting\-Version|Relay\-Version|Bcc";

There are also To: and Cc:.


> 2.4 2.5
>
> $system_headers undef undef
>
> $user_agents delete undef
> (delete?)
>
> In-Reply-To delete undef
>
> $all_others delete (delete?)
> undef (undef)

undef works fine for everything with INN 2.5.
As for $user_agents, yes, delete will work with INN 2.5 but it is wiser
to use undef too.

In <http://www.eyrie.org/~eagle/software/inn/docs/hook-perl.html> (where the
link to Postfilter has been added), there is the list of headers recognized
by *innd* Perl filter (not the same as nnrpd...).  If, with INN *2.4*,
you undef them, they end up empty but not removed by nnrpd and innd rejects
the article as you already experienced it.
And if, with INN *2.4*, you delete them, then it works if they are *not*
in $system_headers (nnrpd); otherwise, they are not deleted as you saw
(initial subject of your thread)...


> is this right?

I hope my explanation were cleaner.
For X-Trace:, I do not see how to remove it with INN 2.4 (delete will
not work, and undef will empty it and it will be rejected by innd).
For User-Agent:, delete will normally work with INN 2.4, unless I am mistaken.

A suggestion I have is:
 * undef with INN 2.5;
 * set to "-" with INN 2.4.

I believe it will work.  Sorry for the fact it is not always possible
to remove a header with INN 2.4 :-/


> postfilter is able to detect which inn version is running so it's simple to
> write the code but i prefer to be sure before starting.

I assume you use something like:

% innconfval version
INN 2.5.0 (20090505 prerelease)

Do not forget INN 2.6.0 (and later) because when INN 2.5.0 is released,
INN 2.6.0 will be the new CURRENT version.

-- 
Julien ÉLIE

« Le style est l'homme même. » (Buffon) 
Re: filter_nnrpd.pl (maybe a bug)
#80950
Author: Aioe
Date: Sat, 09 May 2009 07:44
49 lines
2711 bytes
Julien ÉLIE wrote:

> There are also To: and Cc:.

added

> undef works fine for everything with INN 2.5.

it's clear. With INN 2.5 headers should be deleted using undef.

>  If, with INN *2.4*,
> you undef them, they end up empty but not removed by nnrpd and innd
> rejects the article as you already experienced it.

with inn 2.4:

user agents ($user_agents) *can* be deleted through 'delete' (i've made a 
test now with 2.4.5, 2.4.4 and 2.4.1).

> For X-Trace:, I do not see how to remove it with INN 2.4 (delete will
> not work, and undef will empty it and it will be rejected by innd).

with inn 2.4 system headers *can* be deleted using undef. Postfilter already 
does this and it works (and i've made a test before writing here)

> I believe it will work.  Sorry for the fact it is not always possible
> to remove a header with INN 2.4 :-/

are you sure?
Almost all headers can be removed (even if obviously innd rejects all 
articles that miss some needed header)

> % innconfval version
> INN 2.5.0 (20090505 prerelease)

yep
 
> Do not forget INN 2.6.0 (and later) because when INN 2.5.0 is released,
> INN 2.6.0 will be the new CURRENT version.


thank you :-)
Re: filter_nnrpd.pl (maybe a bug)
#80951
Author: Julien ÉLIE
Date: Sat, 09 May 2009 09:11
55 lines
3605 bytes
Hi Paolo,

> it's clear. With INN 2.5 headers should be deleted using undef.

Yes.


>> If, with INN *2.4*,
>> you undef them, they end up empty but not removed by nnrpd and innd
>> rejects the article as you already experienced it.
>
> with inn 2.4:
>
> user agents ($user_agents) *can* be deleted through 'delete' (i've made a
> test now with 2.4.5, 2.4.4 and 2.4.1).

Yes, it is what I wrote just after:
  And if, with INN *2.4*, you delete them, then it works if they are *not*
  in $system_headers (nnrpd); otherwise, they are not deleted as you saw
  (initial subject of your thread)...

$user_agents are not in $system_headers, so it works with 'delete'.


>> For X-Trace:, I do not see how to remove it with INN 2.4 (delete will
>> not work, and undef will empty it and it will be rejected by innd).
>
> with inn 2.4 system headers *can* be deleted using undef. Postfilter already
> does this and it works (and i've made a test before writing here)

Oh, yes, you're right.  It does not work with 'delete' for INN 2.4 system
headers but 'undef' will work.  (if (hp->Len == 0) hp->Value = hp->Body = NULL;
in the source.  I had overlooked that!)

For INN 2.4, 'undef' will not work for $user_agents (as seen above).


>> I believe it will work.  Sorry for the fact it is not always possible
>> to remove a header with INN 2.4 :-/
>
> are you sure?
> Almost all headers can be removed (even if obviously innd rejects all
> articles that miss some needed header)

Hmm...  Then 'undef' system headers and 'delete' everything else (including
$user_agents).  It will work for both INN 2.4 and INN 2.5.
Maybe the simplest thing to do, isn't it?  No need to separate your code
depending on the version of INN.

-- 
Julien ÉLIE

« Le travail est l'opium du peuple et
  je ne veux pas mourir drogué. » (Boris Vian) 
Re: filter_nnrpd.pl (maybe a bug)
#80952
Author: Aioe
Date: Sat, 09 May 2009 11:46
22 lines
2176 bytes
Julien ÉLIE wrote:

> Hmm...  Then 'undef' system headers and 'delete' everything else
> (including $user_agents).  It will work for both INN 2.4 and INN 2.5.
> Maybe the simplest thing to do, isn't it?  No need to separate your code
> depending on the version of INN.

i don't care about inn version since postfilter is able to detect it. I only 
need to be sure about the effect of each perl statement because the code is 
old (i'm rewriting it now), headers are many and a fully debug is expansive.

btw see 
http://code.google.com/p/postfilter/source/browse/trunk/doc/how_to_delete_headers.txt


Re: filter_nnrpd.pl (maybe a bug)
#80954
Author: Julien ÉLIE
Date: Sat, 09 May 2009 12:46
97 lines
5354 bytes
Hi Paolo,

> i don't care about inn version since postfilter is able to detect it. I only
> need to be sure about the effect of each perl statement because the code is
> old (i'm rewriting it now), headers are many and a fully debug is expansive.

OK, thanks for your work.


> btw see
> http://code.google.com/p/postfilter/source/browse/trunk/doc/how_to_delete_headers.txt

Oh, I see there was some misunderstanding.
When I wrote:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Incidentally, I have also fixed a bug when you do:

  $hdr{'In-Reply-To'} = '';
or
  $hdr{'In-Reply-To'} = undef;

It generated an *empty* header :

  In-Reply-To: \r\n

Now, it totally removes it.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

It was an example I used.  The problem was generic and not linked
with this specific In-Reply-To: header.  Sorry for the misunderstanding.

I only implemented what USEFOR (and also RFC 3977) states:  no empty headers.

And that's why 'undef' now works fine everywhere with INN 2.5.  (Otherwise,
only 'delete' would have worked for all other headers, like in INN 2.4.)


|-------------------------------------------------------------|
|                      NNRPD Version Table                    |
|---|-----------------------|---------------|-----------------|
| # |      Headers          |    INN 2.4    |    INN 2.5      |
|---|-----------------------|---------------|-----------------|
| A | $system_headers       |     undef     |     undef       |
|---|-----------------------|---------------|-----------------|
| B | $user_agents          |    delete     |     undef       |
|---|-----------------------|---------------|-----------------|
| C | $bugged               |    delete     |     undef       |
|---|-----------------------|---------------|-----------------|
| D | All other headers     |    delete     | delete or undef |
|---|-----------------------|---------------|-----------------|

C (In-Reply-To:) and D should be handled the same way.

For B, delete or undef work for INN 2.5.  I do not understand why
you handle $user_agents separately.  Maybe because Postfilter
handles them in a different way?

In fact, it is $system_headers (undef/undef) and all other headers
(delete/delete or undef).



Typo in your doc:  "detete" -> "delete".


> Beware: with inn 2.4, if the perl filter tries to delete an $user_agent
> header using delete the article will be *rejected* by innd because instead
> of deleting that header nnrpd cleans its content and innd doesn't accept
> empty headers.

??  Is it really what INN 2.4 does?  (You have put 'delete' in your table.)
And INN 2.5 allows 'delete' -> it is totally removed.
Do you have an example of reject here?


> Beware: with inn 2.4, every attempt to delete one of $system_headers through
> 'delete' will silently discarded by nnrpd. Simply the 'delete' command will
> have no effects without any kind of log notice.

Also with INN 2.5.


> Beware: some header (notably From, Newsgroups, Subject, Xref, Path, Lines
> and Message-ID) can't be deleted. If the perl filter tries to delete one of them,
> the article is rejected by innd because some mandatory header is missing.

??
Are you really sure Lines: and Xref: cannot be deleted?  It surprises me.
I think Date: cannot be deleted.

-- 
Julien ÉLIE

« J'ai six loyaux serviteurs, ils m'ont appris tout ce que je sais :
  ils s'appellent quoi, pourquoi, quand, comment, où et qui. » (Rudyard Kipling) 
Re: filter_nnrpd.pl (maybe a bug)
#80955
Author: Aioe
Date: Sat, 09 May 2009 13:48
76 lines
3587 bytes
Julien ÉLIE wrote:

> It was an example I used.  The problem was generic and not linked
> with this specific In-Reply-To: header.  Sorry for the misunderstanding.

ok
it was unclear for me, now it's clear :-)

> C (In-Reply-To:) and D should be handled the same way.

ok
 
> For B, delete or undef work for INN 2.5.  I do not understand why
> you handle $user_agents separately.  

they don't work in the same way with INN 2.4. INN 2.4 *rejects* the article 
if an $user_agent header is deleted through *undef* because nnrpd clears its 
content without deleting it (see news://gtvjpa$ptt$1@aioe.org ).
So $user_agents *must* be deleted through 'delete' with inn 2.4. 

> Typo in your doc:  "detete" -> "delete".

fixed, thank you
 
> 
>> Beware: with inn 2.4, if the perl filter tries to delete an $user_agent
>> header using delete the article will be *rejected* by innd because
>> instead of deleting that header nnrpd cleans its content and innd doesn't
>> accept empty headers.
> 
> ??  

s/delete/undef/
it's a stupid and hard to detect error, again thank you.


>> Beware: with inn 2.4, every attempt to delete one of $system_headers
>> through 'delete' will silently discarded by nnrpd. Simply the 'delete'
>> command will have no effects without any kind of log notice.
> 
> Also with INN 2.5.

added, thank you

>> Beware: some header (notably From, Newsgroups, Subject, Xref, Path, Lines
>> and Message-ID) can't be deleted. If the perl filter tries to delete one
>> of them, the article is rejected by innd because some mandatory header is
>> missing.
> 
> ??
> Are you really sure Lines: and Xref: cannot be deleted?

i've checked now, they're deletable. 
do you know a full list of all mandatory headers? (those that are needed by 
innd)

thank you very much, if i can, i'm happy to repay you :-)



> It surprises me.
> I think Date: cannot be deleted.
> 

Re: filter_nnrpd.pl (maybe a bug)
#80956
Author: Aioe
Date: Sat, 09 May 2009 13:52
12 lines
2243 bytes
Aioe wrote:

> they don't work in the same way with INN 2.4. INN 2.4 rejects the article
> if an $user_agent header is deleted through undef because nnrpd clears its
> content without deleting it (see news://gtvjpa$ptt$1@aioe.org ).
> So $user_agents must be deleted through 'delete' with inn 2.4.

... with inn 2.5 all headers can be deleted through undef so the logical flow 
is simpler if postfilter detects the current inn version then (a) always 
deletes through 'undef' if version is 2.5, or (b) deletes through 'undef' 
all system headers and through 'delete' all others.
Re: filter_nnrpd.pl (maybe a bug)
#80957
Author: Julien ÉLIE
Date: Sat, 09 May 2009 17:07
34 lines
3063 bytes
Hi Paolo,

>> For B, delete or undef work for INN 2.5.  I do not understand why
>> you handle $user_agents separately.
>
> they don't work in the same way with INN 2.4. INN 2.4 *rejects* the article
> if an $user_agent header is deleted through *undef* because nnrpd clears its
> content without deleting it (see news://gtvjpa$ptt$1@aioe.org ).
> So $user_agents *must* be deleted through 'delete' with inn 2.4.

Yes, with INN 2.4, you have to use delete.  But with INN 2.5, both delete
and undef work so that's why I wonder why you still separate $user_agents
from all other headers.  (Your new B and your new C.)


> i've checked now, they're deletable.
> do you know a full list of all mandatory headers? (those that are needed by
> innd)

Yes of course, and they are the six you have put (From, Newsgroups, Subject,
Path, Date and Message-ID).

They are the official mandatory header fields per RFC:

    http://www.eyrie.org/~eagle/usefor/drafts/draft-ietf-usefor-usefor-12.txt

(see section 3.1)

-- 
Julien ÉLIE

« Men have a better time than women; for one thing,
  they marry later; for another thing, they die earlier. » (H. L. Mencken) 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads