🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
23 messages
23 total messages Started by D. Stussy Sun, 22 Aug 2010 21:39
Please consider this INN patch for mailpost
#83387
Author: D. Stussy
Date: Sun, 22 Aug 2010 21:39
124 lines
5823 bytes
What this patch does and why:

1) Adds a "-z" parameter to remove any undesired headers from the gated
message.  It also forces removal of the "Bcc:" header.  Under SMTP, Bcc is
permitted to exist with a blank RHS, but NNTP forbids a blank RHS for any
header.  (Without this patch for "Bcc:", the script was promoting it to
"X-Bcc:" and leaving it in the article; a violation of the article format.)

2) Edits the incoming SMTP message's "Received:" header to remove any "for
<mailbox>" clause which contains the name of the news server (or its
domain).  It determines the name by examining "pathhost", "fromhost" and
"domain" (from file "inn.conf").  The reason for this is to protect the
gateway mailbox from spammers who may seek to abuse the gateway.  This will
also remove any "*-To:" headers that cite the news server host or domain
name (e.g. "Errors-To:" which are set to report back which user bounced by
using a mailbox pattern in the envelope).  As the gateway mailbox name is
now hidden, spammers will have to discover it via other means.  It's not
meant as an anti-spam measure by itself, but spammers can't spam that which
they can't find.  Since the administrator knows the message was gated, he
knows it was delivered to the gateway mailbox, so information deleted from
the trace header isn't "lost"; just merely hidden.  "For" clauses from
other "Received:" headers not specifying the mail server's host/domain are
left intact.

This diff is against INN 2.5.2:

diff -bur frontends/mailpost.in frontends/mailpost.in
--- frontends/mailpost.in       2010-03-24 20:10:36.000000000 +0000
+++ frontends/mailpost.in       2010-08-11 21:21:17.000000000 +0000
@@ -5,6 +5,7 @@
 #
 # $Id: mailpost.in 9025 2010-03-21 16:49:41Z iulius $
 #
+# 11aug10 [added -z for headers to zap; edit Received-for and *-To: for
gateway]
 # 21feb00 [added "lc" to duplicate header fixer stmt to make it
case-insensitive]
 # doka 11may99 [fixed duplicate headers problem]
 # brister 19oct98 [cleaned up somewhat for Perl v. 5. and made a little
more robust]
@@ -53,10 +54,10 @@

 $usage .= "[ -r addr ][ -f addr ][ -a approved ][ -d distribution ]" .
     " [ -m mailing-list ][ -b database ][ -o output-path ] [ -c
wait-time ]" .
-    " [ -x header[:header...] ] [ -p port ] newsgroups" ;
+    " [ -x header[:header...]] [ -z header[:header...]] [ -p port ]
newsgroups";

-use vars qw($opt_r $opt_f $opt_a $opt_d $opt_m $opt_b $opt_n $opt_o $opt_h
$opt_c $opt_x $opt_p) ;
-getopts("hr:f:a:d:m:b:no:c:x:p:") || die "usage: $usage\n" ;
+use vars qw($opt_r $opt_f $opt_a $opt_d $opt_m $opt_b $opt_n $opt_o $opt_h
$opt_c $opt_x $opt_p $opt_z) ;
+getopts("hr:f:a:d:m:b:no:c:x:p:z:") || die "usage: $usage\n" ;
 die "usage: $usage\n" if $opt_h ;

 #
@@ -70,6 +71,7 @@
 my $Maintainer = $INN::Config::newsmaster || "usenet" ;
 my $WhereTo = $opt_o || $Submit ;
 my $Mailname = $INN::Config::fromhost ;
+my $Gateway  = $INN::Config::fromhost ;

 # Can't use $INN::Config::pathtmp as we're usually not running as news.
 my $Tmpdir = "/var/tmp" ;
@@ -80,7 +82,8 @@
 }

 chop ($Mailname = `/bin/hostname`) if ! $Mailname ;
-
+$Gateway .= '|' . $INN::Config::pathhost if $INN::Config::pathhost;
+$Gateway .= '|(.+\.)?' . $INN::Config::domain if $INN::Config::domain;

 #
 # Our command-line argument(s) are the list of newsgroups to post to.
@@ -125,11 +128,16 @@
     $exclude .= '|' . join('|', split(/:/, $opt_x));
 }

+# Strip out blank Bcc: header since NNTP does not allow blank header data
+my $skip = 'Bcc';
+if ($opt_z) {
+    $skip .= '|' . join('|', split(/:/, $opt_z));
+}
+
 $newsgroups = join ",", @ARGV ;

 die "usage:  $0 newsgroup [newsgroup ...]\n" unless $newsgroups;

-
 #
 # Do the header.  Our input is a mail message, with or without the From.
 #
@@ -206,6 +214,7 @@

     push @errorText, "($_)\n";

+    next if (/^($skip):/sio);
     next if /^Approved:\s/sio && defined($approved);
     next if /^Distribution:\s/sio && defined($distribution);

@@ -289,6 +298,17 @@
         next ;
     }

