inject: Ditch preline.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 28 Mar 2006 12:23:59 +0000 (13:23 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 28 Mar 2006 12:23:59 +0000 (13:23 +0100)
Preline causes strange broken-pipe errors which hide our rejections.
Kill it, and insert the appropriate headers by hand.

bin/inject
config

index 3d7c65d..f6e360b 100755 (executable)
@@ -7,6 +7,7 @@ import socket as S
 from getopt import getopt, GetoptError
 from sys import stdin, stdout, stderr, argv, exit
 from cStringIO import StringIO
+env = OS.environ
 
 prog = argv[0]
 
@@ -51,13 +52,16 @@ except:
   host = 'localhost'
 dist = 'mail'
 path = 'newsgate'
+sender = env.get('SENDER')
+recip = env.get('RECIPIENT')
 group = None
 
 def opts():
-  global approved, remote, host, dist, path, group
+  global approved, remote, host, dist, path, group, sender, recip
   try:
-    opts, args = getopt(argv[1:], 'a:d:h:r:p:',
+    opts, args = getopt(argv[1:], 'a:d:h:r:p:S:R:',
                         ['approved=', 'distribution=',
+                         'sender=', 'recipient=',
                          'hostname=', 'remote=', 'path='])
   except GetoptError:
     usage()
@@ -70,6 +74,10 @@ def opts():
       host = a
     elif o in ('-r', '--remote'):
       remote = (lambda addr, port = 119: (addr, int(port)))(*a.split(':'))
+    elif o in ('-R', '--recipient'):
+      recip = a
+    elif o in ('-S', '--sender'):
+      sender = a
   if len(args) != 1:
     usage()
   group, = args
@@ -106,6 +114,8 @@ def send():
             'Newsgroups: %s\r\n'
             % group)
   if approved: hdr.write('Approved: %s\r\n' % approved)
+  if sender: hdr.write('Return-Path: <%s>\r\n' % sender)
+  if recip: hdr.write('Delivered-To: %s\r\n' % recip)
   xify = {}
   for h in '''
     lines xref newsgroups path distribution approved received
diff --git a/config b/config
index 06366fb..ec2d0df 100644 (file)
--- a/config
+++ b/config
@@ -15,7 +15,7 @@ admin: root
 
 [post-default]
 #? addrcheck
-|preline -f bin/post "$DEFAULT"
+|bin/post "$DEFAULT"
 
 [mail-default]
 #? addrcheck