[Mailman-Developers] Bug#57223: mailman: gate_news problems (fwd)

Barry A. Warsaw bwarsaw@cnri.reston.va.us (Barry A. Warsaw)
Mon, 7 Feb 2000 12:53:17 -0500 (EST)


I'm cutting and pasting a message that originated on the mailman-users
mailing list.  I think this message is fairly self-explanatory.  Can
other NNTP experts look this over and see if it makes sense?  I'll
apply it if there are no objections.

Note: the bare except is bothersome.

For reference, the thread is here:

http://www.python.org/pipermail/mailman-users/1999-October/002371.html

-Barry

-------------------- snip snip --------------------
On Sun, Oct 10, 1999 at 06:23:41PM -0700, Michael Ghens wrote:
> Tried a  news gateway test. This is the error:
[...]
> nntplib.error_perm: 500 "GROUP" not implemented; try "help".

Were you running the mailman gateway on the same machine as the news server?
(Or on another machine that is an NNTP peer of the news server?)

Python's standard nntplib assumes that when it connects it will default to
(NNRP) reader mode.  If the connection ends up in NNTP/news feed mode, many
commands, including "GROUP" will not be recognized.

A quick hack is to add this to your nntplib.py:

diff -u nntplib.py.dist nntplib.py
--- nntplib.py.dist     Tue Apr 28 17:43:35 1998
+++ nntplib.py  Tue Jun 23 22:06:00 1998  
@@ -71,6 +71,10 @@
                self.file = self.sock.makefile('rb')
                self.debugging = 0
                self.welcome = self.getresp()
+               try:
+                   self.welcome = self.shortcmd('mode reader')
+               except:
+                   pass
                if user:
                    resp = self.shortcmd('authinfo user '+user)
                    if resp[:3] == '381':

This makes nntplib use 'mode reader' for all connections.  As Harald Meland
pointed out, this should probably be controlled by adding another optional
argument to nntplib.NNTP(), but if you only use the library with mailman or
in other "client" applications this will suffice.

Jim

P.S. You could also do the 'mode reader' stanza in GatewayManager, but then
you also need to repeat the 'authinfo' code there if your news server needs
authentication, since that must follow the 'mode reader' command.

-- 
Jim Tittsler, Tokyo