+    # Strip out any Received: headers for clause to prevent spamming the
gateway
+    if (/^Received:\s*/sio) {
+       s/\s+for\s.+\@($Gateway)>?\s*//sio;
+       # FALLTHROUGH
+    }
+
+    # Strip out any headers with gateway mailbox to prevent spamming the
gateway
+    if (/^[A-Z]+-To:\s*/sio) {
+       next if /[@%=]($Gateway)/sio;
+    }
+
     # Random unknown header.  Prepend 'X-' if it is not already there.
     $_ = "X-$_" unless /^X-/sio ;
     $weird_mail_hdrs .= "$_\n";

Re: Please consider this INN patch for mailpost
#83460
Author: Julien ÉLIE
Date: Thu, 30 Sep 2010 17:31
121 lines
4822 bytes
Hi Dieter,

> 1) Adds a "-z" parameter to remove any undesired headers from the gated
> message.  It also forces removal of the "Bcc:" header.  Under SMTP, Bcc is
> permitted to exist with a blank RHS, but NNTP forbids a blank RHS for any
> header.  (Without this patch for "Bcc:", the script was promoting it to
> "X-Bcc:" and leaving it in the article; a violation of the article format.)

That's a nice idea, thanks!

Also OK for the second one about Received: and *-To: headers.



> @@ -80,7 +82,8 @@
> }
>
> chop ($Mailname = `/bin/hostname`) if ! $Mailname ;
> -
> +$Gateway .= '|' . $INN::Config::pathhost if $INN::Config::pathhost;
> +$Gateway .= '|(.+\.)?' . $INN::Config::domain if $INN::Config::domain;
>
> #
> # Our command-line argument(s) are the list of newsgroups to post to.

I would have added:

    chop ($Gateway = `/bin/hostname`) if ! $Gateway ;

the same way it is done for $Mailname.




I would also have changed:

-my $exclude = 'Organization|Distribution';
+my $exclude = 
'Archive|Archived-At|Comments|Distribution|Keywords|Organization|Summary';

and update the documentation as follows:
-- note that there was a mistake about the Approved: header.  It was not a known
header because it was renamed by default to "X-Approved".


@@ -629,7 +643,8 @@
 B<mailpost> [B<-hn>] [B<-a> I<addr>] [B<-b> I<database>] [B<-c> I<wait-time>]
 [B<-d> I<distribution>] [B<-f> I<addr>] [B<-m> I<mailing-list>]
 [B<-o> I<output-command>] [B<-p> I<port>] [B<-r> I<addr>]
-[B<-x> I<header>[B<:>I<header>...]] I<newsgroups>
+[B<-x> I<header>[B<:>I<header>...]] [B<-z> I<header>[B<:>I<header>...]]
+I<newsgroups>

 =head1 DESCRIPTION

@@ -638,12 +653,14 @@
 whitespace-separated list of group names to which to post the article
 (at least one newsgroup must be specified).

-Before feeding the article to B<inews>, it checks that the article has not
-been seen before, and it changes some headers (cleans up some address
-headers, removes X-Trace: and X-Complaints-To:, and puts C<X-> in front
-of unknown headers).
+Before feeding the article to B<inews>, it checks that the article has
+not been seen before, and it changes some headers (cleans up some address
+headers, removes a few ones, and puts C<X-> in front of unknown headers).
+The Received: and *-To: headers are also stripped out to prevent spamming
+the gateway (the name of the news server or the domain name from F<inn.conf>
+are removed).

 If the article has been seen before (B<mailpost> records the Message-ID of
 each article it handles), then the article will be dropped with a non-zero
@@ -730,19 +745,34 @@

 Known headers are:

-    Approved
+    Archive
+    Archived-At
+    Comments
     Content-*
     Date
     Distribution
     From
+    Keywords
     Mailing-List
     Message-ID
     MIME-*
+    Organization
     References
     Return-Path
     Sender
     Subject
+    Summary

+=item B<-z> I<header>[B<:>I<header>...]
+
+A colon-separated list of additional headers which should be removed.
+
+By default, removed headers are:
+
+    Bcc
+    X-Trace
+    X-Complaints-To
+
 =back

 =head1 FILES




Do these changes look good to you?

-- 
Julien ÉLIE

« Nos modernes Josué littéraires crient vainement à la langue de s'arrêter ;
  les langues ni le Soleil ne s'arrĂŞtent plus. Le jour oĂą elles se fixent,
  c'est qu'elles meurent. » (Victor Hugo, Préface de _Cromwell_) 
Re: Please consider this INN patch for mailpost
#83462
Author: D. Stussy
Date: Thu, 30 Sep 2010 20:41
158 lines
6638 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:i82hhu$74b$1@news.trigofacile.com...
> > 1) Adds a "-z" parameter to remove any undesired headers from the gated
> > message.  It also forces removal of the "Bcc:" header.  Under SMTP, Bcc
is
> > permitted to exist with a blank RHS, but NNTP forbids a blank RHS for
any
> > header.  (Without this patch for "Bcc:", the script was promoting it to
> > "X-Bcc:" and leaving it in the article; a violation of the article
format.)
>
> That's a nice idea, thanks!
>
> Also OK for the second one about Received: and *-To: headers.
>
>
>
> > @@ -80,7 +82,8 @@
> > }
> >
> > chop ($Mailname = `/bin/hostname`) if ! $Mailname ;
> > -
> > +$Gateway .= '|' . $INN::Config::pathhost if $INN::Config::pathhost;
> > +$Gateway .= '|(.+\.)?' . $INN::Config::domain if $INN::Config::domain;
> >
> > #
> > # Our command-line argument(s) are the list of newsgroups to post to.
>
> I would have added:
>
>     chop ($Gateway = `/bin/hostname`) if ! $Gateway ;
>
> the same way it is done for $Mailname.

