AlkantarClanX12

Your IP : 18.217.224.165


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/smtpd.cpython-35.pyc



��Yf-��@s$dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZddddgZejdZd	ZGd
d�d�Ze�adZd
ZdZddd�ZGdd�dej�ZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�Z dd�Z!e"dkr e!�Z#e#j$Z$de$kre$j%d�Z&e'e$de&�e(�e)�dg�Z*e$e&dd�Z$nddl+Z*e,e*e$�Z-e-e#j.e#j/fe#j0e#j1fe#j2de#j3�Z4e#j5r�yddl6Z6Wn2e7k
r�e8d d!ej9�ej:d�YnXe6j;d"�d#Z<yej5e<�Wn2e=k
r�e8d$d!ej9�ej:d�YnXyej>�Wne?k
rYnXdS)%a�An RFC 5321 smtp proxy with optional RFC 1870 and RFC 6531 extensions.

Usage: %(program)s [options] [localhost:localport [remotehost:remoteport]]

Options:

    --nosetuid
    -n
        This program generally tries to setuid `nobody', unless this flag is
        set.  The setuid call will fail if this program is not run as root (in
        which case, use this flag).

    --version
    -V
        Print the version number and exit.

    --class classname
    -c classname
        Use `classname' as the concrete SMTP proxy class.  Uses `PureProxy' by
        default.

    --size limit
    -s limit
        Restrict the total size of the incoming message to "limit" number of
        bytes via the RFC 1870 SIZE extension.  Defaults to 33554432 bytes.

    --smtputf8
    -u
        Enable the SMTPUTF8 extension and behave as an RFC 6531 smtp proxy.

    --debug
    -d
        Turn on debugging prints.

    --help
    -h
        Print this message and exit.

Version: %(__version__)s

If localhost is not given then `localhost' is used, and if localport is not
given then 8025 is used.  If remotehost is not given then `localhost' is used,
and if remoteport is not given, then 25 is used.
�N)�warn)�
get_addr_spec�get_angle_addr�
SMTPServer�DebuggingServer�	PureProxy�MailmanProxyzPython SMTP proxy version 0.3c@s(eZdZdd�Zdd�ZdS)�DevnullcCsdS)N�)�self�msgr
r
�*/opt/alt/python35/lib64/python3.5/smtpd.py�writecsz
Devnull.writecCsdS)Nr
)rr
r
r
�flushdsz
Devnull.flushN)�__name__�
__module__�__qualname__rrr
r
r
r
r	bsr	�
z, i�cCsDttt�dtj�|r3t|dtj�tj|�dS)N�file)�print�__doc__�globals�sys�stderr�exit)�coderr
r
r
�usagemsrc@s�eZdZdZdZdZejedd��Ze	dd��Z
edd	dd
d�Zdd
�Z
dd�Ze	dd��Zejdd��Ze	dd��Zejdd��Ze	dd��Zejdd��Ze	dd��Zejdd��Ze	dd��Zejdd��Ze	dd ��Zejd!d ��Ze	d"d#��Zejd$d#��Ze	d%d&��Zejd'd&��Ze	d(d)��Zejd*d)��Ze	d+d,��Zejd-d,��Ze	d.d/��Zejd0d/��Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dS)S�SMTPChannelr�icCs|S)Nr
)�xr
r
r
�<lambda>yszSMTPChannel.<lambda>cCs7yt|jj��SWntk
r2|jSYnXdS)N)�max�command_size_limits�values�
ValueError�command_size_limit)rr
r
r
�max_command_size_limit{s
z"SMTPChannel.max_command_size_limitNFc	Cs�tjj||d|�||_||_||_||_||_|rd|r^td��d}|dkr�t	dt
d�d}||_|r�d|_d|_
d	|_t|_n*d
|_d|_
td�|_d
|_|j�d|_d|_|jj�tj�|_y|j�|_WnLtk
r}z,|j�|jdtj kri�dSWYdd}~XnXt!dt"|j�dt#�|j$d|jt%f�dS)N�mapzFdecode_data and enable_SMTPUTF8 cannot be set to True at the same timeFzgThe decode_data default of True will change to False in 3.6; specify an explicit value for this keyword�Trz
�.�s
�.s
rzPeer:rz	220 %s %s)&�asynchat�
async_chat�__init__�smtp_server�conn�addr�data_size_limit�enable_SMTPUTF8r%r�DeprecationWarning�_decode_data�_emptystring�_linesep�_dotsep�NEWLINE�_newline�ord�_set_rset_state�
seen_greeting�
extended_smtpr#�clear�socketZgetfqdn�fqdnZgetpeername�peer�OSError�close�args�errnoZENOTCONNr�repr�DEBUGSTREAM�push�__version__)	rZserverr1r2r3r(r4�decode_data�errr
r
r
r/�sL					
							
		

