🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
13 messages
13 total messages Started by Julien ÉLIE Thu, 28 Aug 2008 20:26
200 or 201 at initial connection?
#79382
Author: Julien ÉLIE
Date: Thu, 28 Aug 2008 20:26
78 lines
4075 bytes
Hi,

Hmm...  The classic question :)

According to a previous thread
    http://groups.google.fr/group/news.software.nntp/browse_frm/thread/967621f451962ace/

"Yes, there are clients that, if they get a 201 greeting, will never even
attempt to send POST and will just error out.  nnrpd should send a 200
greeting if there's any possibility for the client to authenticate, since
prior to authentication it doesn't know what the real privileges are
(think Perl and Python auth hooks, for instance)."

So if I understand well, the cases are, at initial connection:

* the reader can post right now in at least one group
    -> 200
    -> POST in CAPABILITIES

* the reader cannot post right now but can authenticate and have posting
  access to at least one group
    -> 200
    -> POST *not* in CAPABILITIES

* the reader cannot post right now and cannot authenticate or if authenticated
  will still not have posting access
    -> 201
    -> POST *not* in CAPABILITIES

Am I right?


Because RFC 3977 says:

   If the server will accept further commands from the client including
   POST, the server MUST present a 200 greeting code.  If the server
   will accept further commands from the client, but the client is not
   authorized to post articles using the POST command, the server MUST
   present a 201 greeting code.

It is not clear for the second case I described.  Reading that, I understand
that it is 201 even though the client might be authorized to post after
authenticated.
So perhaps it is:

* the reader cannot post right now but can authenticate and have posting
  access to at least one group
    -> 201
    -> POST in CAPABILITIES

What strikes me most is that it seems to be how nnrpd already behaves
for 200/201 while I was under the impression that it did not the right thing...

If, after authentication, the reader still does not have posting access,
it is the moment we drop POST from CAPABILITIES.  Right?


   Note: the distinction between the 200 and 201 response codes has
   turned out in practice to be insufficient; for example, some servers
   do not allow posting until the client has authenticated, while other
   clients assume that a 201 response means that posting will never be
   possible even after authentication.  Therefore, clients SHOULD use
   the CAPABILITIES command (Section 5.2) rather than rely on this
   response.

Still not clear.  The note does not give more explanation :-/
I think the three cases I see (do you have other ones?) should be given
in examples to make the note perfectly clear...


Thanks beforehand and sorry for that recurrent question...

-- 
Julien ÉLIE

« -- Nous voyageons plus vite que la lumière !
  -- Alors comment y voir clair dans tout ça ? » (Astérix) 
Re: 200 or 201 at initial connection?
#79383
Author: Russ Allbery
Date: Fri, 29 Aug 2008 00:57
56 lines
3014 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> writes:

> So if I understand well, the cases are, at initial connection:
>
> * the reader can post right now in at least one group
>    -> 200
>    -> POST in CAPABILITIES
>
> * the reader cannot post right now but can authenticate and have posting
>  access to at least one group
>    -> 200
>    -> POST *not* in CAPABILITIES
>
> * the reader cannot post right now and cannot authenticate or if authenticated
>  will still not have posting access
>    -> 201
>    -> POST *not* in CAPABILITIES
>
> Am I right?

Correct.

> Because RFC 3977 says:
>
>   If the server will accept further commands from the client including
>   POST, the server MUST present a 200 greeting code.  If the server
>   will accept further commands from the client, but the client is not
>   authorized to post articles using the POST command, the server MUST
>   present a 201 greeting code.

Which, of course, doesn't tell you what to do if you don't know whether
the user will be able to post or not.  nnrpd errs on the side of caution
and presents 200.

> So perhaps it is:
>
> * the reader cannot post right now but can authenticate and have posting
>  access to at least one group
>    -> 201
>    -> POST in CAPABILITIES

No, you cannot advertise POST in CAPABILITIES unless the user can POST
right now without any additional authentication.  POST should only show up
after the user has acquired whatever authentication is needed so that they
can post.

CAPABILITIES has to be much more accurate than the 200/201.  It should
reflect the current state, including STARTTLS, authentication, MODE
READER, and so forth, and the standard makes it clear that its results may
change after those sorts of operations.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: 200 or 201 at initial connection?
#79384
Author: Julien ÉLIE
Date: Sat, 30 Aug 2008 21:02
80 lines
3627 bytes
Hi Russ,

>> * the reader can post right now in at least one group
>>    -> 200
>>    -> POST in CAPABILITIES
>>
>> * the reader cannot post right now but can authenticate and have posting
>>  access to at least one group
>>    -> 200
>>    -> POST *not* in CAPABILITIES
>>
>> * the reader cannot post right now and cannot authenticate or if authenticated
>>  will still not have posting access
>>    -> 201
>>    -> POST *not* in CAPABILITIES
>>
>> Am I right?
>
> Correct.