I specifically left that out for one reason:  Virtual hosting.  The
/bin/hostname name may not be the same name as the news server, nor even
under the same domain name.  We could add another command line parameter to
exclude additional hostnames if necessary.

On my system, my news server is "news.snarked.org", but /bin/hostname
returns only "snarked.org" which has no DNS address-type records.  However,
while the script is running, the name from the TCP socket might be
"localhost" if it's using the loopback interface to connect between mail
and news.  The only certain exclusions were those names from the
"etc/inn.conf" file declarations.

> I would also have changed:
>
> -my $exclude = 'Organization|Distribution';
> +my $exclude =
>
'Archive|Archived-At|Comments|Distribution|Keywords|Organization|Summary';

I didn't do that because if the message was first gated from news to mail
and is being gated back (why, I don't know) for some reason, the message
may already have these headers present, and I saw no reason not to preserve
them.

> and update the documentation as follows:
> -- note that there was a mistake about the Approved: header.  It was not
a known
> header because it was renamed by default to "X-Approved".

I might have missed that too, or intentionally ignored that.  It's been 5
weeks since I posted the suggestion, so it's no longer fresh on my mind.

> @@ -629,7 +643,8 @@
>  B<mailpost> [B<-hn>] [B<-a> I<addr>] [B<-b> I<database>] [B<-c>
I<wait-time>]
>  [B<-d> I<distribution>] [B<-f> I<addr>] [B<-m> I<mailing-list>]
>  [B<-o> I<output-command>] [B<-p> I<port>] [B<-r> I<addr>]
> -[B<-x> I<header>[B<:>I<header>...]] I<newsgroups>
> +[B<-x> I<header>[B<:>I<header>...]] [B<-z> I<header>[B<:>I<header>...]]
> +I<newsgroups>
>
>  =head1 DESCRIPTION
>
> @@ -638,12 +653,14 @@
>  whitespace-separated list of group names to which to post the article
>  (at least one newsgroup must be specified).
>
> -Before feeding the article to B<inews>, it checks that the article has
not
> -been seen before, and it changes some headers (cleans up some address
> -headers, removes X-Trace: and X-Complaints-To:, and puts C<X-> in front
> -of unknown headers).
> +Before feeding the article to B<inews>, it checks that the article has
> +not been seen before, and it changes some headers (cleans up some
address
> +headers, removes a few ones, and puts C<X-> in front of unknown
headers).
> +The Received: and *-To: headers are also stripped out to prevent
spamming

Actually, the "Received" header is not stripped out, but it is altered to
delete the "FOR _mailbox_" clause (capitals=literal, underscore=variable,
which may or may not have surrounding "<>").  Only those "for" clauses
which contain a mailbox of a domain in "$Gateway" are altered.

Similarly with those "*-To:" headers - only those containing a substring
(domain) in "$Gateway" are stripped.  This is meant to target the
deprecated DSN-type headers like "Errors-To:", specific routing via "%"
(also deprecated but still supported by some MTAs), or SRS, where the
sending/rewritten/routing mailbox has the recipient domain as a substring
of the user component of the mailbox.

> +the gateway (the name of the news server or the domain name from
F<inn.conf>
> +are removed).
>
>  If the article has been seen before (B<mailpost> records the Message-ID
of
>  each article it handles), then the article will be dropped with a
non-zero
> @@ -730,19 +745,34 @@
>
>  Known headers are:
>
> -    Approved
> +    Archive
> +    Archived-At
> +    Comments
>      Content-*
>      Date
>      Distribution
>      From
> +    Keywords
>      Mailing-List
>      Message-ID
>      MIME-*
> +    Organization
>      References
>      Return-Path
>      Sender
>      Subject
> +    Summary
>
> +=item B<-z> I<header>[B<:>I<header>...]
> +
> +A colon-separated list of additional headers which should be removed.
> +
> +By default, removed headers are:
> +
> +    Bcc
> +    X-Trace
> +    X-Complaints-To
> +
>  =back
>
>  =head1 FILES

Same comment as above regarding news->mail->news gating.

> Do these changes look good to you?

See above.

Re: Please consider this INN patch for mailpost
#83463
Author: Julien ÉLIE
Date: Thu, 30 Sep 2010 21:03
84 lines
4004 bytes
Hi Dieter,

>> I would have added:
>>
>>     chop ($Gateway = `/bin/hostname`) if ! $Gateway ;
>>
>> the same way it is done for $Mailname.
>
> I specifically left that out for one reason:  Virtual hosting.  The
> /bin/hostname name may not be the same name as the news server, nor even
> under the same domain name.  We could add another command line parameter to
> exclude additional hostnames if necessary.

Then how would it harm if /bin/hostname was in the patterns to look for?


> However,
> while the script is running, the name from the TCP socket might be
> "localhost" if it's using the loopback interface to connect between mail
> and news.

It does not matter to have "localhost" left in Received: or *-To: headers.
No problem to not look for it, if I understand the aim of your patch.


>> I would also have changed:
>>
>> -my $exclude = 'Organization|Distribution';
>> +my $exclude =
>>
> 'Archive|Archived-At|Comments|Distribution|Keywords|Organization|Summary';
>
> I didn't do that because if the message was first gated from news to mail
> and is being gated back (why, I don't know) for some reason, the message
> may already have these headers present, and I saw no reason not to preserve
> them.

I do not understand.  If we do not list these headers here, it means that
they are renamed.  For instance, the Comments: header field becomes X-Comments:
and that's why I thought we had better list it here.
We should preserve these headers.


>> +The Received: and *-To: headers are also stripped out to prevent
>> spamming
>
> Actually, the "Received" header is not stripped out, but it is altered to
> delete the "FOR _mailbox_" clause

Yep, I will change the wording.


>> +=item B<-z> I<header>[B<:>I<header>...]
>> +
>> +A colon-separated list of additional headers which should be removed.
>> +
>> +By default, removed headers are:
>> +
>> +    Bcc
>> +    X-Trace
>> +    X-Complaints-To
>> +
>>  =back
>>
>>  =head1 FILES
>
> Same comment as above regarding news->mail->news gating.

I did not change anything here.
The X-Trace: and X-Complaints-To: headers have always been removed
by mailpost.



Injection-Date: and Injection-Info: headers are currently renamed to X-*.
Maybe the first one should remain unchanged and the second one removed
(like X-Trace:).

-- 
Julien ÉLIE

« La fin du monde est un sujet sérieux, surtout pour ceux qui s'y préparent. » 
(Filiu) 
Re: Please consider this INN patch for mailpost
#83466
Author: D. Stussy
Date: Fri, 01 Oct 2010 03:08
108 lines
5063 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:i82tvh$n8g$1@news.trigofacile.com...
> >> I would have added:
> >>
> >>     chop ($Gateway = `/bin/hostname`) if ! $Gateway ;
> >>
> >> the same way it is done for $Mailname.
> >
> > I specifically left that out for one reason:  Virtual hosting.  The
> > /bin/hostname name may not be the same name as the news server, nor
even
> > under the same domain name.  We could add another command line
parameter to
> > exclude additional hostnames if necessary.
>
> Then how would it harm if /bin/hostname was in the patterns to look for?

Unnecessary processing (extra work).  If the name stored in the system's
global hostname variable isn't ever used in mail gated to news, we'd be
checking for a value that will never be present.  That's why I decided to
write my suggested patch with ONLY the names we KNOW are used for the news
server, and mail delivered to the news server hostname is that which is
gated.  If there should be other hostnames or domains that should be
excluded (beyond inn.conf and readers.conf), let the administrator
explicitly set them (and perhaps we should have a parameter for that).

I chose a minimalist approach to the feature -- alter as little as
possible/desired.

> > However,
> > while the script is running, the name from the TCP socket might be
> > "localhost" if it's using the loopback interface to connect between
mail
> > and news.
>
> It does not matter to have "localhost" left in Received: or *-To:
headers.
> No problem to not look for it, if I understand the aim of your patch.

Bad example.  However, my point was that there may be other [virtual]
hostnames in use that have nothing to do with the gateway.

> >> I would also have changed:
> >>
> >> -my $exclude = 'Organization|Distribution';
> >> +my $exclude =
> >>
> >
'Archive|Archived-At|Comments|Distribution|Keywords|Organization|Summary';
> >
> > I didn't do that because if the message was first gated from news to
mail
> > and is being gated back (why, I don't know) for some reason, the
message
> > may already have these headers present, and I saw no reason not to
preserve
> > them.
>
> I do not understand.  If we do not list these headers here, it means that
> they are renamed.  For instance, the Comments: header field becomes
X-Comments:
> and that's why I thought we had better list it here.
> We should preserve these headers.

Excluded headers are not passed AT ALL to the news article version of the
message.  They are effectively deleted.

> >> +The Received: and *-To: headers are also stripped out to prevent
> >> spamming
> >
> > Actually, the "Received" header is not stripped out, but it is altered
to
> > delete the "FOR _mailbox_" clause
>
> Yep, I will change the wording.
>
>
> >> +=item B<-z> I<header>[B<:>I<header>...]
> >> +
> >> +A colon-separated list of additional headers which should be removed.
> >> +
> >> +By default, removed headers are:
> >> +
> >> +    Bcc
> >> +    X-Trace
> >> +    X-Complaints-To
> >> +
> >>  =back
> >>
> >>  =head1 FILES
> >
> > Same comment as above regarding news->mail->news gating.
>
> I did not change anything here.
> The X-Trace: and X-Complaints-To: headers have always been removed
> by mailpost.
>
>
>
> Injection-Date: and Injection-Info: headers are currently renamed to X-*.
> Maybe the first one should remain unchanged and the second one removed
> (like X-Trace:).

Do what you feel is appropriate for those two.  I did not write my patch
with them in mind as I was hacking at a version (2.5.2) that doesn't have
them yet.

Re: Please consider this INN patch for mailpost
#83473
Author: Julien ÉLIE
Date: Fri, 01 Oct 2010 18:46
55 lines
3164 bytes
Hi Dieter,

>> I do not understand.  If we do not list these headers here, it means that
>> they are renamed.  For instance, the Comments: header field becomes
>> X-Comments: and that's why I thought we had better list it here.
>> We should preserve these headers.
>
> Excluded headers are not passed AT ALL to the news article version of the
> message.  They are effectively deleted.

No.  They are effectively *excluded from deletion*.
They are passed to the generated news article.


    if (/^($exclude):\s*/sio) {
        $real_news_hdrs .= "$_\n";
        next;
    }

    print TMPFILE <<"EOF";
Path: ${path}
From: ${fromHdr}
Newsgroups: ${newsgroups}
${real_news_hdrs}Date: ${dateHdr}
${weird_mail_hdrs}
EOF


man mailpost

   A colon-separated list of additional headers which should be treated
   as known headers; these headers will be passed through to inews without
   having "X-" prepended.




>> Injection-Date: and Injection-Info: headers are currently renamed to X-*.
>> Maybe the first one should remain unchanged and the second one removed
>> (like X-Trace:).
>
> Do what you feel is appropriate for those two.  I did not write my patch
> with them in mind as I was hacking at a version (2.5.2) that doesn't have
> them yet.

OK, I will have a look.
Thanks for your other remarks too.  I will take them into account.

-- 
Julien ÉLIE

« Depuis que j'ai changé mon clavier qwerty pour un clavier azerty,
  je tape deux fois plus vite. Pourquoi ?
  Parce qu'un homme azerty en vaut deux ! » 
Re: Please consider this INN patch for mailpost
#83474
Author: D. Stussy
Date: Fri, 01 Oct 2010 19:52
24 lines
2149 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:i85aa4$bq1$1@news.trigofacile.com...
> >> I do not understand.  If we do not list these headers here, it means
that
> >> they are renamed.  For instance, the Comments: header field becomes
> >> X-Comments: and that's why I thought we had better list it here.
> >> We should preserve these headers.
> >
> > Excluded headers are not passed AT ALL to the news article version of
the
> > message.  They are effectively deleted.
>
> No.  They are effectively *excluded from deletion*.
> They are passed to the generated news article.
>
>
>     if (/^($exclude):\s*/sio) {
>         $real_news_hdrs .= "$_\n";
>         next;
>     }

I would logically call those INCLUDED headers.  ;-)

Re: Please consider this INN patch for mailpost
#83482
Author: Julien ÉLIE
Date: Sun, 03 Oct 2010 12:12
30 lines
2574 bytes
Hi Dieter,

>>     chop ($Gateway = `/bin/hostname`) if ! $Gateway ;
>
> I specifically left that out for one reason:  Virtual hosting.  The
> /bin/hostname name may not be the same name as the news server, nor even
> under the same domain name.  We could add another command line parameter to
> exclude additional hostnames if necessary.
>
> On my system, my news server is "news.snarked.org", but /bin/hostname
> returns only "snarked.org" which has no DNS address-type records.

Anyway, I see in lib/innconf.c that when "fromhost" is unset, it uses:

    if (innconf->fromhost == NULL)
        innconf->fromhost = xstrdup(GetFQDN(innconf->domain));

It corresponds to what the documentation states in inn.conf:  "The default
is the fully-qualified domain name of the local host."
Therefore, the definition in mailpost will do nothing (and no harm) but
it prevents the following line:
  $Gateway .= '|' . $INN::Config::pathhost if $INN::Config::pathhost;
to put a "|" at the beginning of the regexp in case $Gateway is not defined.
(Which should normally not happen.)

-- 
Julien ÉLIE

« It's documented in The Book, somewhere... » (Larry Wall) 
Re: Please consider this INN patch for mailpost
#83483
Author: D. Stussy
Date: Mon, 04 Oct 2010 05:39
33 lines
2598 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:i89ruf$efp$1@news.trigofacile.com...
> >>     chop ($Gateway = `/bin/hostname`) if ! $Gateway ;
> >
> > I specifically left that out for one reason:  Virtual hosting.  The
> > /bin/hostname name may not be the same name as the news server, nor
even
> > under the same domain name.  We could add another command line
parameter to
> > exclude additional hostnames if necessary.
> >
> > On my system, my news server is "news.snarked.org", but /bin/hostname
> > returns only "snarked.org" which has no DNS address-type records.
>
> Anyway, I see in lib/innconf.c that when "fromhost" is unset, it uses:
>
>     if (innconf->fromhost == NULL)
>         innconf->fromhost = xstrdup(GetFQDN(innconf->domain));
>
> It corresponds to what the documentation states in inn.conf:  "The
default
> is the fully-qualified domain name of the local host."
> Therefore, the definition in mailpost will do nothing (and no harm) but
> it prevents the following line:
>   $Gateway .= '|' . $INN::Config::pathhost if $INN::Config::pathhost;
> to put a "|" at the beginning of the regexp in case $Gateway is not
defined.
> (Which should normally not happen.)

You are correct that at this point, I assumed "$Gateway" was not empty.
Was that in fact a bad assumption?

Re: Please consider this INN patch for mailpost
#83488
Author: Julien ÉLIE
Date: Mon, 04 Oct 2010 17:30
48 lines
3163 bytes
Hi Dieter,

>> Anyway, I see in lib/innconf.c that when "fromhost" is unset, it uses:
>>
>>     if (innconf->fromhost == NULL)
>>         innconf->fromhost = xstrdup(GetFQDN(innconf->domain));
>>
>> Therefore, the definition in mailpost will do nothing (and no harm) but
>> it prevents the following line:
>>   $Gateway .= '|' . $INN::Config::pathhost if $INN::Config::pathhost;
>> to put a "|" at the beginning of the regexp in case $Gateway is not
> defined.
>
> You are correct that at this point, I assumed "$Gateway" was not empty.
> Was that in fact a bad assumption?

One can use the empty string:

19:25 news@trigo ~% grep fromhost ~/etc/inn.conf
fromhost:               ""
19:25 news@trigo ~% innconfval -i  ~/etc/inn.conf -s | grep FROMHOST
FROMHOST=''; export FROMHOST;


Note that, when unset (NULL), the value is properly set:

19:26 news@trigo ~% grep fromhost ~/etc/inn.conf
#fromhost:              news.trigofacile.com
19:26 news@trigo ~% innconfval -i  ~/etc/inn.conf -s | grep FROMHOST
FROMHOST='news.trigofacile.com'; export FROMHOST;



Anyway, I believe that the case of an empty string should not occur.
It is a misconfiguration.  News administrators are not supposed to
break their server...  What, for instance, if fromhost is itself a pattern
like "a|b|c" or ".*"?

I also did not test whether the dot means everything or a real dot
in $Gateway...

-- 
Julien ÉLIE

« -- Du potage : c'est tout ce que le cuisinier a pu faire !
  -- Ce blocus devient très horripilant !
  -- Blocus, c'est ton cuisinier ? » (Astérix) 
Re: Please consider this INN patch for mailpost
#83489
Author: D. Stussy
Date: Tue, 05 Oct 2010 00:53
14 lines
1779 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:i8d2vq$219$1@news.trigofacile.com...
> ...
> I also did not test whether the dot means everything or a real dot
> in $Gateway...

I think I ignored that too.  However, that's a one additional line fix:

  [pseudocode:]  $Gateway ->  "s/\./\\./g"

I don't recall offhand exactly how to specify the change in perl.  I'm
still figuring the language out.

Fixes to mailpost -- Long headers - was Re: Please consider this INN patch for mailpost
#83503
Author: D. Stussy
Date: Thu, 07 Oct 2010 06:25
25 lines
2211 bytes
I have noted another problem recently:

Some mail, because of its source (Yahoo), contains a [custom] header with
data that exceeds 998 characters (excluding the trailing CR+LF).  Should
this program deal with that problem for mail it is gating, or not (or
optional)?

If so, I suggest altering the header at position 980 with "
(truncated)...", which makes the length 995 characters (excluding CR+LF),
thus less than the 998 character limitation for article headers with
minimal information loss.

As this patch is trivial (one carefully placed line), I shall let the ISC
INN maintainers actually write the patch.  However, as noted, it should be
something like:

  $line = left($line, 980) . " (truncated)..."  if length($line) > 998;

Where $line is the actual variable containing the header line (both header
name and data).  I did not look back at the actual script to see if $line
is the actual variable.



Re: Fixes to mailpost -- Long headers - was Re: Please consider this INN patch for mailpost
#83502
Author: Julien ÉLIE
Date: Thu, 07 Oct 2010 18:13
14 lines
1985 bytes
Hi Dieter,

> Some mail, because of its source (Yahoo), contains a [custom] header with
> data that exceeds 998 characters (excluding the trailing CR+LF).

Why don't you just remove that custom header with the new -z flag you added?

-- 
Julien ÉLIE

« As promised, here's the patch to do this.  Not only is it good
  (it compiles), but it is perfect (it boots).  Up 9 minutes so far
  without problems. » (Richard Gooch on linux-kernel) 
Re: Fixes to mailpost -- Long headers - was Re: Please consider this INN patch for mailpost
#83504
Author: D. Stussy
Date: Thu, 07 Oct 2010 19:59
23 lines
2385 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:i8l2ka$ugv$1@news.trigofacile.com...
> > Some mail, because of its source (Yahoo), contains a [custom] header
with
> > data that exceeds 998 characters (excluding the trailing CR+LF).
>
> Why don't you just remove that custom header with the new -z flag you
added?

Yes, I could.  However, I suggested this because of the news article header
line length standard.  Such a problem could easily return when another mail
server does something else stupid with overly large header data.

Also, I have occasionally noted this with DKIM signatures that use long
keys.  Preserving part of that field seems a better solution than deleting
it entirely as the message gates.  Similarly with a "References:" header,
even though NNTP would have a different size reducing algorithm (keeping
the first and last MIDs).

In other words, I'm trying to address a larger problem than just one
offending header (pun intended).

Re: Fixes to mailpost -- Long headers
#83506
Author: Julien ÉLIE
Date: Thu, 07 Oct 2010 20:18
27 lines
2304 bytes
Hi Dieter,

> Also, I have occasionally noted this with DKIM signatures that use long
> keys.  Preserving part of that field seems a better solution than deleting
> it entirely as the message gates.

Why would it be a better solution to alter a header?
The DKIM signature is useless if altered.
And a header ending with " (truncated)..." may see its syntax broken!
If useless for Netnews, just drop it.


> Similarly with a "References:" header,
> even though NNTP would have a different size reducing algorithm (keeping
> the first and last MIDs).

Yep, we had a patch from Harald Dunkel about that:
    http://inn.eyrie.org/trac/changeset/9020

The References: header is now properly dealt with by mailpost.

-- 
Julien ÉLIE

« L'art de la médecine consiste à distraire le malade
  pendant que la nature le guérit. » (Voltaire) 
Re: Fixes to mailpost -- Long headers
#83513
Author: D. Stussy
Date: Fri, 08 Oct 2010 01:57
39 lines
3079 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:i8l9ug$6m7$1@news.trigofacile.com...
> > Also, I have occasionally noted this with DKIM signatures that use long
> > keys.  Preserving part of that field seems a better solution than
deleting
> > it entirely as the message gates.
>
> Why would it be a better solution to alter a header?
> The DKIM signature is useless if altered.
> And a header ending with " (truncated)..." may see its syntax broken!
> If useless for Netnews, just drop it.

1)  I don't want to drop it if it's within the permitted length.  Granted
that dropping it will still leave an Authentication-Results header that
says it was valid, but I believe in modifying only as necessary.

2)  Granted truncating breaks it, but it is also leaving SMTP and is
considered delivered.  If the message were to re-enter SMTP, a truncated
header should then be discarded, especially in favor of a new signature (if
applicable).