zSMTPChannel.__init__cCsA|j|_d|_g|_d|_d|_|jd�dS)z/Reset state variables to their post-DATA state.NFrs
)�COMMAND�
smtp_state�mailfrom�rcpttos�require_SMTPUTF8�	num_bytes�set_terminator)rr
r
r
�_set_post_data_state�s				z SMTPChannel._set_post_data_statecCs |j�d|_g|_dS)z.Reset all state variables except the greeting.rN)rU�
received_data�received_lines)rr
r
r
r=�s
	zSMTPChannel._set_rset_statecCstdtd�|jS)NzTAccess to __server attribute on SMTPChannel is deprecated, use 'smtp_server' insteadr))rr5r0)rr
r
r
�__server�s
zSMTPChannel.__servercCstdtd�||_dS)NzRSetting __server attribute on SMTPChannel is deprecated, set 'smtp_server' insteadr))rr5r0)r�valuer
r
r
rX�s
cCstdtd�|jS)NzUAccess to __line attribute on SMTPChannel is deprecated, use 'received_lines' insteadr))rr5rW)rr
r
r
�__line�s
zSMTPChannel.__linecCstdtd�||_dS)NzSSetting __line attribute on SMTPChannel is deprecated, set 'received_lines' insteadr))rr5rW)rrYr
r
r
rZ�s
cCstdtd�|jS)NzRAccess to __state attribute on SMTPChannel is deprecated, use 'smtp_state' insteadr))rr5rO)rr
r
r
�__state�s
zSMTPChannel.__statecCstdtd�||_dS)NzPSetting __state attribute on SMTPChannel is deprecated, set 'smtp_state' insteadr))rr5rO)rrYr
r
r
r[�s
cCstdtd�|jS)NzXAccess to __greeting attribute on SMTPChannel is deprecated, use 'seen_greeting' insteadr))rr5r>)rr
r
r
�
__greeting�s
zSMTPChannel.__greetingcCstdtd�||_dS)NzVSetting __greeting attribute on SMTPChannel is deprecated, set 'seen_greeting' insteadr))rr5r>)rrYr
r
r
r\�s
cCstdtd�|jS)NzSAccess to __mailfrom attribute on SMTPChannel is deprecated, use 'mailfrom' insteadr))rr5rP)rr
r
r
�
__mailfrom�s
zSMTPChannel.__mailfromcCstdtd�||_dS)NzQSetting __mailfrom attribute on SMTPChannel is deprecated, set 'mailfrom' insteadr))rr5rP)rrYr
r
r
r]�s
cCstdtd�|jS)NzQAccess to __rcpttos attribute on SMTPChannel is deprecated, use 'rcpttos' insteadr))rr5rQ)rr
r
r
�	__rcpttos�s
zSMTPChannel.__rcpttoscCstdtd�||_dS)NzOSetting __rcpttos attribute on SMTPChannel is deprecated, set 'rcpttos' insteadr))rr5rQ)rrYr
r
r
r^�s
cCstdtd�|jS)NzTAccess to __data attribute on SMTPChannel is deprecated, use 'received_data' insteadr))rr5rV)rr
r
r
�__datas
zSMTPChannel.__datacCstdtd�||_dS)NzRSetting __data attribute on SMTPChannel is deprecated, set 'received_data' insteadr))rr5rV)rrYr
r
r
r_s
cCstdtd�|jS)NzKAccess to __fqdn attribute on SMTPChannel is deprecated, use 'fqdn' insteadr))rr5rB)rr
r
r
�__fqdns
zSMTPChannel.__fqdncCstdtd�||_dS)NzISetting __fqdn attribute on SMTPChannel is deprecated, set 'fqdn' insteadr))rr5rB)rrYr
r
r
r`s
cCstdtd�|jS)NzKAccess to __peer attribute on SMTPChannel is deprecated, use 'peer' insteadr))rr5rC)rr
r
r
�__peers
zSMTPChannel.__peercCstdtd�||_dS)NzISetting __peer attribute on SMTPChannel is deprecated, set 'peer' insteadr))rr5rC)rrYr
r
r
ras
cCstdtd�|jS)NzKAccess to __conn attribute on SMTPChannel is deprecated, use 'conn' insteadr))rr5r1)rr
r
r
�__conn$s
zSMTPChannel.__conncCstdtd�||_dS)NzISetting __conn attribute on SMTPChannel is deprecated, set 'conn' insteadr))rr5r1)rrYr
r
r
rb)s
cCstdtd�|jS)NzKAccess to __addr attribute on SMTPChannel is deprecated, use 'addr' insteadr))rr5r2)rr
r
r
�__addr/s
zSMTPChannel.__addrcCstdtd�||_dS)NzISetting __addr attribute on SMTPChannel is deprecated, set 'addr' insteadr))rr5r2)rrYr
r
r
rc4s
cCs3tjj|t|d|jr%dnd��dS)Nz
zutf-8�ascii)r-r.rJ�bytesrR)rrr
r
r
rJ;szSMTPChannel.pushcCs�d}|j|jkr$|j}n|j|jkr?|j}|rX|j|krXdS|rs|jt|�7_|jr�|jj	t
|d��n|jj	|�dS)Nzutf-8)rOrNr'�DATAr3rS�lenr6rW�append�str)r�data�limitr
r
r
�collect_incoming_data@s		z!SMTPChannel.collect_incoming_datac
Cs�|jj|j�}tdt|�dt�g|_|j|jkrf|jd}|_|ss|j	d�dS|j
s�t|d�}|jd�}|dkr�|j
�}d}n0|d|�j
�}||dd�j�}|jr|j|n|j}||kr'|j	d�dSt|d	|d�}|sX|j	d
|�dS||�dS|j|jkr�|j	d�d|_dS|jr�|j|jkr�|j	d�d|_dSg}xZ|j|j�D]F}	|	r|	d|jkr|j|	dd��q�|j|	�q�W|jj|�|_|j|j|j|jf}
i}|j
s�d
|jd|ji}|j j!|
|�}|j"�|s�|j	d�n
|j	|�dS)NzData:rrz500 Error: bad syntaxzutf-8� rz500 Error: line too longZsmtp_z&500 Error: command "%s" not recognizedz451 Internal confusionz552 Error: Too much mail data�mail_options�rcpt_optionsz250 OK)#r7�joinrWrrHrIrOrNrSrJr6ri�find�upper�stripr?r#r&�getattrrfr3�splitr8r9rhr;rVrCrPrQrnror0�process_messagerU)
r�lineZsz�i�command�argZmax_sz�methodrj�textrF�kwargsZstatusr
r
r
�found_terminatorPsd	
		


	
			
zSMTPChannel.found_terminatorcCs\|s|jd�dS|jr1|jd�dS|j�||_|jd|j�dS)Nz501 Syntax: HELO hostnamez503 Duplicate HELO/EHLOz250 %s)rJr>r=rB)rrzr
r
r
�	smtp_HELO�s
	

	zSMTPChannel.smtp_HELOcCs�|s|jd�dS|jr1|jd�dS|j�||_d|_|jd|j�|jr�|jd|j�|jdd7<|js�|jd�|jr�|jd	�|jdd
7<|jd�dS)Nz501 Syntax: EHLO hostnamez503 Duplicate HELO/EHLOTz250-%sz250-SIZE %s�MAIL�z250-8BITMIMEz250-SMTPUTF8�
z250 HELP)	rJr>r=r?rBr3r#r6r4)rrzr
r
r
�	smtp_EHLO�s&
	

				
	
zSMTPChannel.smtp_EHLOcCs'|r|jd�n
|jd�dS)Nz501 Syntax: NOOPz250 OK)rJ)rrzr
r
r
�	smtp_NOOP�szSMTPChannel.smtp_NOOPcCs|jd�|j�dS)Nz221 Bye)rJZclose_when_done)rrzr
r
r
�	smtp_QUIT�s
zSMTPChannel.smtp_QUITcCs@t|�}|d|�j�|kr<||d�j�SdS)Nr)rgrrrs)r�keywordrzZkeylenr
r
r
�_strip_command_keyword�sz"SMTPChannel._strip_command_keywordcCsc|s
dS|j�jd�r4t|�\}}nt|�\}}|sV||fS|j|fS)Nr�<)rr)�lstrip�
startswithrrZ	addr_spec)rrz�address�restr
r
r
�_getaddr�s
zSMTPChannel._getaddrcCsgi}xZ|D]R}|jd�\}}}|j�sE|rI|rIdS|rU|nd||<q
W|S)N�=T)�	partition�isalnum)r�params�resultZparam�eqrYr
r
r
�
_getparams�s
zSMTPChannel._getparamscCsg|rVd}|j�}|dkr4|jd�qc|dkrP|jd�qc|dkr�d}|jru||7}|j|�qc|dkr�d	}|jr�||7}|j|�qc|d
kr�|jd�qc|dkr�|jd
�qc|dkr|jd�qc|dkr*|jd�qc|dkrF|jd�qc|jd�n
|jd�dS)Nz [SP <mail-parameters>]ZEHLOz250 Syntax: EHLO hostnameZHELOz250 Syntax: HELO hostnamer�z 250 Syntax: MAIL FROM: <address>ZRCPTz250 Syntax: RCPT TO: <address>rfz250 Syntax: DATAZRSETz250 Syntax: RSETZNOOPz250 Syntax: NOOPZQUITz250 Syntax: QUITZVRFYz250 Syntax: VRFY <address>zD501 Supported commands: EHLO HELO MAIL RCPT DATA RSET NOOP QUIT VRFYzD250 Supported commands: EHLO HELO MAIL RCPT DATA RSET NOOP QUIT VRFY)rrrJr?)rrzZextendedZlc_argrr
r
r
�	smtp_HELP�s:	
	
zSMTPChannel.smtp_HELPcCsV|rE|j|�\}}|r1|jd�qR|jd|�n
|jd�dS)NzB252 Cannot VRFY user, but will accept message and attempt deliveryz502 Could not VRFY %sz501 Syntax: VRFY <address>)r�rJ)rrzr�r�r
r
r
�	smtp_VRFY�szSMTPChannel.smtp_VRFYcCse|js|jd�dStd|dt�d}|jrF|d7}|dkrc|j|�dS|jd|�}|j|�\}}|s�|j|�dS|jr�|r�|j|�dS|jr�|jd�dS|j�j	�|_
|j|j
�}|dkr |j|�dS|jsX|j
dd	�}|dkrX|jd�dS|jr�|j
dd
�}|dkr�d|_n|d
k	r�|jd�dS|j
dd�}|r|j�s�|j|�dS|jrt|�|jkr|jd�dSt|j��dkr5|jd�dS||_td|jdt�|jd�dS)Nz503 Error: send HELO firstz	===> MAILrz 501 Syntax: MAIL FROM: <address>z [SP <mail-parameters>]zFROM:z503 Error: nested MAIL commandZBODY�7BIT�8BITMIMEz1501 Error: BODY can only be one of 7BIT, 8BITMIMEZSMTPUTF8FTz&501 Error: SMTPUTF8 takes no argumentsZSIZEz:552 Error: message size exceeds fixed maximum message sizerz:555 MAIL FROM parameters not recognized or not implementedzsender:z250 OK)r�r�)r>rJrrIr?r�r�rPrrrurnr�r6�popr4rR�isdigitr3�intrg�keys)rrz�	syntaxerrr�r�Zbody�smtputf8�sizer
r
r
�	smtp_MAILsh	
	



	

	
	



	zSMTPChannel.smtp_MAILcCs�|js|jd�dStd|dt�|jsG|jd�dSd}|jr`|d7}|dkr}|j|�dS|jd|�}|j|�\}}|s�|j|�dS|jr�|r�|j|�dS|j�j	�|_
