🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #82023

Re: Spaces in NNTP commands

#82023
From: D. Stussy
Date: Sun, 18 Oct 2009 21:55
116 lines
6021 bytes
"Curt Welch" <curt@kcwc.com> wrote in message
news:20091018102618.742$eW@newsreader.com...
> =?iso-8859-15?Q?Julien_=C9LIE?= <iulius@nom-de-mon-site.com.invalid>
wrote:
> > Hi,
> >
> > Is it OK to just discard empty NNTP commands or commands containing
> > only white spaces?
>
> I have no clue what the specs they have written on this recently say, but
> all NNTP servers I've used, or written, always ignored empty lines.  I
use
> NNTP servers as command shells interactively and I like my command
servers
> to not bitch at me just because I hit return. :)
>
> My server had about 20 private NNTP commands for server admin and
> monitoring so the way I controlled my servers were to telnet to them and
> type commands.  I didn't use a separate out of band protocol to admin my
> servers like inn and diablo does.  And since I did spend a lot of time
> typing commands by hand to the servers, I wanted them to act like a
normal
> command shell - which ignores blank lines.
>
> Real NNTP clines don't send
> > That is to say answering nothing to "\r\n" and "   \r\n", just waiting
> > for the following real command.
> >
> > It is what nnrpd currently does for empty commands (but not innd, which
> > accepts the first "\r\n" and rejects the second "\r\n" with 500).
> >
> > An amusing thing is to write " \r\n" to nnrpd:  it closes the
connection
> > :)
> >
> > if (ac == 0)
> >   break;
> > => leave the infinite read loop
> > (it should be a "continue")
> >
> > N.B.: Even though RFC 3977 does not accept " POST" (leading space),
> > "POST " (trailing space), "IHAVE  <mid>" (with two white spaces),
> > it seems better to accept such commands, as nnrpd currently does.
> >
> > And just silently read empty commands.
> >
> > Any thought about that?
>
> Again, all the NNTP servers I've used or written, act like a command
shell
> and allow extra spaces everywhere, including in front of the commands or
> after the last argument.  Command parsing works by breaking the line into
> an argc/argv like structure based on spaces so it simply allows spaces
> everywhere around the words that make up the command.
>
> The one exception I had to deal with for that is allowing spaces in
message
> ids. I would reject the message as invalid if it had a space in the MID
but
> I had to hack the parser to special case commands that took message-ids
as
> arguments and parse them correctly if it had a space in it.  That was
back
> in the day where Diablo actually allowed message-ids like that and
because
> of that, I was at times, receiving messages from peers that had a space
in
> the message-id.

Is a space in a message-ID even a valid character?

A space is not part of the character set allowed by "atext" (from the BNF)
nor "qtext" (for quoted strings) nor "dtext".  Message-ID technically
relies only on "atext" and "dtext".  Therefore, I conclude that spaces are
NOT allowed in message ID's, even inside a quoted string (if such were
allowed in a MID).

Although the original news message format borrowed much from RFC 822, I
have used its current replacement, RFC 5322, for reference.  Section 3.6.4
of 5322 contains the BNF syntax for a message-id field.

Note also that a message-id is supposed to have a guarentee of uniqueness.
Therefore, MIDs like <...@localhost> are INVALID - for violating the
uniqueness property (and similarly with any other reserved domain entry).
(Yes, there are people that do send messages with the domain-part set to
"localhost" or "example.com" and the like.  In my cleanfeed.local file, I
add these to the filtered out MIDs as such messages are considered
malformed and thus SPAM).

> This was required for "TAKETHIS <bad id>".  If you rejected it as an
> invalid command, you break the protocol when the sending site follows
that
> with a full article. You want to correctly take the article from the peer
> and then correctly reject it.  If you don't do that, the peer just gets
> hung as it keeps trying to send the article to you again without
> understanding why it's getting 500 errors from your server - which means
> your feed from that peer might just hang until someone on the sending
side
> manually takes the bad article out of the queue.

If there's a space, it should be rejected with the error appropriate to a
bad parameter, not a bad command.

> I would hope current Diablo (and no other current NNTP servers) do that
> anymore.  But it's one more bit of old code that was needed once, and
could
> be useful in the future when someone writes a cheap ass server that
allows
> spaces in Message-ids and tries to feed such articles to a peer.


As long as we're dealing with NNTP command parsing, should a PASSWORD or
USER-ID be permitted to contain a space?  Unlike that with MID, I'm not
certain I've seen anything that would intentionally disallow such.

Technical Details
Message-ID: <hbg7ub$a74$5@snarked.org>
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!border1.nntp.dca.giganews.com!nntp.giganews.com!news.alt.net!news.kjsl.com!news.exile.org!news.snarked.org!not-for-mail
References: <hbdap8$7e8$1@news.trigofacile.com> <20091018102618.742$eW@newsreader.com>

Show Full Headers
Complete Article Headers
Message-ID: <hbg7ub$a74$5@snarked.org>
Subject: Re: Spaces in NNTP commands
Date: Sun, 18 Oct 2009 14:55:50 -0700
From: "D. Stussy" <spam+newsgroups@bde-arc.ampr.org>
References: <hbdap8$7e8$1@news.trigofacile.com> <20091018102618.742$eW@newsreader.com>
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!border1.nntp.dca.giganews.com!nntp.giganews.com!news.alt.net!news.kjsl.com!news.exile.org!news.snarked.org!not-for-mail
Newsgroups: news.software.nntp
Lines: 116
Reply-To: "D. Stussy" <replies@newsgroups.kd6lvw.ampr.org>
NNTP-Posting-Host: pool-71-160-18-32.lsanca.dsl-w.verizon.net
X-Trace: snarked.org 1255908107 10468 71.160.18.32 (18 Oct 2009 23:21:47 GMT)
X-Complaints-To: newsmaster@snarked.org
NNTP-Posting-Date: Sun, 18 Oct 2009 23:21:47 +0000 (UTC)
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478