3)  To drop such headers, we need to know their names in advance.  We may
not know in advance the name of an X-* header that is too long.

> > Similarly with a "References:" header,
> > even though NNTP would have a different size reducing algorithm
(keeping
> > the first and last MIDs).
>
> Yep, we had a patch from Harald Dunkel about that:
>     http://inn.eyrie.org/trac/changeset/9020
>
> The References: header is now properly dealt with by mailpost.

Right, but the handling there is a special case.  My suggestion is for the
generic case of an overly-long header+data.  You seem exceptionally
resistant to the idea.

Re: Fixes to mailpost -- Long headers
#83512
Author: Julien ÉLIE
Date: Fri, 08 Oct 2010 17:58
17 lines
2143 bytes
Hi Dieter,

> Right, but the handling there is a special case.  My suggestion is for the
> generic case of an overly-long header+data.  You seem exceptionally
> resistant to the idea.

Yes, I am resistant to alter headers this way.

What I am willing to do, however, is to remove overly-long header lines.
With a flag to trigger that behaviour.

-- 
Julien ÉLIE

« I had some words with my wife, and she had
  some paragraphs with me. » (Sigmund Freud) 
Re: Fixes to mailpost -- Long headers
#83515
Author: D. Stussy
Date: Fri, 08 Oct 2010 22:19
21 lines
2020 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message
news:i8nm38$qf7$1@news.trigofacile.com...
> > Right, but the handling there is a special case.  My suggestion is for
the
> > generic case of an overly-long header+data.  You seem exceptionally
> > resistant to the idea.
>
> Yes, I am resistant to alter headers this way.
>
> What I am willing to do, however, is to remove overly-long header lines.
> With a flag to trigger that behaviour.