|j|j
�}|dkr |j|�dSt|j
��dkrI|jd	�dS|jj|�td
|jdt�|jd�dS)Nz503 Error: send HELO firstz	===> RCPTrz503 Error: need MAIL commandz501 Syntax: RCPT TO: <address>z [SP <mail-parameters>]zTO:rz8555 RCPT TO parameters not recognized or not implementedzrecips:z250 OK)r>rJrrIrPr?r�r�rrruror�rgr�rQrh)rrzr�r�r�r
r
r
�	smtp_RCPT;s@	
	
	





zSMTPChannel.smtp_RCPTcCs2|r|jd�dS|j�|jd�dS)Nz501 Syntax: RSETz250 OK)rJr=)rrzr
r
r
�	smtp_RSET^s


zSMTPChannel.smtp_RSETcCsu|js|jd�dS|js4|jd�dS|rK|jd�dS|j|_|jd�|jd�dS)Nz503 Error: send HELO firstz503 Error: need RCPT commandz501 Syntax: DATAs
.
z#354 End data with <CR><LF>.<CR><LF>)r>rJrQrfrOrT)rrzr
r
r
�	smtp_DATAes	
	


zSMTPChannel.smtp_DATAcCs|jd�dS)Nz502 EXPN not implemented)rJ)rrzr
r
r
�	smtp_EXPNtszSMTPChannel.smtp_EXPN),rrrrNrfr&�collections�defaultdictr#�propertyr'�DATA_SIZE_DEFAULTr/rUr=Z_SMTPChannel__server�setterZ_SMTPChannel__lineZ_SMTPChannel__stateZ_SMTPChannel__greetingZ_SMTPChannel__mailfromZ_SMTPChannel__rcpttosZ_SMTPChannel__dataZ_SMTPChannel__fqdnZ_SMTPChannel__peerZ_SMTPChannel__connZ_SMTPChannel__addrrJrlr~rr�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
r
rts`-	>#6#rc@sFeZdZeZeddddd�Zdd�Zdd�ZdS)	rNFcCs4||_||_||_||_|rB|r<td��d}|dkrdtdtd�d}||_tj	j
|d|�y`tj|dtj
�}|j|dd|dd	�|j�|j|�|jd
�Wn|j��Yn6Xtd|jjtjtj��||fdt�dS)
NzVThe decode_data and enable_SMTPUTF8 parameters cannot be set to True at the same time.FzgThe decode_data default of True will change to False in 3.6; specify an explicit value for this keywordr)Tr(�typerr�z0%s started at %s
	Local addr: %s
	Remote addr:%sr)Z
