AlkantarClanX12

Your IP : 3.138.114.140


Current Path : /usr/lib64/python3.6/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/__pycache__/smtpd.cpython-36.pyc

3


 \���@s^dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZddddd	gZejdZd
ZGdd�d�Ze�ad
ZdZdZd%dd�ZGdd�dej�ZGdd�dej�ZGdd�de�ZGdd�de�ZGdd	�d	e�ZGdd�d�Z dd�Z!e"dk�rZe!�Z#e#j$Z$de$k�rpe$j%d�Z&e'e$de&�e(�e)�dg�Z*e$e&dd�Z$nddl+Z*e,e*e$�Z-e-e#j.e#j/fe#j0e#j1fe#j2e#j3d�Z4e#j5�r6yddl6Z6Wn.e7k
�r�e8d ej9d!�ej:d�YnXe6j;d"�d#Z<yej5e<�Wn.e=k
�r4e8d$ej9d!�ej:d�YnXyej>�Wne?k
�rXYnXdS)&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�SMTPChannel�
SMTPServer�DebuggingServer�	PureProxy�MailmanProxyzPython SMTP proxy version 0.3c@seZdZdd�Zdd�ZdS)�DevnullcCsdS)N�)�self�msgrr�/usr/lib64/python3.6/smtpd.py�writefsz
Devnull.writecCsdS)Nr)rrrr�flushgsz
Devnull.flushN)�__name__�
__module__�__qualname__rrrrrrr
esr
�
z, i�cCs4ttt�tjd�|r&t|tjd�tj|�dS)N)�file)�print�__doc__�globals�sys�stderr�exit)�coder
rrr�usagepsrc@s�eZdZdZdZdZejefdd��Ze	dd��Z
edd	d	fd
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)Srr�icCs|S)Nr)�xrrr�<lambda>|szSMTPChannel.<lambda>cCs*yt|jj��Stk
r$|jSXdS)N)�max�command_size_limits�values�
ValueError�command_size_limit)rrrr�max_command_size_limit~sz"SMTPChannel.max_command_size_limitNFc	Cstjj|||d�||_||_||_||_||_||_|rF|rFt	d��|rdd|_
d|_d|_t
|_nd|_
d|_td�|_d	|_|j�d|_d
|_|jj�tj�|_y|j�|_Wn:tk
r�}z|j�|jdtjkr�dSd}~XnXtdt |j�t!d
�|j"d|jt#f�dS)N)�mapzFdecode_data and enable_SMTPUTF8 cannot be set to True at the same timerz
�.�s
�.�
FrzPeer:)rz	220 %s %s)$�asynchat�
async_chat�__init__�smtp_server�conn�addr�data_size_limit�enable_SMTPUTF8�_decode_datar%�_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__)	rZserverr1r2r3r(r4�decode_data�errrrrr/�s@


zSMTPChannel.__init__cCs.|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)rrrr�_set_post_data_state�sz SMTPChannel._set_post_data_statecCs|j�d|_g|_dS)z.Reset all state variables except the greeting.rN)rT�
received_data�received_lines)rrrrr<�szSMTPChannel._set_rset_statecCstdtd�|jS)NzTAccess to __server attribute on SMTPChannel is deprecated, use 'smtp_server' instead�)r�DeprecationWarningr0)rrrr�__server�szSMTPChannel.__servercCstdtd�||_dS)NzRSetting __server attribute on SMTPChannel is deprecated, set 'smtp_server' insteadrW)rrXr0)r�valuerrrrY�scCstdtd�|jS)NzUAccess to __line attribute on SMTPChannel is deprecated, use 'received_lines' insteadrW)rrXrV)rrrr�__line�szSMTPChannel.__linecCstdtd�||_dS)NzSSetting __line attribute on SMTPChannel is deprecated, set 'received_lines' insteadrW)rrXrV)rrZrrrr[�scCstdtd�|jS)NzRAccess to __state attribute on SMTPChannel is deprecated, use 'smtp_state' insteadrW)rrXrN)rrrr�__state�szSMTPChannel.__statecCstdtd�||_dS)NzPSetting __state attribute on SMTPChannel is deprecated, set 'smtp_state' insteadrW)rrXrN)rrZrrrr\�scCstdtd�|jS)NzXAccess to __greeting attribute on SMTPChannel is deprecated, use 'seen_greeting' insteadrW)rrXr=)rrrr�
__greeting�szSMTPChannel.__greetingcCstdtd�||_dS)NzVSetting __greeting attribute on SMTPChannel is deprecated, set 'seen_greeting' insteadrW)rrXr=)rrZrrrr]�scCstdtd�|jS)NzSAccess to __mailfrom attribute on SMTPChannel is deprecated, use 'mailfrom' insteadrW)rrXrO)rrrr�
__mailfrom�szSMTPChannel.__mailfromcCstdtd�||_dS)NzQSetting __mailfrom attribute on SMTPChannel is deprecated, set 'mailfrom' insteadrW)rrXrO)rrZrrrr^�scCstdtd�|jS)NzQAccess to __rcpttos attribute on SMTPChannel is deprecated, use 'rcpttos' insteadrW)rrXrP)rrrr�	__rcpttos�szSMTPChannel.__rcpttoscCstdtd�||_dS)NzOSetting __rcpttos attribute on SMTPChannel is deprecated, set 'rcpttos' insteadrW)rrXrP)rrZrrrr_�scCstdtd�|jS)NzTAccess to __data attribute on SMTPChannel is deprecated, use 'received_data' insteadrW)rrXrU)rrrr�__data�szSMTPChannel.__datacCstdtd�||_dS)NzRSetting __data attribute on SMTPChannel is deprecated, set 'received_data' insteadrW)rrXrU)rrZrrrr`scCstdtd�|jS)NzKAccess to __fqdn attribute on SMTPChannel is deprecated, use 'fqdn' insteadrW)rrXrA)rrrr�__fqdn
szSMTPChannel.__fqdncCstdtd�||_dS)NzISetting __fqdn attribute on SMTPChannel is deprecated, set 'fqdn' insteadrW)rrXrA)rrZrrrrascCstdtd�|jS)NzKAccess to __peer attribute on SMTPChannel is deprecated, use 'peer' insteadrW)rrXrB)rrrr�__peerszSMTPChannel.__peercCstdtd�||_dS)NzISetting __peer attribute on SMTPChannel is deprecated, set 'peer' insteadrW)rrXrB)rrZrrrrbscCstdtd�|jS)NzKAccess to __conn attribute on SMTPChannel is deprecated, use 'conn' insteadrW)rrXr1)rrrr�__conn szSMTPChannel.__conncCstdtd�||_dS)NzISetting __conn attribute on SMTPChannel is deprecated, set 'conn' insteadrW)rrXr1)rrZrrrrc%scCstdtd�|jS)NzKAccess to __addr attribute on SMTPChannel is deprecated, use 'addr' insteadrW)rrXr2)rrrr�__addr+szSMTPChannel.__addrcCstdtd�||_dS)NzISetting __addr attribute on SMTPChannel is deprecated, set 'addr' insteadrW)rrXr2)rrZrrrrd0scCs&tjj|t|d|jrdnd��dS)Nz
zutf-8�ascii)r-r.rI�bytesrQ)rr
rrrrI7s
zSMTPChannel.pushcCs|d}|j|jkr|j}n|j|jkr*|j}|r<|j|kr<dS|rR|jt|�7_|jrl|jj	t
|d��n|jj	|�dS)Nzutf-8)rNrMr'�DATAr3rR�lenr5rV�append�str)r�data�limitrrr�collect_incoming_data<sz!SMTPChannel.collect_incoming_datac
Cs|jj|j�}tdt|�td�g|_|j|jk�r|jd}|_|sT|j	d�dS|j
sdt|d�}|jd�}|dkr�|j
�}d}n$|d|�j
�}||dd�j�}|jr�|j|n|j}||kr�|j	d�dSt|d	|d�}|�s�|j	d
|�dS||�dS|j|jk�r*|j	d�d|_dS|j�rT|j|jk�rT|j	d�d|_dSg}xJ|j|j�D]:}	|	�r�|	d|jk�r�|j|	dd��n
|j|	��qfW|jj|�|_|j|j|j|jf}
i}|j
�s�|j|jd
�}|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)#r6�joinrVrrGrHrNrMrRrIr5rj�find�upper�stripr>r#r&�getattrrgr3�splitr7r8rir:rUrBrOrProrpr0�process_messagerT)
r�lineZsz�i�command�argZmax_sz�methodrk�textrE�kwargsZstatusrrr�found_terminatorLsd






zSMTPChannel.found_terminatorcCsH|s|jd�dS|jr&|jd�dS|j�||_|jd|j�dS)Nz501 Syntax: HELO hostnamez503 Duplicate HELO/EHLOz250 %s)rIr=r<rA)rr{rrr�	smtp_HELO�s

zSMTPChannel.smtp_HELOcCs�|s|jd�dS|jr&|jd�dS|j�||_d|_|jd|j�|jrr|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)	rIr=r<r>rAr3r#r5r4)rr{rrr�	smtp_EHLO�s&



zSMTPChannel.smtp_EHLOcCs|r|jd�n
|jd�dS)Nz501 Syntax: NOOPz250 OK)rI)rr{rrr�	smtp_NOOP�szSMTPChannel.smtp_NOOPcCs|jd�|j�dS)Nz221 Bye)rIZclose_when_done)rr{rrr�	smtp_QUIT�s
zSMTPChannel.smtp_QUITcCs0t|�}|d|�j�|kr,||d�j�SdS)Nr)rhrsrt)r�keywordr{Zkeylenrrr�_strip_command_keyword�sz"SMTPChannel._strip_command_keywordcCsF|sdS|j�jd�r$t|�\}}nt|�\}}|s<||fS|j|fS)Nr�<)rr)�lstrip�
startswithrrZ	addr_spec)rr{�address�restrrr�_getaddr�szSMTPChannel._getaddrcCsNi}xD|D]<}|jd�\}}}|j�s2|r6|r6dS|r>|nd||<q
W|S)N�=T)�	partition�isalnum)r�params�resultZparam�eqrZrrr�
_getparams�s
zSMTPChannel._getparamscCs|r�d}|j�}|dkr$|jd�q�|dkr8|jd�q�|dkr^d}|jrR||7}|j|�q�|dkr�d	}|jrx||7}|j|�q�|d
kr�|jd�q�|dkr�|jd
�q�|dkr�|jd�q�|dkr�|jd�q�|dkr�|jd�q�|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>rgz250 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)rsrIr>)rr{ZextendedZlc_argr
rrr�	smtp_HELP�s:zSMTPChannel.smtp_HELPcCs@|r2|j|�\}}|r"|jd�q<|jd|�n
|jd�dS)NzB252 Cannot VRFY user, but will accept message and attempt deliveryz502 Could not VRFY %sz501 Syntax: VRFY <address>)r�rI)rr{r�r�rrr�	smtp_VRFY�szSMTPChannel.smtp_VRFYcCs�|js|jd�dStd|td�d}|jr4|d7}|dkrJ|j|�dS|jd|�}|j|�\}}|sv|j|�dS|jr�|r�|j|�dS|jr�|jd�dS|j�j	�|_
|j|j
�}|dkr�|j|�dS|j�s|j
dd	�}|dk�r|jd�dS|j�r>|j
dd
�}|dk�r&d|_n|d
k	�r>|jd�dS|j
dd�}|�r�|j��sh|j|�dS|j�r�t|�|jk�r�|jd�dSt|j��dk�r�|jd�dS||_td|jtd�|jd�dS)Nz503 Error: send HELO firstz	===> MAIL)rz 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=rIrrHr>r�r�rOrsrvror�r5�popr4rQ�isdigitr3�intrh�keys)rr{�	syntaxerrr�r�Zbody�smtputf8�sizerrr�	smtp_MAILsh














zSMTPChannel.smtp_MAILcCs|js|jd�dStd|td�|js6|jd�dSd}|jrH|d7}|dkr^|j|�dS|jd|�}|j|�\}}|s�|j|�dS|jr�|r�|j|�dS|j�j	�|_
|j|j
�}|dkr�|j|�dSt|j
��dkr�|jd	�dS|jj|�td
|jtd�|jd�dS)Nz503 Error: send HELO firstz	===> RCPT)rz503 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=rIrrHrOr>r�r�rsrvrpr�rhr�rPri)rr{r�r�r�rrr�	smtp_RCPT7s@






zSMTPChannel.smtp_RCPTcCs(|r|jd�dS|j�|jd�dS)Nz501 Syntax: RSETz250 OK)rIr<)rr{rrr�	smtp_RSETZs

zSMTPChannel.smtp_RSETcCsZ|js|jd�dS|js(|jd�dS|r:|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=rIrPrgrNrS)rr{rrr�	smtp_DATAas



zSMTPChannel.smtp_DATAcCs|jd�dS)Nz502 EXPN not implemented)rI)rr{rrr�	smtp_EXPNpszSMTPChannel.smtp_EXPN),rrrrMrgr&�collections�defaultdictr#�propertyr'�DATA_SIZE_DEFAULTr/rTr<Z_SMTPChannel__server�setterZ_SMTPChannel__lineZ_SMTPChannel__stateZ_SMTPChannel__greetingZ_SMTPChannel__mailfromZ_SMTPChannel__rcpttosZ_SMTPChannel__dataZ_SMTPChannel__fqdnZ_SMTPChannel__peerZ_SMTPChannel__connZ_SMTPChannel__addrrIrmrr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrws`&	>#6#c@s2eZdZeZedddfdd�Zdd�Zdd�ZdS)	rNFcCs�||_||_||_||_||_|r.|r.td��tjj||d�yNt	j
|dt	ji�}|j|dd|dd�|j
�|j|�|jd�Wn|j��Yn(Xtd|jjtjtj��||ftd�dS)	NzFdecode_data and enable_SMTPUTF8 cannot be set to True at the same time)r(�typerr�z0%s started at %s
	Local addr: %s
	Remote addr:%s)r)Z