How about this:  A flag with a value:

0 - Do nothing (default, also same as no value or undef)
1 - Delete header
2 - Truncate header.

Let the adminstrator choose.  Is that acceptable?

Re: Fixes to mailpost -- Long headers
#83517
Author: Julien ÉLIE
Date: Sat, 09 Oct 2010 07:58
24 lines
2159 bytes
Hi Dieter,

>> What I am willing to do, however, is to remove overly-long header lines.
>> With a flag to trigger that behaviour.
>
> How about this:  A flag with a value:
>
> 0 - Do nothing (default, also same as no value or undef)
> 1 - Delete header
> 2 - Truncate header.
>
> Let the adminstrator choose.  Is that acceptable?

Yes!
(I would switch 1 and 2, to have a sort by order of alteration.)

-- 
Julien ÉLIE

« -- Cet homme qui est sorti du palais, nous renseignera peut-être
  sur la façon d'y entrer. Suivons-le.
  -- Mais... Il sait sortir d'accord, mais rien ne prouve qu'il
  sache entrer, et... » (Astérix) 
Re: Please consider this INN patch for mailpost (addendum)
#83630
Author: D. Stussy
Date: Fri, 05 Nov 2010 02:10
21 lines
2169 bytes
There is one more place that may need to be altered to hide the gateway
address:  The message body.