_localaddr�_remoteaddrr3r4r%rr5r6�asyncore�
dispatcherr/rAZgetaddrinfoZSOCK_STREAMZ
create_socketZset_reuse_addrZbindZlistenrEr�	__class__r�time�ctimerI)rZ	localaddrZ
remoteaddrr3r(r4rLZgai_resultsr
r
r
r/|s6				
	 


zSMTPServer.__init__cCsKtdt|�dt�|j||||j|j|j|j�}dS)NzIncoming connection from %sr)rrHrI�
channel_classr3Z_mapr4r6)rr1r2Zchannelr
r
r
�handle_accepted�s	zSMTPServer.handle_acceptedcKs
t�dS)a8Override this abstract method to handle messages from the client.

        peer is a tuple containing (ipaddr, port) of the client that made the
        socket connection to our smtp port.

        mailfrom is the raw address the client claims the message is coming
        from.

        rcpttos is a list of raw addresses the client wishes to deliver the
        message to.

        data is a string containing the entire full text of the message,
        headers (if supplied) and all.  It has been `de-transparencied'
        according to RFC 821, Section 4.5.2.  In other words, a line
        containing a `.' followed by other text has had the leading dot
        removed.

        kwargs is a dictionary containing additional information. It is empty
        unless decode_data=False or enable_SMTPUTF8=True was given as init
        parameter, in which case ut will contain the following keys:
            'mail_options': list of parameters to the mail command.  All
                            elements are uppercase strings.  Example:
                            ['BODY=8BITMIME', 'SMTPUTF8'].
            'rcpt_options': same, for the rcpt command.

        This function should return None for a normal `250 Ok' response;
        otherwise, it should return the desired response string in RFC 821
        format.

        N)�NotImplementedError)rrCrPrQrjr}r
r
r
rv�szSMTPServer.process_message)	rrrrr�r�r/r�rvr
r
r
r
rxs
"c@s(eZdZdd�Zdd�ZdS)rcCs�d}|j�}x�|D]z}|rn|rnd|d}t|t�s^t|jd��}t|�d}t|t�s�t|�}t|�qWdS)NrzX-Peer: rzutf-8)�
splitlines�
isinstancerirH�encoder)rrCrjZ	inheaders�linesrwZ
peerheaderr
r
r
�_print_message_content�s


z&DebuggingServer._print_message_contentcKsptd�|rR|jd�r1td|d�|jd�rRtd|d�|j||�td�dS)Nz%---------- MESSAGE FOLLOWS ----------rnzmail options: %srozrcpt options: %s
z%------------ END MESSAGE ------------)r�getr�)rrCrPrQrjr}r
r
r
rv�s
zDebuggingServer.process_messageN)rrrr�rvr
r
r
r
r�scs:eZdZ�fdd�Zdd�Zdd�Z�S)rcs?d|kr"|dr"td��tt|�j||�dS)Nr4z$PureProxy does not support SMTPUTF8.)r%�superrr/)rrFr})r�r
r
r/�szPureProxy.__init__c	Cs�|jd�}d}x|D]}|s)P|d7}qW|j|d|d�tj|�}|j|||�}td|dt�dS)Nrrrz
X-Peer: %szwe got some refusals:r)ru�insertr:rp�_deliverrrI)	rrCrPrQrjr�rxrw�refusedr
r
r
rv�s
zPureProxy.process_messagecCs7ddl}i}yU|j�}|j|jd|jd�z|j|||�}Wd|j�XWn�|jk
r�}ztddt�|j	}WYdd}~Xn�t
|jfk
r2}z`td|jdt�t
|dd	�}t
|dd�}	x|D]}
||	f||
<qWWYdd}~XnX|S)
Nrrzgot SMTPRecipientsRefusedrZgotZ	smtp_codeZ
smtp_error�ignore���)�smtplibZSMTPZconnectr�Zsendmail�quitZSMTPRecipientsRefusedrrIZ
recipientsrDZ
SMTPExceptionr�rt)rrPrQrjr�r��s�eZerrcode�errmsg�rr
r
r
r��s$
'zPureProxy._deliver)rrrr/rvr�r
r
)r�r
r�scs.eZdZ�fdd�Zdd�Z�S)rcs?d|kr"|dr"td��tt|�j||�dS)Nr4z'MailmanProxy does not support SMTPUTF8.)r%r�rr/)rrFr})r�r
r
r/szMailmanProxy.__init__cCs�ddlm}ddlm}ddlm}ddlm}g}	x�|D]�}
|
j�jd�d}|jd�}t|�dkr�qM|d}
t|�dkr�|d	}nd
}|j	|
�sM|d!kr�qM|	j
|
|
|f�qMWx$|	D]\}
}
}|j|
�q�Wtddj
|�dt�|ri|j|||�}td|dt�i}||�}|j|�}|jd�s�||d<|jd�s�tjtj��|d<x(|	D] \}
}
}td|
dt�|j|
�}|s(|j|
dd�}|||
<|d
krJ|j|dd	�q�|dkrl|j|dd	�q�|dkr�|j|dd	�q�|d
kr�|j|dd	�q�|d"kr�|dkr�d|d<n
d |d<|j|dd	�q�WdS)#Nr)�StringIO)�Utils)�Message)�MailList�@�-r)rr�admin�owner�requestrp�leavezforwarding recips:rmrzwe got refusals:�fromZFromZdateZDatezsending message to�lock�tolistZtoadminZtoownerZ	torequestZ	subscribeZSubjectZunsubscribe)rr�r�r�rpr�)rpr�)�ior�ZMailmanr�r�r��lowerrurgZlist_existsrh�removerrprIr�r�r�r�ZEnqueue)rrCrPrQrjr�r�r�r�Z	listnamesZrcptZlocal�partsZlistnameryr�Zmlistsr�rZmlistr
r
r
rvsd


	



