Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../proc/self/root/usr/bin
File: smtpd2.py
#! /usr/bin/python2.7
[0] Fix | Delete
"""An RFC 2821 smtp proxy.
[1] Fix | Delete
[2] Fix | Delete
Usage: %(program)s [options] [localhost:localport [remotehost:remoteport]]
[3] Fix | Delete
[4] Fix | Delete
Options:
[5] Fix | Delete
[6] Fix | Delete
--nosetuid
[7] Fix | Delete
-n
[8] Fix | Delete
This program generally tries to setuid `nobody', unless this flag is
[9] Fix | Delete
set. The setuid call will fail if this program is not run as root (in
[10] Fix | Delete
which case, use this flag).
[11] Fix | Delete
[12] Fix | Delete
--version
[13] Fix | Delete
-V
[14] Fix | Delete
Print the version number and exit.
[15] Fix | Delete
[16] Fix | Delete
--class classname
[17] Fix | Delete
-c classname
[18] Fix | Delete
Use `classname' as the concrete SMTP proxy class. Uses `PureProxy' by
[19] Fix | Delete
default.
[20] Fix | Delete
[21] Fix | Delete
--debug
[22] Fix | Delete
-d
[23] Fix | Delete
Turn on debugging prints.
[24] Fix | Delete
[25] Fix | Delete
--help
[26] Fix | Delete
-h
[27] Fix | Delete
Print this message and exit.
[28] Fix | Delete
[29] Fix | Delete
Version: %(__version__)s
[30] Fix | Delete
[31] Fix | Delete
If localhost is not given then `localhost' is used, and if localport is not
[32] Fix | Delete
given then 8025 is used. If remotehost is not given then `localhost' is used,
[33] Fix | Delete
and if remoteport is not given, then 25 is used.
[34] Fix | Delete
"""
[35] Fix | Delete
[36] Fix | Delete
# Overview:
[37] Fix | Delete
#
[38] Fix | Delete
# This file implements the minimal SMTP protocol as defined in RFC 821. It
[39] Fix | Delete
# has a hierarchy of classes which implement the backend functionality for the
[40] Fix | Delete
# smtpd. A number of classes are provided:
[41] Fix | Delete
#
[42] Fix | Delete
# SMTPServer - the base class for the backend. Raises NotImplementedError
[43] Fix | Delete
# if you try to use it.
[44] Fix | Delete
#
[45] Fix | Delete
# DebuggingServer - simply prints each message it receives on stdout.
[46] Fix | Delete
#
[47] Fix | Delete
# PureProxy - Proxies all messages to a real smtpd which does final
[48] Fix | Delete
# delivery. One known problem with this class is that it doesn't handle
[49] Fix | Delete
# SMTP errors from the backend server at all. This should be fixed
[50] Fix | Delete
# (contributions are welcome!).
[51] Fix | Delete
#
[52] Fix | Delete
# MailmanProxy - An experimental hack to work with GNU Mailman
[53] Fix | Delete
# <www.list.org>. Using this server as your real incoming smtpd, your
[54] Fix | Delete
# mailhost will automatically recognize and accept mail destined to Mailman
[55] Fix | Delete
# lists when those lists are created. Every message not destined for a list
[56] Fix | Delete
# gets forwarded to a real backend smtpd, as with PureProxy. Again, errors
[57] Fix | Delete
# are not handled correctly yet.
[58] Fix | Delete
#
[59] Fix | Delete
# Please note that this script requires Python 2.0
[60] Fix | Delete
#
[61] Fix | Delete
# Author: Barry Warsaw <barry@python.org>
[62] Fix | Delete
#
[63] Fix | Delete
# TODO:
[64] Fix | Delete
#
[65] Fix | Delete
# - support mailbox delivery
[66] Fix | Delete
# - alias files
[67] Fix | Delete
# - ESMTP
[68] Fix | Delete
# - handle error codes from the backend smtpd
[69] Fix | Delete
[70] Fix | Delete
import sys
[71] Fix | Delete
import os
[72] Fix | Delete
import errno
[73] Fix | Delete
import getopt
[74] Fix | Delete
import time
[75] Fix | Delete
import socket
[76] Fix | Delete
import asyncore
[77] Fix | Delete
import asynchat
[78] Fix | Delete
[79] Fix | Delete
__all__ = ["SMTPServer","DebuggingServer","PureProxy","MailmanProxy"]
[80] Fix | Delete
[81] Fix | Delete
program = sys.argv[0]
[82] Fix | Delete
__version__ = 'Python SMTP proxy version 0.2'
[83] Fix | Delete
[84] Fix | Delete
[85] Fix | Delete
class Devnull:
[86] Fix | Delete
def write(self, msg): pass
[87] Fix | Delete
def flush(self): pass
[88] Fix | Delete
[89] Fix | Delete
[90] Fix | Delete
DEBUGSTREAM = Devnull()
[91] Fix | Delete
NEWLINE = '\n'
[92] Fix | Delete
EMPTYSTRING = ''
[93] Fix | Delete
COMMASPACE = ', '
[94] Fix | Delete
[95] Fix | Delete
[96] Fix | Delete
def usage(code, msg=''):
[97] Fix | Delete
print >> sys.stderr, __doc__ % globals()
[98] Fix | Delete
if msg:
[99] Fix | Delete
print >> sys.stderr, msg
[100] Fix | Delete
sys.exit(code)
[101] Fix | Delete
[102] Fix | Delete
[103] Fix | Delete
class SMTPChannel(asynchat.async_chat):
[104] Fix | Delete
COMMAND = 0
[105] Fix | Delete
DATA = 1
[106] Fix | Delete
[107] Fix | Delete
def __init__(self, server, conn, addr):
[108] Fix | Delete
asynchat.async_chat.__init__(self, conn)
[109] Fix | Delete
self.__server = server
[110] Fix | Delete
self.__conn = conn
[111] Fix | Delete
self.__addr = addr
[112] Fix | Delete
self.__line = []
[113] Fix | Delete
self.__state = self.COMMAND
[114] Fix | Delete
self.__greeting = 0
[115] Fix | Delete
self.__mailfrom = None
[116] Fix | Delete
self.__rcpttos = []
[117] Fix | Delete
self.__data = ''
[118] Fix | Delete
self.__fqdn = socket.getfqdn()
[119] Fix | Delete
try:
[120] Fix | Delete
self.__peer = conn.getpeername()
[121] Fix | Delete
except socket.error, err:
[122] Fix | Delete
# a race condition may occur if the other end is closing
[123] Fix | Delete
# before we can get the peername
[124] Fix | Delete
self.close()
[125] Fix | Delete
if err[0] != errno.ENOTCONN:
[126] Fix | Delete
raise
[127] Fix | Delete
return
[128] Fix | Delete
print >> DEBUGSTREAM, 'Peer:', repr(self.__peer)
[129] Fix | Delete
self.push('220 %s %s' % (self.__fqdn, __version__))
[130] Fix | Delete
self.set_terminator('\r\n')
[131] Fix | Delete
[132] Fix | Delete
# Overrides base class for convenience
[133] Fix | Delete
def push(self, msg):
[134] Fix | Delete
asynchat.async_chat.push(self, msg + '\r\n')
[135] Fix | Delete
[136] Fix | Delete
# Implementation of base class abstract method
[137] Fix | Delete
def collect_incoming_data(self, data):
[138] Fix | Delete
self.__line.append(data)
[139] Fix | Delete
[140] Fix | Delete
# Implementation of base class abstract method
[141] Fix | Delete
def found_terminator(self):
[142] Fix | Delete
line = EMPTYSTRING.join(self.__line)
[143] Fix | Delete
print >> DEBUGSTREAM, 'Data:', repr(line)
[144] Fix | Delete
self.__line = []
[145] Fix | Delete
if self.__state == self.COMMAND:
[146] Fix | Delete
if not line:
[147] Fix | Delete
self.push('500 Error: bad syntax')
[148] Fix | Delete
return
[149] Fix | Delete
method = None
[150] Fix | Delete
i = line.find(' ')
[151] Fix | Delete
if i < 0:
[152] Fix | Delete
command = line.upper()
[153] Fix | Delete
arg = None
[154] Fix | Delete
else:
[155] Fix | Delete
command = line[:i].upper()
[156] Fix | Delete
arg = line[i+1:].strip()
[157] Fix | Delete
method = getattr(self, 'smtp_' + command, None)
[158] Fix | Delete
if not method:
[159] Fix | Delete
self.push('502 Error: command "%s" not implemented' % command)
[160] Fix | Delete
return
[161] Fix | Delete
method(arg)
[162] Fix | Delete
return
[163] Fix | Delete
else:
[164] Fix | Delete
if self.__state != self.DATA:
[165] Fix | Delete
self.push('451 Internal confusion')
[166] Fix | Delete
return
[167] Fix | Delete
# Remove extraneous carriage returns and de-transparency according
[168] Fix | Delete
# to RFC 821, Section 4.5.2.
[169] Fix | Delete
data = []
[170] Fix | Delete
for text in line.split('\r\n'):
[171] Fix | Delete
if text and text[0] == '.':
[172] Fix | Delete
data.append(text[1:])
[173] Fix | Delete
else:
[174] Fix | Delete
data.append(text)
[175] Fix | Delete
self.__data = NEWLINE.join(data)
[176] Fix | Delete
status = self.__server.process_message(self.__peer,
[177] Fix | Delete
self.__mailfrom,
[178] Fix | Delete
self.__rcpttos,
[179] Fix | Delete
self.__data)
[180] Fix | Delete
self.__rcpttos = []
[181] Fix | Delete
self.__mailfrom = None
[182] Fix | Delete
self.__state = self.COMMAND
[183] Fix | Delete
self.set_terminator('\r\n')
[184] Fix | Delete
if not status:
[185] Fix | Delete
self.push('250 Ok')
[186] Fix | Delete
else:
[187] Fix | Delete
self.push(status)
[188] Fix | Delete
[189] Fix | Delete
# SMTP and ESMTP commands
[190] Fix | Delete
def smtp_HELO(self, arg):
[191] Fix | Delete
if not arg:
[192] Fix | Delete
self.push('501 Syntax: HELO hostname')
[193] Fix | Delete
return
[194] Fix | Delete
if self.__greeting:
[195] Fix | Delete
self.push('503 Duplicate HELO/EHLO')
[196] Fix | Delete
else:
[197] Fix | Delete
self.__greeting = arg
[198] Fix | Delete
self.push('250 %s' % self.__fqdn)
[199] Fix | Delete
[200] Fix | Delete
def smtp_NOOP(self, arg):
[201] Fix | Delete
if arg:
[202] Fix | Delete
self.push('501 Syntax: NOOP')
[203] Fix | Delete
else:
[204] Fix | Delete
self.push('250 Ok')
[205] Fix | Delete
[206] Fix | Delete
def smtp_QUIT(self, arg):
[207] Fix | Delete
# args is ignored
[208] Fix | Delete
self.push('221 Bye')
[209] Fix | Delete
self.close_when_done()
[210] Fix | Delete
[211] Fix | Delete
# factored
[212] Fix | Delete
def __getaddr(self, keyword, arg):
[213] Fix | Delete
address = None
[214] Fix | Delete
keylen = len(keyword)
[215] Fix | Delete
if arg[:keylen].upper() == keyword:
[216] Fix | Delete
address = arg[keylen:].strip()
[217] Fix | Delete
if not address:
[218] Fix | Delete
pass
[219] Fix | Delete
elif address[0] == '<' and address[-1] == '>' and address != '<>':
[220] Fix | Delete
# Addresses can be in the form <person@dom.com> but watch out
[221] Fix | Delete
# for null address, e.g. <>
[222] Fix | Delete
address = address[1:-1]
[223] Fix | Delete
return address
[224] Fix | Delete
[225] Fix | Delete
def smtp_MAIL(self, arg):
[226] Fix | Delete
print >> DEBUGSTREAM, '===> MAIL', arg
[227] Fix | Delete
address = self.__getaddr('FROM:', arg) if arg else None
[228] Fix | Delete
if not address:
[229] Fix | Delete
self.push('501 Syntax: MAIL FROM:<address>')
[230] Fix | Delete
return
[231] Fix | Delete
if self.__mailfrom:
[232] Fix | Delete
self.push('503 Error: nested MAIL command')
[233] Fix | Delete
return
[234] Fix | Delete
self.__mailfrom = address
[235] Fix | Delete
print >> DEBUGSTREAM, 'sender:', self.__mailfrom
[236] Fix | Delete
self.push('250 Ok')
[237] Fix | Delete
[238] Fix | Delete
def smtp_RCPT(self, arg):
[239] Fix | Delete
print >> DEBUGSTREAM, '===> RCPT', arg
[240] Fix | Delete
if not self.__mailfrom:
[241] Fix | Delete
self.push('503 Error: need MAIL command')
[242] Fix | Delete
return
[243] Fix | Delete
address = self.__getaddr('TO:', arg) if arg else None
[244] Fix | Delete
if not address:
[245] Fix | Delete
self.push('501 Syntax: RCPT TO: <address>')
[246] Fix | Delete
return
[247] Fix | Delete
self.__rcpttos.append(address)
[248] Fix | Delete
print >> DEBUGSTREAM, 'recips:', self.__rcpttos
[249] Fix | Delete
self.push('250 Ok')
[250] Fix | Delete
[251] Fix | Delete
def smtp_RSET(self, arg):
[252] Fix | Delete
if arg:
[253] Fix | Delete
self.push('501 Syntax: RSET')
[254] Fix | Delete
return
[255] Fix | Delete
# Resets the sender, recipients, and data, but not the greeting
[256] Fix | Delete
self.__mailfrom = None
[257] Fix | Delete
self.__rcpttos = []
[258] Fix | Delete
self.__data = ''
[259] Fix | Delete
self.__state = self.COMMAND
[260] Fix | Delete
self.push('250 Ok')
[261] Fix | Delete
[262] Fix | Delete
def smtp_DATA(self, arg):
[263] Fix | Delete
if not self.__rcpttos:
[264] Fix | Delete
self.push('503 Error: need RCPT command')
[265] Fix | Delete
return
[266] Fix | Delete
if arg:
[267] Fix | Delete
self.push('501 Syntax: DATA')
[268] Fix | Delete
return
[269] Fix | Delete
self.__state = self.DATA
[270] Fix | Delete
self.set_terminator('\r\n.\r\n')
[271] Fix | Delete
self.push('354 End data with <CR><LF>.<CR><LF>')
[272] Fix | Delete
[273] Fix | Delete
[274] Fix | Delete
class SMTPServer(asyncore.dispatcher):
[275] Fix | Delete
def __init__(self, localaddr, remoteaddr):
[276] Fix | Delete
self._localaddr = localaddr
[277] Fix | Delete
self._remoteaddr = remoteaddr
[278] Fix | Delete
asyncore.dispatcher.__init__(self)
[279] Fix | Delete
try:
[280] Fix | Delete
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
[281] Fix | Delete
# try to re-use a server port if possible
[282] Fix | Delete
self.set_reuse_addr()
[283] Fix | Delete
self.bind(localaddr)
[284] Fix | Delete
self.listen(5)
[285] Fix | Delete
except:
[286] Fix | Delete
# cleanup asyncore.socket_map before raising
[287] Fix | Delete
self.close()
[288] Fix | Delete
raise
[289] Fix | Delete
else:
[290] Fix | Delete
print >> DEBUGSTREAM, \
[291] Fix | Delete
'%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % (
[292] Fix | Delete
self.__class__.__name__, time.ctime(time.time()),
[293] Fix | Delete
localaddr, remoteaddr)
[294] Fix | Delete
[295] Fix | Delete
def handle_accept(self):
[296] Fix | Delete
pair = self.accept()
[297] Fix | Delete
if pair is not None:
[298] Fix | Delete
conn, addr = pair
[299] Fix | Delete
print >> DEBUGSTREAM, 'Incoming connection from %s' % repr(addr)
[300] Fix | Delete
channel = SMTPChannel(self, conn, addr)
[301] Fix | Delete
[302] Fix | Delete
# API for "doing something useful with the message"
[303] Fix | Delete
def process_message(self, peer, mailfrom, rcpttos, data):
[304] Fix | Delete
"""Override this abstract method to handle messages from the client.
[305] Fix | Delete
[306] Fix | Delete
peer is a tuple containing (ipaddr, port) of the client that made the
[307] Fix | Delete
socket connection to our smtp port.
[308] Fix | Delete
[309] Fix | Delete
mailfrom is the raw address the client claims the message is coming
[310] Fix | Delete
from.
[311] Fix | Delete
[312] Fix | Delete
rcpttos is a list of raw addresses the client wishes to deliver the
[313] Fix | Delete
message to.
[314] Fix | Delete
[315] Fix | Delete
data is a string containing the entire full text of the message,
[316] Fix | Delete
headers (if supplied) and all. It has been `de-transparencied'
[317] Fix | Delete
according to RFC 821, Section 4.5.2. In other words, a line
[318] Fix | Delete
containing a `.' followed by other text has had the leading dot
[319] Fix | Delete
removed.
[320] Fix | Delete
[321] Fix | Delete
This function should return None, for a normal `250 Ok' response;
[322] Fix | Delete
otherwise it returns the desired response string in RFC 821 format.
[323] Fix | Delete
[324] Fix | Delete
"""
[325] Fix | Delete
raise NotImplementedError
[326] Fix | Delete
[327] Fix | Delete
[328] Fix | Delete
class DebuggingServer(SMTPServer):
[329] Fix | Delete
# Do something with the gathered message
[330] Fix | Delete
def process_message(self, peer, mailfrom, rcpttos, data):
[331] Fix | Delete
inheaders = 1
[332] Fix | Delete
lines = data.split('\n')
[333] Fix | Delete
print '---------- MESSAGE FOLLOWS ----------'
[334] Fix | Delete
for line in lines:
[335] Fix | Delete
# headers first
[336] Fix | Delete
if inheaders and not line:
[337] Fix | Delete
print 'X-Peer:', peer[0]
[338] Fix | Delete
inheaders = 0
[339] Fix | Delete
print line
[340] Fix | Delete
print '------------ END MESSAGE ------------'
[341] Fix | Delete
[342] Fix | Delete
[343] Fix | Delete
class PureProxy(SMTPServer):
[344] Fix | Delete
def process_message(self, peer, mailfrom, rcpttos, data):
[345] Fix | Delete
lines = data.split('\n')
[346] Fix | Delete
# Look for the last header
[347] Fix | Delete
i = 0
[348] Fix | Delete
for line in lines:
[349] Fix | Delete
if not line:
[350] Fix | Delete
break
[351] Fix | Delete
i += 1
[352] Fix | Delete
lines.insert(i, 'X-Peer: %s' % peer[0])
[353] Fix | Delete
data = NEWLINE.join(lines)
[354] Fix | Delete
refused = self._deliver(mailfrom, rcpttos, data)
[355] Fix | Delete
# TBD: what to do with refused addresses?
[356] Fix | Delete
print >> DEBUGSTREAM, 'we got some refusals:', refused
[357] Fix | Delete
[358] Fix | Delete
def _deliver(self, mailfrom, rcpttos, data):
[359] Fix | Delete
import smtplib
[360] Fix | Delete
refused = {}
[361] Fix | Delete
try:
[362] Fix | Delete
s = smtplib.SMTP()
[363] Fix | Delete
s.connect(self._remoteaddr[0], self._remoteaddr[1])
[364] Fix | Delete
try:
[365] Fix | Delete
refused = s.sendmail(mailfrom, rcpttos, data)
[366] Fix | Delete
finally:
[367] Fix | Delete
s.quit()
[368] Fix | Delete
except smtplib.SMTPRecipientsRefused, e:
[369] Fix | Delete
print >> DEBUGSTREAM, 'got SMTPRecipientsRefused'
[370] Fix | Delete
refused = e.recipients
[371] Fix | Delete
except (socket.error, smtplib.SMTPException), e:
[372] Fix | Delete
print >> DEBUGSTREAM, 'got', e.__class__
[373] Fix | Delete
# All recipients were refused. If the exception had an associated
[374] Fix | Delete
# error code, use it. Otherwise,fake it with a non-triggering
[375] Fix | Delete
# exception code.
[376] Fix | Delete
errcode = getattr(e, 'smtp_code', -1)
[377] Fix | Delete
errmsg = getattr(e, 'smtp_error', 'ignore')
[378] Fix | Delete
for r in rcpttos:
[379] Fix | Delete
refused[r] = (errcode, errmsg)
[380] Fix | Delete
return refused
[381] Fix | Delete
[382] Fix | Delete
[383] Fix | Delete
class MailmanProxy(PureProxy):
[384] Fix | Delete
def process_message(self, peer, mailfrom, rcpttos, data):
[385] Fix | Delete
from cStringIO import StringIO
[386] Fix | Delete
from Mailman import Utils
[387] Fix | Delete
from Mailman import Message
[388] Fix | Delete
from Mailman import MailList
[389] Fix | Delete
# If the message is to a Mailman mailing list, then we'll invoke the
[390] Fix | Delete
# Mailman script directly, without going through the real smtpd.
[391] Fix | Delete
# Otherwise we'll forward it to the local proxy for disposition.
[392] Fix | Delete
listnames = []
[393] Fix | Delete
for rcpt in rcpttos:
[394] Fix | Delete
local = rcpt.lower().split('@')[0]
[395] Fix | Delete
# We allow the following variations on the theme
[396] Fix | Delete
# listname
[397] Fix | Delete
# listname-admin
[398] Fix | Delete
# listname-owner
[399] Fix | Delete
# listname-request
[400] Fix | Delete
# listname-join
[401] Fix | Delete
# listname-leave
[402] Fix | Delete
parts = local.split('-')
[403] Fix | Delete
if len(parts) > 2:
[404] Fix | Delete
continue
[405] Fix | Delete
listname = parts[0]
[406] Fix | Delete
if len(parts) == 2:
[407] Fix | Delete
command = parts[1]
[408] Fix | Delete
else:
[409] Fix | Delete
command = ''
[410] Fix | Delete
if not Utils.list_exists(listname) or command not in (
[411] Fix | Delete
'', 'admin', 'owner', 'request', 'join', 'leave'):
[412] Fix | Delete
continue
[413] Fix | Delete
listnames.append((rcpt, listname, command))
[414] Fix | Delete
# Remove all list recipients from rcpttos and forward what we're not
[415] Fix | Delete
# going to take care of ourselves. Linear removal should be fine
[416] Fix | Delete
# since we don't expect a large number of recipients.
[417] Fix | Delete
for rcpt, listname, command in listnames:
[418] Fix | Delete
rcpttos.remove(rcpt)
[419] Fix | Delete
# If there's any non-list destined recipients left,
[420] Fix | Delete
print >> DEBUGSTREAM, 'forwarding recips:', ' '.join(rcpttos)
[421] Fix | Delete
if rcpttos:
[422] Fix | Delete
refused = self._deliver(mailfrom, rcpttos, data)
[423] Fix | Delete
# TBD: what to do with refused addresses?
[424] Fix | Delete
print >> DEBUGSTREAM, 'we got refusals:', refused
[425] Fix | Delete
# Now deliver directly to the list commands
[426] Fix | Delete
mlists = {}
[427] Fix | Delete
s = StringIO(data)
[428] Fix | Delete
msg = Message.Message(s)
[429] Fix | Delete
# These headers are required for the proper execution of Mailman. All
[430] Fix | Delete
# MTAs in existence seem to add these if the original message doesn't
[431] Fix | Delete
# have them.
[432] Fix | Delete
if not msg.getheader('from'):
[433] Fix | Delete
msg['From'] = mailfrom
[434] Fix | Delete
if not msg.getheader('date'):
[435] Fix | Delete
msg['Date'] = time.ctime(time.time())
[436] Fix | Delete
for rcpt, listname, command in listnames:
[437] Fix | Delete
print >> DEBUGSTREAM, 'sending message to', rcpt
[438] Fix | Delete
mlist = mlists.get(listname)
[439] Fix | Delete
if not mlist:
[440] Fix | Delete
mlist = MailList.MailList(listname, lock=0)
[441] Fix | Delete
mlists[listname] = mlist
[442] Fix | Delete
# dispatch on the type of command
[443] Fix | Delete
if command == '':
[444] Fix | Delete
# post
[445] Fix | Delete
msg.Enqueue(mlist, tolist=1)
[446] Fix | Delete
elif command == 'admin':
[447] Fix | Delete
msg.Enqueue(mlist, toadmin=1)
[448] Fix | Delete
elif command == 'owner':
[449] Fix | Delete
msg.Enqueue(mlist, toowner=1)
[450] Fix | Delete
elif command == 'request':
[451] Fix | Delete
msg.Enqueue(mlist, torequest=1)
[452] Fix | Delete
elif command in ('join', 'leave'):
[453] Fix | Delete
# TBD: this is a hack!
[454] Fix | Delete
if command == 'join':
[455] Fix | Delete
msg['Subject'] = 'subscribe'
[456] Fix | Delete
else:
[457] Fix | Delete
msg['Subject'] = 'unsubscribe'
[458] Fix | Delete
msg.Enqueue(mlist, torequest=1)
[459] Fix | Delete
[460] Fix | Delete
[461] Fix | Delete
class Options:
[462] Fix | Delete
setuid = 1
[463] Fix | Delete
classname = 'PureProxy'
[464] Fix | Delete
[465] Fix | Delete
[466] Fix | Delete
def parseargs():
[467] Fix | Delete
global DEBUGSTREAM
[468] Fix | Delete
try:
[469] Fix | Delete
opts, args = getopt.getopt(
[470] Fix | Delete
sys.argv[1:], 'nVhc:d',
[471] Fix | Delete
['class=', 'nosetuid', 'version', 'help', 'debug'])
[472] Fix | Delete
except getopt.error, e:
[473] Fix | Delete
usage(1, e)
[474] Fix | Delete
[475] Fix | Delete
options = Options()
[476] Fix | Delete
for opt, arg in opts:
[477] Fix | Delete
if opt in ('-h', '--help'):
[478] Fix | Delete
usage(0)
[479] Fix | Delete
elif opt in ('-V', '--version'):
[480] Fix | Delete
print >> sys.stderr, __version__
[481] Fix | Delete
sys.exit(0)
[482] Fix | Delete
elif opt in ('-n', '--nosetuid'):
[483] Fix | Delete
options.setuid = 0
[484] Fix | Delete
elif opt in ('-c', '--class'):
[485] Fix | Delete
options.classname = arg
[486] Fix | Delete
elif opt in ('-d', '--debug'):
[487] Fix | Delete
DEBUGSTREAM = sys.stderr
[488] Fix | Delete
[489] Fix | Delete
# parse the rest of the arguments
[490] Fix | Delete
if len(args) < 1:
[491] Fix | Delete
localspec = 'localhost:8025'
[492] Fix | Delete
remotespec = 'localhost:25'
[493] Fix | Delete
elif len(args) < 2:
[494] Fix | Delete
localspec = args[0]
[495] Fix | Delete
remotespec = 'localhost:25'
[496] Fix | Delete
elif len(args) < 3:
[497] Fix | Delete
localspec = args[0]
[498] Fix | Delete
remotespec = args[1]
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function