[Mailman-Developers] Bug#57596: mailman: Here we go again... post: nntplib.error_perm : 500 "POST" not implemented; try "help". (fwd)

Thomas Wouters thomas@xs4all.net
Sun, 13 Feb 2000 15:29:51 +0100


--oC1+HKm2/end4ao3
Content-Type: text/plain; charset=us-ascii

On Wed, Feb 09, 2000 at 11:36:41AM +0100, Gergely Madarasz wrote:

> Package: mailman
> Version: 1.1-2
> Severity: important
> 
> Feb 09 03:47:55 2000 post: Traceback (innermost last):
> post:   File "/var/lib/mailman/scripts/post", line 73, in ?
> post:      mlist.Post(msg, approved=fromusenet)
> post:   File "/usr/lib/mailman/Mailman/MailList.py", line 1331, in Post
> post:      self.SendMailToNewsGroup(msg)
> post:   File "/usr/lib/mailman/Mailman/GatewayManager.py", line 204, in SendMailToNewsGroup
> post:      con.post(msg)
> post:   File "/usr/lib/python1.5/nntplib.py", line 417, in post
> post:      resp = self.shortcmd('POST')
> post:   File "/usr/lib/python1.5/nntplib.py", line 158, in shortcmd
> post:      return self.getresp()
> post:   File "/usr/lib/python1.5/nntplib.py", line 134, in getresp
> post:      raise error_perm, resp

> Gatewaying seems completely broken.

Indeed. I'm not sure what kind of newsserver is being used, but apparently
it doesn't even do POSTing without 'mode reader' first. This is different
from the setup we use, so I'm not sure what other commands are tricky to
try.

There are three possible fixes:

- Hack around it in mailman like we did in gate_news (by catching the
error_perm and doing a 'mode reader' at that time)

- backporting the newest nntplib from the python cvs tree to the
Mailman/pythonlib and explicitly importing that copy

- wrapping the nntplib.NNTP constructor with something that sends 'mode
reader' and possibly resends authentication data, before releasing the
object to the caller.

fix #1 is ok for a quick-fix in one or two places (diff attached) but not a
very good mailman-wide solution. I'm not sure which of #2 or #3 is better, i
believe Barry prefers #2 (or so he said ;) but i think wrapping nntplib.NNTP
might be more maintainable. On the other hand, Mailman does not currently
use any kind of authentication, so maybe #1 is the best (easiest) fix after
all.

The good news is, nntplib is only used in two places, cron/gate_news and
Mailman/GatewayManager.py (Mailman/Handlers/ToUsenet.py in 1.2-cvs) so when
this fix is applied, all NNTP problems should be solved... honest ;)

(Attached: 2 diffs, one for mailman 1.1, and one for the current CVS tree.
Barry or another Cabal member can figure out what is the proper fix, and
implement or apply the right fix.)

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!

--oC1+HKm2/end4ao3
Content-Type: text/plain; charset=us-ascii
Content-Description: mailman-1.2-cvs.ToUsenet.py.diff
Content-Disposition: attachment; filename="mailman.cvs.diff"

Index: Mailman/Handlers/ToUsenet.py
===================================================================
RCS file: /projects/cvsroot/mailman/Mailman/Handlers/ToUsenet.py,v
retrieving revision 1.5
diff -u -r1.5 ToUsenet.py
--- ToUsenet.py	2000/01/21 20:28:45	1.5
+++ ToUsenet.py	2000/02/13 13:55:05
@@ -126,7 +126,12 @@
     conn = nntplib.NNTP(mlist.nntp_host)
     try:
         try:
-            conn.post(fp)
+            try:
+                conn.post(fp)
+            except nntplib.error_perm:
+                conn.shortcmd("mode reader")
+                fp.seek(0)  # Rewind in case the failed post read some of it.
+                conn.post(fp)
         except nntplib.error_temp, e:
             sys.stderr.write('encountered NNTP error for list %s\n' %
                              mlist.internal_name())

--oC1+HKm2/end4ao3
Content-Type: text/plain; charset=us-ascii
Content-Description: mailman-1.1.GatewayManager.py.diff
Content-Disposition: attachment; filename="mailman.diff"

--- Mailman/GatewayManager.py.orig	Sun Feb 13 14:19:59 2000
+++ Mailman/GatewayManager.py	Sun Feb 13 14:20:50 2000
@@ -201,6 +201,10 @@
                 if i <> -1 and line[i+1] <> ' ':
                     msg.headers[n] = line[:i+1] + ' ' + line[i+1:]
             con = nntplib.NNTP(self.nntp_host)
-            con.post(msg)
+            try:
+                con.post(msg)
+            except nntplib.error_perm:
+                con.shortcmd("mode reader")
+                con.post(msg)
             con.quit()
             os._exit(0)

--oC1+HKm2/end4ao3--