That's great.  It is now pretty clear thanks to you.



> CAPABILITIES has to be much more accurate than the 200/201.  It should
> reflect the current state, including STARTTLS, authentication, MODE
> READER, and so forth.

As for the implementation, it can soon become very difficult...
Just a few examples:

auth "users" {
    hosts: "*"
    auth: "ckpasswd -f /home/news/etc/users"
}

access "users" {
    newsgroups: "*"
    access: RPA
}

With an *empty* users file.  The same goes for ldap, Kerberos...
The server will send 200 whereas in fact the client will never
be able to authenticate.


Another tricky one:

access "users" {
    post: "*abc*"
    access: RPAIN
}

Suppose that we have no group containing "abc" (you can also try
post: "!*" if you prefer)...  We also have to check whether local
posts are allowed in groups by the way (for the "n" flag in active).
Note that it is amusing to use such an access group -> the client
connects and receives 200 with READER, POST, IHAVE and NEWNEWS.
Nevertheless, almost everything is denied.


May I assume it is useless to check such degenerated cases?
Anyway, the first one cannot be checked.
The second one, it can but I do not think it is worth doing that.

Therefore, it is impossible to properly implement the right anwser codes.

Can we just do the best we can with what the news administrator
sets up?  (implicitly assuming that for instance if post: is used,
then at least one group exists in which the user will be able to post)


(For those who wonder whether I am driving insane with such remarks,
well I hope not!)

-- 
Julien ÉLIE

« Ta vie ne tient qu'à un fil, Téléféric ! » (Astérix) 
Re: 200 or 201 at initial connection?
#79385
Author: Russ Allbery
Date: Sun, 31 Aug 2008 01:09
49 lines
2953 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> writes:

> As for the implementation, it can soon become very difficult...
> Just a few examples:
>
> auth "users" {
>    hosts: "*"
>    auth: "ckpasswd -f /home/news/etc/users"
> }
>
> access "users" {
>    newsgroups: "*"
>    access: RPA
> }
>
> With an *empty* users file.  The same goes for ldap, Kerberos...
> The server will send 200 whereas in fact the client will never
> be able to authenticate.

Yeah, this is the sort of thing I was thinking of when I had mentioned
cases where you don't know whether the user will be able to authenticate
or not.  CAPABILITIES is much cleaner since it reflects the current
state.  This is one of the reasons why relying on 200/201 is deprecated.

It turns out that 200 is the "safe" return; it never breaks anything, and
at most leads clients to attempt posts that won't be allowed.  So nnrpd
currently always returns (or at least should always return) 200 unless it
knows for sure that posting will never be possible.

> May I assume it is useless to check such degenerated cases?
> Anyway, the first one cannot be checked.
> The second one, it can but I do not think it is worth doing that.
>
> Therefore, it is impossible to properly implement the right anwser codes.

Yup.  Exactly.

> Can we just do the best we can with what the news administrator
> sets up?  (implicitly assuming that for instance if post: is used,
> then at least one group exists in which the user will be able to post)

Yeah, I wouldn't spend a whole lot of time on getting it that accurate.
That's why CAPABILITIES is replacing it anyway.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: 200 or 201 at initial connection?
#79386
Author: Julien ÉLIE
Date: Sun, 31 Aug 2008 06:28
31 lines
2671 bytes
Hi Russ,

> Yeah, this is the sort of thing I was thinking of when I had mentioned
> cases where you don't know whether the user will be able to authenticate
> or not.  CAPABILITIES is much cleaner since it reflects the current
> state.  This is one of the reasons why relying on 200/201 is deprecated.

I do not understand why the same problem does not arises for POST
in CAPABILITIES:  since we cannot "advertise POST in CAPABILITIES unless
the user can POST right now without any additional authentication" (according
to your previous message ih this thread), we need to know that.

Python dynamic access groups for instance prevent us from knowing if POST
should be put in the CAPABILITIES list.


>> Can we just do the best we can with what the news administrator
>> sets up?  (implicitly assuming that for instance if post: is used,
>> then at least one group exists in which the user will be able to post)
>
> Yeah, I wouldn't spend a whole lot of time on getting it that accurate.
> That's why CAPABILITIES is replacing it anyway.

Even within the current state, I am unsure we can know whether POST should
be advertised...

-- 
Julien ÉLIE

« Vinum nouum, amicus nouus : uesterascet, et cum suauitate bibes illud. »
Re: 200 or 201 at initial connection?
#79387
Author: Julien ÉLIE
Date: Sun, 31 Aug 2008 12:01
57 lines
3175 bytes
Hi Russ,

