[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Merge changes from 0-0-5-patches branch.
Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv22126/lib/mixminion/server
Modified Files:
Modules.py
Log Message:
Merge changes from 0-0-5-patches branch.
Original commit message:
Modules:
Fix a bug where socket errors from smtplib would crash the
server. (If your smtp server was down, it would take mixminion
with it.)
ClientMain, ServerInfo, test, Modules:
Make "From" address support optional.
[Rationale: Previously, I'd argued for having only a single
supported "From" policy, as a measure to prevent linkability
based on client option preferences. Adam Back correctly pointed
out that this is silly. Consider that _any_ use or non-use of
From addresses makes messages linkable *in itself*. In other
words, Eve can already tell which messages set their from
addresses; she gains nothing by learning that those messages
have chosen an exit node with From support to do so.]
Some admins have been hesitant to support "From," even in the
limited form described in the spec. I still hope that it will
eventually prove itself to be relatively harmless, but given the
low number of Type I/II exits with *any* from support, it does
make sense to give both options a try (at least) for now.
Index: Modules.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/Modules.py,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- Modules.py 31 Aug 2003 19:29:29 -0000 1.54
+++ Modules.py 12 Sep 2003 15:52:46 -0000 1.55
@@ -862,6 +862,7 @@
# headers from body.
# maxMessageSize: Largest allowable size (after decompression, before
# base64) for outgoing messages.
+ # allowFromAddr: Boolean: do we support user-supplied from addresses?
def _formatEmailMessage(self, address, packet):
"""Given a RFC822 mailbox (delivery address), and an instance of
DeliveryMessage, return a string containing a message to be sent
@@ -876,7 +877,7 @@
headers = packet.getHeaders()
subject = headers.get("SUBJECT", self.subject)
fromAddr = headers.get("FROM")
- if fromAddr:
+ if fromAddr and self.allowFromAddr:
fromAddr = '"%s %s" <%s>' % (self.fromTag, fromAddr,
self.returnAddress)
else:
@@ -936,6 +937,7 @@
'AddressFile' : ('ALLOW', None, None),
'ReturnAddress' : ('ALLOW', None, None),
'RemoveContact' : ('ALLOW', None, None),
+ 'AllowFromAddress' : ('ALLOW', _parseBoolean, 'yes'),
'SMTPServer' : ('ALLOW', None, 'localhost'),
'MaximumSize' : ('ALLOW', _parseSize, "100K"),
}
@@ -970,6 +972,7 @@
self.returnAddress = sec['ReturnAddress']
self.contact = sec['RemoveContact']
self.retrySchedule = sec['Retry']
+ self.allowFromAddr = sec['AllowFromAddress']
# validate should have caught these.
assert (self.server and self.addressFile and self.returnAddress
and self.contact)
@@ -1021,10 +1024,15 @@
moduleManager.enableModule(self)
def getServerInfoBlock(self):
+ if self.allowFromAddr:
+ allowFrom = "yes"
+ else:
+ allowFrom = "no"
return """\
[Delivery/MBOX]
Version: 0.1
- """
+ Allow-From: %s
+ """ % (allowFrom)
def getName(self):
return "MBOX"
@@ -1057,8 +1065,13 @@
def __init__(self):
DeliveryModule.__init__(self)
def getServerInfoBlock(self):
- return "[Delivery/SMTP]\nVersion: 0.1\nMaximum-Size: %s\n" % (
- ceilDiv(self.maxMessageSize,1024) )
+ if self.allowFromAddr:
+ allowFrom = "yes"
+ else:
+ allowFrom = "no"
+ return ("[Delivery/SMTP]\nVersion: 0.1\n"
+ "Maximum-Size: %s\nAllow-From: %s\n") % (
+ ceilDiv(self.maxMessageSize,1024), allowFrom)
def getName(self):
return "SMTP"
def getExitTypes(self):
@@ -1089,6 +1102,7 @@
"7 hours for 6 days"),
'BlacklistFile' : ('ALLOW', None, None),
'SMTPServer' : ('ALLOW', None, 'localhost'),
+ 'AllowFromAddress': ('ALLOW', _parseBoolean, "yes"),
'Message' : ('ALLOW', None, ""),
'ReturnAddress': ('ALLOW', None, None), #Required on e
'FromTag' : ('ALLOW', None, "[Anon]"),
@@ -1130,6 +1144,7 @@
self.subject = sec['SubjectLine']
self.returnAddress = sec['ReturnAddress']
self.fromTag = sec.get('FromTag', "[Anon]")
+ self.allowFromAddr = sec['AllowFromAddress']
if message:
self.header = "X-Anonymous: yes\n\n%s" %(message)
else:
@@ -1200,6 +1215,7 @@
'SubjectLine' : ('ALLOW', None,
'Type III Anonymous Message'),
'MaximumSize' : ('ALLOW', _parseSize, "100K"),
+ 'AllowFromAddress' : ('ALLOW', _parseBoolean, "yes"),
}
}
@@ -1220,6 +1236,7 @@
self.subject = sec['SubjectLine']
self.retrySchedule = sec['Retry']
self.fromTag = sec.get('FromTag', "[Anon]")
+ self.allowFromAddr = sec['AllowFromAddress']
self.command = cmd[0]
self.options = tuple(cmd[1]) + ("-l", self.server)
self.returnAddress = "nobody"
@@ -1310,8 +1327,9 @@
try:
con.sendmail(fromAddr, toList, message)
res = DELIVER_OK
- except smtplib.SMTPException, e:
- LOG.warn("Unsuccessful smtp: "+str(e))
+ except (smtplib.SMTPException, socket.error), e:
+ LOG.warn("Unsuccessful SMTP connection to %s: %s",
+ server, str(e))
res = DELIVER_FAIL_RETRY
con.quit()