zMailmanProxy.process_message)rrrr/rvr
r
)r�r
rsc@s(eZdZdZdZdZdZdS)�OptionsTrNF)rrr�setuid�	classname�
size_limitr4r
r
r
r
r�ksr�c
!Cs%yAtjtjdd�dddddddd	g�\}}Wn5tjk
rx}ztd|�WYdd}~XnXt�}x|D]�\}}|d'kr�td�q�|d(kr�tt�tjd�q�|d)kr�d|_	q�|d*kr||_
q�|d+krtjaq�|d,kr4d|_
q�|d-kr�yt|�}||_Wq�td|dtj�tjd�Yq�Xq�Wt|�dkr�d}d}nht|�dkr�|d}d}nCt|�d kr�|d}|d}ntdd!tj|��|jd"�}	|	dkrAtdd#|�|d|	�|_y!t||	dd��|_Wn#tk
r�tdd$|�YnX|jd"�}	|	dkr�tdd%|�|d|	�|_y!t||	dd��|_Wn#tk
r tdd&|�YnX|S).Nrz	nVhc:s:duzclass=Znosetuid�version�helpzsize=�debugr��-h�--helpr�-V�	--version�-n�
--nosetuidF�-c�--class�-d�--debug�-u�
--smtputf8T�-s�--sizezInvalid size: rzlocalhost:8025zlocalhost:25r)�zInvalid arguments: %s�:zBad local spec: %szBad local port: %szBad remote spec: %szBad remote port: %s)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)�getoptr�argv�errorrr�rrKrr�r�rrIr4r�r�rg�
COMMASPACErprq�	localhost�	localportr%�
remotehost�
remoteport)
ZoptsrFr��optionsZoptrzZint_sizeZ	localspecZ
remotespecrxr
r
r
�	parseargsrsp 	


	
	

!
!
r��__main__r*rr4z7Cannot import module "pwd"; try running with -n option.r�nobodyr)z3Cannot setuid "nobody"; try running with -n option.)@rr�osrGr�r�rAr�r-r��warningsrZemail._header_value_parserrr�__all__r�ZprogramrKr	rIr:r�r�rr.rr�rrrrr�r�rr�r��rfindZlastdot�
__import__r�locals�modr�rtZclass_r�r�r�r�r�r4�proxyr��pwd�ImportErrorrrr�getpwnamr��PermissionErrorZloop�KeyboardInterruptr
r
r
r
�<module>-sr#
	��U-SB		(