> No, you cannot advertise POST in CAPABILITIES unless the user can POST
> right now without any additional authentication.  POST should only show up
> after the user has acquired whatever authentication is needed so that they
> can post.
>
> CAPABILITIES has to be much more accurate than the 200/201.  It should
> reflect the current state, including STARTTLS, authentication, MODE
> READER, and so forth, and the standard makes it clear that its results may
> change after those sorts of operations.

I agree.

May I suggest an improvement for the following example in section 5.3.3?


   Example of use of the MODE READER command on a mode-switching server:

      [C] CAPABILITIES
      [S] 101 Capability list:
      [S] VERSION 2
      [S] IHAVE
      [S] MODE-READER
      [S] .
      [C] MODE READER
      [S] 200 Reader mode, posting permitted
      [C] CAPABILITIES
      [S] 101 Capability list:
      [S] VERSION 2
      [S] READER
      [S] NEWNEWS
      [S] LIST ACTIVE NEWSGROUPS
      [S] STARTTLS
      [S] .

   In this case, the server offers (but does not require) TLS privacy in
   its reading mode but not in its transit mode.

As the return code is 200 (also with the comment "posting permitted"), I think
you should either change the comment or add POST to the CAPABILITIES list.
Another solution is to say that posting will be allowed only if the connection
is encrypted; therefore, POST will appear only after a successful STARTTLS.

It would make the example clearer!



I do not know whether it is worthwile mentioning misprints but in case
there is another "edition", there is one in "which therefore does not
providing reading facilities" (5.3.3).

-- 
Julien ÉLIE

« Deficiente uino, deficit omne. » 
Re: 200 or 201 at initial connection?
#79388
Author: Russ Allbery
Date: Sun, 31 Aug 2008 20:53
35 lines
2840 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> writes:

>> Yeah, this is the sort of thing I was thinking of when I had mentioned
>> cases where you don't know whether the user will be able to
>> authenticate or not.  CAPABILITIES is much cleaner since it reflects
>> the current state.  This is one of the reasons why relying on 200/201
>> is deprecated.
>
> I do not understand why the same problem does not arises for POST in
> CAPABILITIES:  since we cannot "advertise POST in CAPABILITIES unless
> the user can POST right now without any additional authentication"
> (according to your previous message ih this thread), we need to know
> that.
>
> Python dynamic access groups for instance prevent us from knowing if
> POST should be put in the CAPABILITIES list.

Oh, hm.  Now I see what you're getting at.

Dynamic authorization is a hard one for this, and I'm not sure we can do
any better than advertising POST despite the fact that it might always
fail.  I think it's sort of in the same category as posting filters or "n"
mode groups -- the POST *capability* is present, but there are various
post-time checks that may or may not succeed at the time of a posting.

You're right, this isn't as different as I thought.  CAPABILITIES will
need to be handled a similar way, since the client should not even attempt
a POST unless POST is advertised as a capability.  If we want the browser
to attempt one, we have to advertise it.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: 200 or 201 at initial connection?
#79389
Author: Julien ÉLIE
Date: Sun, 31 Aug 2008 21:25
24 lines
2386 bytes
Hi Russ,

> CAPABILITIES will
> need to be handled a similar way, since the client should not even attempt
> a POST unless POST is advertised as a capability.  If we want the browser
> to attempt one, we have to advertise it.

All right.  Therefore, each time an option which can lead to a possibility
to post is used, we have to advertise POST.

Anyway, if there is only local.test where a user can post on a news server
which provides thousands of newsgroups, POST is also here; so it does not
harm to advertise POST when we are unsure (dynamic access scripts for instance).


CAPABILITIES is still better than the 200/201 greeting because of its accuracy
for the current state of the session (and not a possible state the user can reach).
But it suffers from the same limitations to find out if a user can post.

-- 
Julien ÉLIE

« Sitis licita, etiam potio licita. » 
Re: 200 or 201 at initial connection?
#79390
Author: Julien ÉLIE
Date: Sun, 31 Aug 2008 21:30
29 lines
2359 bytes
Hi again,

> May I suggest an improvement for the following example in section 5.3.3?

For 6.2.1.2 too, regarding ARTICLE:

   If the argument is a message-id and no such article exists, a 430
   response MUST be returned.
   If the argument is a number or is omitted
   and the currently selected newsgroup is invalid, a 412 response MUST
   be returned.
   If the argument is a number and that article does not
   exist in the currently selected newsgroup, a 423 response MUST be
   returned.
   If the argument is omitted and the current article number
   is invalid, a 420 response MUST be returned.

There is a race condition for the second and the fourth.  We MUST return
two different codes :)
RFC 3977 does not mention that these sentences should match in order.

I believe the fourth one lacks "in the currently selected newsgroup".

