AlkantarClanX12

Your IP : 18.117.156.170


Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/smtpd.cpython-37.opt-1.pyc

B

� f���@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$�%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!�e�:d�YnXe6�;d"�d#Z<ye�5e<�Wn.e=k
�r4e8d$ej9d!�e�:d�YnXye�>�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�*/opt/alt/python37/lib64/python3.7/smtpd.py�writef�z
Devnull.writecCsdS)Nr)rrrr�flushgrz
Devnull.flushN)�__name__�
__module__�__qualname__rrrrrrr
esr
�
z, i�cCs4ttt�tjd�|r&t|tjd�t�|�dS)N)�file)�print�__doc__�globals�sys�stderr�exit)�coder
rrr�usagepsrc@s�eZdZdZdZdZe�efdd��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>|rzSMTPChannel.<lambda>cCs*yt|j���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	
Cs tjj|||d�||_||_||_||_||_||_|rF|rFt	d��|rdd|_
d|_d|_t
|_nd|_
d|_td�|_d	|_|��d|_d
|_|j��t��|_y|��|_Wn<tk
r�}z|��|jdtjkr�dSd}~XYnXtdt |j�t!d
�|�"d|jt#f�dS)N)�mapzFdecode_data and enable_SMTPUTF8 cannot be set to True at the same timerz
�.rs
�.�
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|_|�d�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|��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&tj�|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|j�	t
|d��n|j�	|�dS)Nzutf-8)rNrMr(�DATAr3rR�lenr5rV�append�str)r�data�limitrrr�collect_incoming_data<sz!SMTPChannel.collect_incoming_datac
Cs|j�|j�}tdt|�td�g|_|j|jk�r|jd}|_|sT|�	d�dS|j
sdt|d�}|�d�}|dkr�|�
�}d}n$|d|��
�}||dd���}|jr�|j|n|j}||kr�|�	d�dSt|d	|d�}|s�|�	d
|�dS||�dS|j|jk�r(|�	d�d|_dS|j�rR|j|jk�rR|�	d�d|_dSg}xJ|�|j�D]:}	|	�r�|	d|jk�r�|�|	dd��n
|�|	��qdW|j�|�|_|j|j|j|jf}
i}|j
�s�|j|jd
�}|j j!|
|�}|�"�|�s|�	d�n
|�	|�dS)NzData:)rrz500 Error: bad syntaxzutf-8� r z500 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|�d�dS|jr&|�d�dS|��||_|�d|j�dS)Nz501 Syntax: HELO hostnamez503 Duplicate HELO/EHLOz250 %s)rIr=r<rA)rr{rrr�	smtp_HELO�s

zSMTPChannel.smtp_HELOcCs�|s|�d�dS|jr&|�d�dS|��||_d|_|�d|j�|jrr|�d|j�|jdd7<|js�|�d�|jr�|�d	�|jdd
7<|�d�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|�d�n
|�d�dS)Nz501 Syntax: NOOPz250 OK)rI)rr{rrr�	smtp_NOOP�szSMTPChannel.smtp_NOOPcCs|�d�|��dS)Nz221 Bye)rIZclose_when_done)rr{rrr�	smtp_QUIT�s
zSMTPChannel.smtp_QUITcCs0t|�}|d|���|kr,||d���SdS)Nr)rhrsrt)r�keywordr{Zkeylenrrr�_strip_command_keyword�sz"SMTPChannel._strip_command_keywordcCsF|sdS|���d�r$t|�\}}nt|�\}}|s<||fS|j|fS)N)rr�<)�lstrip�
startswithrrZ	addr_spec)rr{�address�restrrr�_getaddr�szSMTPChannel._getaddrcCsJi}x@|D]8}|�d�\}}}|��r.|r2|s2dS|r:|nd||<q
W|S)N�=T)�	partition�isalnum)r�params�resultZparam�eqrZrrr�
_getparams�s
zSMTPChannel._getparamscCs|r�d}|��}|dkr$|�d�q�|dkr8|�d�q�|dkr^d}|jrR||7}|�|�q�|dkr�d	}|jrx||7}|�|�q�|d
kr�|�d�q�|dkr�|�d
�q�|dkr�|�d�q�|dkr�|�d�q�|dkr�|�d�q�|�d�n
|�d�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|�|�\}}|r"|�d�q<|�d|�n
|�d�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|�d�dStd|td�d}|jr4|d7}|dkrJ|�|�dS|�d|�}|�|�\}}|sv|�|�dS|js�|r�|�|�dS|jr�|�d�dS|���	�|_
|�|j
�}|dkr�|�|�dS|js�|�
dd	�}|d
kr�|�d�dS|j�r8|�
dd
�}|dk�r d|_n|d
k	�r8|�d�dS|�
dd�}|�r�|���sb|�|�dS|j�r�t|�|jk�r�|�d�dSt|���dk�r�|�d�dS||_td|jtd�|�d�dS)Nz503 Error: send HELO firstz	===> MAIL)rz 501 Syntax: MAIL FROM: <address>z [SP <mail-parameters>]zFROM:z503 Error: nested MAIL commandZBODY�7BIT)r�Z8BITMIMEz1501 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=rIrrHr>r�r�rOrsrvror�r5�popr4rQ�isdigitr3�intrh�keys)rr{�	syntaxerrr�r�Zbody�smtputf8�sizerrr�	smtp_MAILsh














zSMTPChannel.smtp_MAILcCs|js|�d�dStd|td�|js6|�d�dSd}|jrH|d7}|dkr^|�|�dS|�d|�}|�|�\}}|s�|�|�dS|js�|r�|�|�dS|���	�|_
|�|j
�}|dkr�|�|�dSt|�
��dkr�|�d	�dS|j�|�td
|jtd�|�d�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|�d�dS|��|�d�dS)Nz501 Syntax: RSETz250 OK)rIr<)rr{rrr�	smtp_RSETZs

zSMTPChannel.smtp_RSETcCsZ|js|�d�dS|js(|�d�dS|r:|�d�dS|j|_|�d�|�d�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|�d�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)	rNFcCs�||_||_||_||_||_|r.|r.td��tjj||d�yNt	j
|dt	ji�}|�|dd|dd�|�
�|�|�|�d�Wn|���Yn(Xtd|jjt�t���||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__c	Cs6tdt|�td�|�||||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)rcCspd}|��}x^|D]V}|rN|sNd|d}t|t�sBt|�d��}t|�d}t|t�s`t|�}t|�qWdS)Nr zX-Peer: rzutf-8)�
splitlines�
isinstancerjrG�encoder)rrBrkZ	inheaders�linesrxZ
peerheaderrrr�_print_message_content�s


z&DebuggingServer._print_message_contentcKsXtd�|r@|�d�r&td|d�|�d�r@td|d�|�||�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|�d�}d}x|D]}|sP|d7}qW|�|d|d�t�|�}|�|||�}td|td�dS)Nrrr z
X-Peer: %szwe got some refusals:)r)rv�insertr9rq�_deliverrrH)	rrBrOrPrkr�ryrx�refusedrrrrw�s


zPureProxy.process_messagec
Cs�ddl}i}yB|��}|�|jd|jd�z|�|||�}Wd|��XWn�|jk
r�}ztdtd�|j	}Wdd}~XYnjt
|jfk
r�}zFtd|jtd�t
|dd�}t
|dd	�}	x|D]}
||	f||
<q�WWdd}~XYnX|S)
Nrr zgot SMTPRecipientsRefused)rZgotZ	smtp_code���Z
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__cCs8ddlm}ddlm}ddlm}ddlm}g}	x||D]t}
|
���d�d}|�d�}t|�dkrhq:|d}
t|�dkr�|d	}nd
}|�	|
�r:|dkr�q:|	�
|
|
|f�q:Wx|	D]\}
}
}|�|
�q�Wtdd
�
|�td�|�r|�|||�}td|td�i}||�}|�|�}|�d��s0||d<|�d��sNt�t���|d<x�|	D]�\}
}
}td|
td�|�|
�}|�s�|j|
dd�}|||
<|d
k�r�|j|d	d�n�|dk�r�|j|d	d�nh|dk�r�|j|d	d�nN|dk�r�|j|d	d�n4|dk�rT|dk�rd|d <nd!|d <|j|d	d��qTWdS)"Nr)�StringIO)�Utils)�Message)�MailList�@�-rWr r)r�admin�owner�requestrq�leavezforwarding recips:rn)rzwe got refusals:�fromZFromZdateZDatezsending message to)�lock)�tolistr�)Ztoadminr�)Ztoownerr�)Z	torequest)rqr�rqZ	subscribeZSubjectZunsubscribe)�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.t�tjdd�dddddddd	g�\}}Wn.tjk
r\}ztd|�Wdd}~XYnXt�}x�|D]�\}}|d
kr�td�qj|dkr�tt�t�d�qj|d
kr�d|_	qj|dkr�||_
qj|dkr�tjaqj|dkr�d|_
qj|dkrjyt|�}||_Wqjtd|tjd�t�d�YqjXqjWt|�dk�r@d}d}nPt|�dk�r\|d}d}n4t|�dk�r||d}|d}ntddt�|��|�d�}	|	dk�r�tdd|�|d|	�|_yt||	dd��|_Wn$tk
�r�tdd|�YnX|�d�}	|	dk�r"tdd|�|d|	�|_yt||	dd��|_Wn$tk
�rntdd|�YnX|S) Nr z	nVhc:s:duzclass=Znosetuid�version�helpzsize=�debugr�)z-hz--helpr)z-Vz	--version)z-nz
--nosetuidF)z-cz--class)z-dz--debug)z-uz
--smtputf8T)z-sz--sizezInvalid size: )rzlocalhost:8025zlocalhost:25rW�zInvalid arguments: %s�:zBad local spec: %szBad local port: %szBad remote spec: %szBad remote port: %s)�getoptr�argv�errorrr�rrJrr�r�rrHr4r�r�rh�
COMMASPACErqrr�	localhost�	localportr&�
remotehost�
remoteport)
ZoptsrEr��optionsZoptr{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