I have noted that some mailing lists may insert the subscriber's address
into the body of the message.  That is damn annoying.

Therefore, about line 350 of mailpost.in:

-$rest .= $_ while (<STDIN>);
+$rest .= s/.+[@%=]($Gateway).*\n//sio while (<STDIN>);

I think that does it - It effectively deletes any line (by substitution)
that contains the gateway domain.  I also think that this is correct:  The
substitiution expression operates on $_, which is changed each time the
while() clause is tested to be the current line input.

Maybe this shouldn't delete the entire line but just the gateway mailbox?
Are the parentheses needed around Gateway?  I know that "%" and "=" are
needed for routing and SRS type expressions from the mail system.

Re: Please consider this INN patch for mailpost (addendum)
#83639
Author: D. Stussy
Date: Thu, 11 Nov 2010 21:08
27 lines
2333 bytes
"D. Stussy" <spam+newsgroups@bde-arc.ampr.org> wrote in message
news:ib07h3$7ko$4@snarked.org...
> There is one more place that may need to be altered to hide the gateway
> address:  The message body.
>
> I have noted that some mailing lists may insert the subscriber's address
> into the body of the message.  That is damn annoying.
>
> Therefore, about line 350 of mailpost.in:
>
> -$rest .= $_ while (<STDIN>);
> +$rest .= s/.+[@%=]($Gateway).*\n//sio while (<STDIN>);
>
> I think that does it - It effectively deletes any line (by substitution)
> that contains the gateway domain.  I also think that this is correct:
The
> substitiution expression operates on $_, which is changed each time the
> while() clause is tested to be the current line input.
>
> Maybe this shouldn't delete the entire line but just the gateway mailbox?
> Are the parentheses needed around Gateway?  I know that "%" and "=" are
> needed for routing and SRS type expressions from the mail system.