-- 
Julien ÉLIE

« Tu quoque fili... Ce Brutus...
  Je finirai par avoir des ennuis avec ce garnement ! » (César)
Re: 200 or 201 at initial connection?
#79391
Author: Russ Allbery
Date: Sun, 31 Aug 2008 21:54
39 lines
2812 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> writes:

> Hi again,
>
>> May I suggest an improvement for the following example in section 5.3.3?
>
> For 6.2.1.2 too, regarding ARTICLE:
>
>   If the argument is a message-id and no such article exists, a 430
>   response MUST be returned.  If the argument is a number or is omitted
>   and the currently selected newsgroup is invalid, a 412 response MUST
>   be returned.  If the argument is a number and that article does not
>   exist in the currently selected newsgroup, a 423 response MUST be
>   returned.  If the argument is omitted and the current article number
>   is invalid, a 420 response MUST be returned.
>
> There is a race condition for the second and the fourth.  We MUST return
> two different codes :)  RFC 3977 does not mention that these sentences
> should match in order.
>
> I believe the fourth one lacks "in the currently selected newsgroup".

Yes, there are some precendence problems.  The intention, I think, is to
say:

    If (the argument is a number or is omitted) and the currently selected
    newsgroup is invalid, a 412 response MUST be returned.  If the
    currently selected newsgroup is valid but the current article number
    is invalid, a 420 response MUST be returned.

The most common reason for a 412 response is to issue ARTICLE with a
number before issuing any GROUP command.  420 is only used once a valid
current newsgroup has been established.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: 200 or 201 at initial connection?
#79392
Author: Julien ÉLIE
Date: Mon, 01 Sep 2008 05:56
39 lines
3092 bytes
Hi Russ,

>>   If the argument is a message-id and no such article exists, a 430
>>   response MUST be returned.  If the argument is a number or is omitted
>>   and the currently selected newsgroup is invalid, a 412 response MUST
>>   be returned.  If the argument is a number and that article does not
>>   exist in the currently selected newsgroup, a 423 response MUST be
>>   returned.  If the argument is omitted and the current article number
>>   is invalid, a 420 response MUST be returned.
>
> Yes, there are some precendence problems.  The intention, I think, is to
> say:
>
>    If (the argument is a number or is omitted) and the currently selected
>    newsgroup is invalid, a 412 response MUST be returned.  If the
>    currently selected newsgroup is valid but the current article number
>    is invalid, a 420 response MUST be returned.

"If the argument is omitted" in the last sentence.  Otherwise, it is confusing
with the third one, returning 423.
Indeed, suppose that in an empty group (=> invalid current article number),
you send "ARTICLE 42".  Then the article does not exist (423) and the current
article number is also invalid (420).

I think 423 is the right code, isn't it?


> The most common reason for a 412 response is to issue ARTICLE with a
> number before issuing any GROUP command.  420 is only used once a valid
> current newsgroup has been established.

It is also what I understood.  But better be without ambiguity in RFC.

-- 
Julien ÉLIE

« Tu quoque fili... Ce Brutus...
  Je finirai par avoir des ennuis avec ce garnement ! » (César)
Re: 200 or 201 at initial connection?
#79393
Author: Russ Allbery
Date: Mon, 01 Sep 2008 07:30
28 lines
2244 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> writes:

>> Yes, there are some precendence problems.  The intention, I think, is to
>> say:
>>
>>    If (the argument is a number or is omitted) and the currently selected
>>    newsgroup is invalid, a 412 response MUST be returned.  If the
>>    currently selected newsgroup is valid but the current article number
>>    is invalid, a 420 response MUST be returned.
>
> "If the argument is omitted" in the last sentence.

Well, yes.

> Otherwise, it is confusing with the third one, returning 423.  Indeed,
> suppose that in an empty group (=> invalid current article number), you
> send "ARTICLE 42".  Then the article does not exist (423) and the
> current article number is also invalid (420).
>
> I think 423 is the right code, isn't it?

Yes.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: 200 or 201 at initial connection?
#79401
Author: Julien ÉLIE
Date: Wed, 03 Sep 2008 20:17
19 lines
2037 bytes
Hi Russ,

>> There is a race condition for the second and the fourth.  We MUST return
>> two different codes :)  RFC 3977 does not mention that these sentences
>> should match in order.
>>
>> I believe the fourth one lacks "in the currently selected newsgroup".
>
> Yes, there are some precendence problems.

Incidentally, the same remark applies to similar explanations in the
description of both OVER and HDR.

-- 
Julien ÉLIE

« Qu'est-ce que je vous sers pour arroser le sanglier bouilli ?
  De l'eau chaude, de la cervoise tiède ou du vin rouge glacé ? » (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