_localaddr�_remoteaddrr3r4r5r%�asyncore�
dispatcherr/r@ZgetaddrinfoZSOCK_STREAMZ
create_socketZset_reuse_addrZbindZlistenrDr�	__class__r�time�ctimerH)rZ	localaddrZ
remoteaddrr3r(r4rKZgai_resultsrrrr/xs*

zSMTPServer.__init__cCs6tdt|�td�|j||||j|j|j|j�}dS)NzIncoming connection from %s)r)rrGrH�
channel_classr3Z_mapr4r5)rr1r2Zchannelrrr�handle_accepted�szSMTPServer.handle_acceptedcKst�dS)aOverride 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 if decode_data=True was given as init parameter, otherwise
        it 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)rrBrOrPrkr~rrrrw�szSMTPServer.process_message)	rrrrr�r�r/r�rwrrrrrts
c@seZdZdd�Zdd�ZdS)rcCsrd}|j�}x`|D]X}|rP|rPd|d}t|t�sDt|jd��}t|�d}t|t�sbt|�}t|�qWdS)NrzX-Peer: rzutf-8)�
splitlines�
isinstancerjrG�encoder)rrBrkZ	inheaders�linesrxZ
peerheaderrrr�_print_message_content�s



z&DebuggingServer._print_message_contentcKsXtd�|r@|jd�r&td|d�|jd�r@td|d�|j||�td�dS)Nz%---------- MESSAGE FOLLOWS ----------rozmail options: %srpzrcpt options: %s
z%------------ END MESSAGE ------------)r�getr�)rrBrOrPrkr~rrrrw�s

zDebuggingServer.process_messageN)rrrr�rwrrrrr�scs,eZdZ�fdd�Zdd�Zdd�Z�ZS)rcs.d|kr|drtd��tt|�j||�dS)Nr4z$PureProxy does not support SMTPUTF8.)r%�superrr/)rrEr~)r�rrr/�szPureProxy.__init__c	Csh|jd�}d}x|D]}|sP|d7}qW|j|d|d�tj|�}|j|||�}td|td�dS)Nrrrz
X-Peer: %szwe got some refusals:)r)rv�insertr9rq�_deliverrrH)	rrBrOrPrkr�ryrx�refusedrrrrw�s


zPureProxy.process_messagecCs�ddl}i}yB|j�}|j|jd|jd�z|j|||�}Wd|j�XWn�|jk
r�}ztdtd�|j	}WYdd}~Xnjt
|jfk
r�}zHtd|jtd�t
|dd	�}t
|dd�}	x|D]}
||	f||
<q�WWYdd}~XnX|S)
Nrrzgot SMTPRecipientsRefused)rZgotZ	smtp_codeZ
smtp_error�ignore���)�smtplibZSMTPZconnectr�Zsendmail�quitZSMTPRecipientsRefusedrrHZ
recipientsrCZ
SMTPExceptionr�ru)rrOrPrkr�r��s�eZerrcode�errmsg�rrrrr��s$
"zPureProxy._deliver)rrrr/rwr��
__classcell__rr)r�rr�scs$eZdZ�fdd�Zdd�Z�ZS)r	cs.d|kr|drtd��tt|�j||�dS)Nr4z'MailmanProxy does not support SMTPUTF8.)r%r�rr/)rrEr~)r�rrr/
szMailmanProxy.__init__cCs:ddlm}ddlm}ddlm}ddlm}g}	x~|D]v}
|
j�jd�d}|jd�}t|�dkrhq:|d}
t|�dkr�|d	}nd
}|j	|
�s:|d!kr�q:|	j
|
|
|f�q:Wx|	D]\}
}
}|j|
�q�Wtddj
|�td�|�r|j|||�}td|td�i}||�}|j|�}|jd��s2||d<|jd��sPtjtj��|d<x�|	D]�\}
}
}td|
td�|j|
�}|�s�|j|
dd�}|||
<|d
k�r�|j|d	d�n�|dk�r�|j|d	d�nh|dk�r�|j|d	d�nN|d
k�r�|j|d	d�n4|d"k�rV|dk�rd|d<nd |d<|j|d	d��qVWdS)#Nr)�StringIO)�Utils)�Message)�MailList�@�-rWrr�admin�owner�requestrq�leavezforwarding recips:rn)rzwe got refusals:�fromZFromZdateZDatezsending message to)�lock)�tolist)Ztoadmin)Ztoowner)Z	torequestZ	subscribeZSubjectZunsubscribe)rr�r�r�rqr�)rqr�)�ior�ZMailmanr�r�r��lowerrvrhZlist_existsri�removerrqrHr�r�r�r�ZEnqueue)rrBrOrPrkr�r�r�r�Z	listnamesZrcptZlocal�partsZlistnamerzr�Zmlistsr�r
Zmlistrrrrwsd











zMailmanProxy.process_message)rrrr/rwr�rr)r�rr	sc@seZdZdZdZdZdZdS)�OptionsTrNF)rrr�setuid�	classname�
size_limitr4rrrrr�_sr�c
!Csty.tjtjdd�dddddddd	g�\}}Wn.tjk
r\}ztd|�WYdd}~XnXt�}x�|D]�\}}|d'kr�td�qj|d(kr�tt�tjd�qj|d)kr�d|_	qj|d*kr�||_
qj|d+kr�tjaqj|d,kr�d|_
qj|d-krjyt|�}||_Wqjtd|tjd�tjd�YqjXqjWt|�dk�r@d}d}nPt|�dk�r\|d}d}n4t|�d k�r||d}|d}ntdd!tj|��|jd"�}	|	dk�r�tdd#|�|d|	�|_yt||	dd��|_Wn$tk
�r�tdd$|�YnX|jd"�}	|	dk�r"tdd%|�|d|	�|_yt||	dd��|_Wn$tk
�rntdd&|�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:25rW�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�rrJrr�r�rrHr4r�r�rh�
COMMASPACErqrr�	localhost�	localportr%�
remotehost�
remoteport)
ZoptsrEr��options�optr{Zint_sizeZ	localspecZ
remotespecryrrr�	parseargsfsp






r��__main__r)r)r4z7Cannot import module "pwd"; try running with -n option.)r�nobodyrWz3Cannot setuid "nobody"; try running with -n option.)r)@rr�osrFr�r�r@r�r-r��warningsrZemail._header_value_parserrr�__all__r�ZprogramrJr
rHr9r�r�rr.rr�rrrr	r�r�rr�r��rfindZlastdot�
__import__r�locals�modr�ruZclass_r�r�r�r�r�r4�proxyr��pwd�ImportErrorrrr�getpwnamr��PermissionErrorZloop�KeyboardInterruptrrrr�<module>-sx#

M-SB