In testing the above, it appears not to work (it deletes more than just the
affected line).

Re: Please consider this INN patch for mailpost
#87747
Author: Julien ÉLIE
Date: Wed, 19 Jul 2017 20:41
57 lines
3516 bytes
Hi Dieter,

Yeah, now taken into account 7 years after your proposal.  Better now 
than never :)

They will be shipped with INN 2.6.2:
   https://inn.eyrie.org/trac/changeset/10166
   https://inn.eyrie.org/trac/changeset/10167
   https://inn.eyrie.org/trac/changeset/10168

Do you happen to have other improvements to mailpost?



> What this patch does and why:
> 
> 1) Adds a "-z" parameter to remove any undesired headers from the gated
> message.  It also forces removal of the "Bcc:" header.  Under SMTP, Bcc is
> permitted to exist with a blank RHS, but NNTP forbids a blank RHS for any
> header.  (Without this patch for "Bcc:", the script was promoting it to
> "X-Bcc:" and leaving it in the article; a violation of the article format.)

Thanks for that new parameter!
Note that I've dropped the part about the Bcc: header in your patch 
because the problem of empty header fields has been fixed by other 
patches for INN 2.6.2:
   https://inn.eyrie.org/trac/changeset/10162
   https://inn.eyrie.org/trac/changeset/10156



> 2) Edits the incoming SMTP message's "Received:" header to remove any "for
> <mailbox>" clause which contains the name of the news server (or its
> domain).  It determines the name by examining "pathhost", "fromhost" and
> "domain" (from file "inn.conf").  The reason for this is to protect the
> gateway mailbox from spammers who may seek to abuse the gateway.  This will
> also remove any "*-To:" headers that cite the news server host or domain
> name (e.g. "Errors-To:" which are set to report back which user bounced by
> using a mailbox pattern in the envelope).  As the gateway mailbox name is
> now hidden, spammers will have to discover it via other means.  It's not
> meant as an anti-spam measure by itself, but spammers can't spam that which
> they can't find.  Since the administrator knows the message was gated, he
> knows it was delivered to the gateway mailbox, so information deleted from
> the trace header isn't "lost"; just merely hidden.  "For" clauses from
> other "Received:" headers not specifying the mail server's host/domain are
> left intact.

OK, I'm fine with that.

-- 
Julien ÉLIE

« – Chef ! On vient !
   – On se met en carré ?
   – Non ! En bosquet ! » (Astérix)

Re: Fixes to mailpost -- Long headers - was Re: Please consider this INN patch for mailpost
#87748
Author: Julien ÉLIE
Date: Wed, 19 Jul 2017 20:50
37 lines
2748 bytes
Hi Dieter,

>>> Some mail, because of its source (Yahoo), contains a [custom]
>>> header with
>>> data that exceeds 998 characters (excluding the trailing CR+LF).
>>
>> Why don't you just remove that custom header with the new -z flag you
> added?
> 
> Yes, I could.  However, I suggested this because of the news article header
> line length standard.  Such a problem could easily return when another mail
> server does something else stupid with overly large header data.
> 
> Also, I have occasionally noted this with DKIM signatures that use long
> keys.  Preserving part of that field seems a better solution than deleting
> it entirely as the message gates.  Similarly with a "References:" header,
> even though NNTP would have a different size reducing algorithm (keeping
> the first and last MIDs).
> 
> In other words, I'm trying to address a larger problem than just one
> offending header (pun intended).

It was in fact a bug in inews, not mailpost.
Such messages posted by mailpost through inews were rejected because 
inews checked the length of 998 characters for the whole header field 
whereas that limit is for a single header line (without continuation 
lines).  Fixed in INN 2.6.2:
   https://inn.eyrie.org/trac/changeset/10161

-- 
Julien ÉLIE

« – Chef ! On vient !
   – On se met en carré ?
   – Non ! En bosquet ! » (Astérix)

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