-
<c       s    d  Z  $ I d k Z J d k Z K d k Z L d k Z M d k Z N d k Z O d k Z P d k Z R d d d d g Z	 T e i
 d Z U d Z X d f  d	     YZ ] e   a ^ d
 Z _ d Z ` d Z d d d  Z l d e i f d     YZ d e i f d     YZ Bd e f d     YZ Rd e f d     YZ {d e f d     YZ d f  d     YZ d   Z 	e d j os
e   Z e i o y d k Z Wn6 e  j
 o' e i! d IJe i" d  n Xe i# d  d Z$ y e i e$  WnX e% j
 oI Z& e& i e i' j o
   n e i! d IJe i" d  n Xn d k( Z( e) e( e i*  Z+ e+ e i, e i- f e i. e i/ f  Z0 y  e i1   Wn !e2 j
 o
 "n Xn d S(   sc  An RFC 2821 smtp proxy.

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 `SMTPProxy' by
        default.

    --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.
Ns
   SMTPServers   DebuggingServers	   PureProxys   MailmanProxyi    s   Python SMTP proxy version 0.2s   Devnullc      s#   X t  Z Y d   Z Z d   Z RS(   Nc    s
   Y Y d  S(   N(    (   s   selfs   msg(    (    s   /usr/lib/python2.2/smtpd.pys   writeY s    c    s
   Z Z d  S(   N(    (   s   self(    (    s   /usr/lib/python2.2/smtpd.pys   flushZ s    (   s   __name__s
   __module__s   writes   flush(    (    (    s   /usr/lib/python2.2/smtpd.pys   DevnullX s   	s   
s    s   , c    sL   d e t  i t t   IJf | o g t  i | IJn h t  i |   d  S(   N(   s   syss   stderrs   __doc__s   globalss   msgs   exits   code(   s   codes   msg(    (    s   /usr/lib/python2.2/smtpd.pys   usaged s   
s   SMTPChannelc      s   l t  Z m d Z n d Z p d   Z  d   Z  d   Z  d   Z  d   Z  d   Z	  d	   Z
  d
   Z  d   Z  d   Z  d   Z d   Z RS(   Ni    i   c    s   p q t  i i |  |  r | |  _ s | |  _ t | |  _	 u g  |  _
 v |  i |  _ w d |  _ x t |  _ y g  |  _ z d |  _ { t i   |  _ | | i   |  _ } t d It |  i  IJ~ |  i d |  i t f   |  i d  d  S(   Ni    s    s   Peer:s	   220 %s %ss   
(   s   asynchats
   async_chats   __init__s   selfs   conns   servers   _SMTPChannel__servers   _SMTPChannel__conns   addrs   _SMTPChannel__addrs   _SMTPChannel__lines   COMMANDs   _SMTPChannel__states   _SMTPChannel__greetings   Nones   _SMTPChannel__mailfroms   _SMTPChannel__rcpttoss   _SMTPChannel__datas   sockets   getfqdns   _SMTPChannel__fqdns   getpeernames   _SMTPChannel__peers   DEBUGSTREAMs   reprs   pushs   __version__s   set_terminator(   s   selfs   servers   conns   addr(    (    s   /usr/lib/python2.2/smtpd.pys   __init__p s   c    s!     t  i i |  | d  d  S(   Ns   
(   s   asynchats
   async_chats   pushs   selfs   msg(   s   selfs   msg(    (    s   /usr/lib/python2.2/smtpd.pys   push s   c    s     |  i i |  d  S(   N(   s   selfs   _SMTPChannel__lines   appends   data(   s   selfs   data(    (    s   /usr/lib/python2.2/smtpd.pys   collect_incoming_data s   c 	   s    t  i |  i  }  t d It |  IJ g  |  _  |  i |  i j o  | o  |  i	 d   d  Sn  t
 }  | i d  }  | d j  o  | i   }  t
 } n+  | |  i   }  | | d i   }  t |  d | t
  }  | o  |  i	 d |   d  Sn  | |   d  SnL |  i |  i j o  |  i	 d   d  Sn  g  }  x] | i d	  D ]I }  | o | d d
 j o  | i | d  n  | i |  qW t i |  |  _  |  i i |  i  |  i  |  i  |  i  }  g  |  _  t
 |  _  |  i |  _  |  i  d	   | o  |  i	 d  n  |  i	 |  d  S(   Ns   Data:s   500 Error: bad syntaxs    i    i   s   smtp_s'   502 Error: command "%s" not implementeds   451 Internal confusions   
s   .s   250 Ok(!   s   EMPTYSTRINGs   joins   selfs   _SMTPChannel__lines   lines   DEBUGSTREAMs   reprs   _SMTPChannel__states   COMMANDs   pushs   Nones   methods   finds   is   uppers   commands   args   strips   getattrs   DATAs   datas   splits   texts   appends   NEWLINEs   _SMTPChannel__datas   _SMTPChannel__servers   process_messages   _SMTPChannel__peers   _SMTPChannel__mailfroms   _SMTPChannel__rcpttoss   statuss   set_terminator(	   s   selfs   statuss   is   texts   commands   args   lines   datas   method(    (    s   /usr/lib/python2.2/smtpd.pys   found_terminator sR   		 			c    sq     | o  |  i d   d  Sn  |  i o  |  i d  n$  | |  _  |  i d |  i  d  S(   Ns   501 Syntax: HELO hostnames   503 Duplicate HELO/EHLOs   250 %s(   s   args   selfs   pushs   _SMTPChannel__greetings   _SMTPChannel__fqdn(   s   selfs   arg(    (    s   /usr/lib/python2.2/smtpd.pys	   smtp_HELO s   c    s5     | o  |  i d  n  |  i d  d  S(   Ns   501 Syntax: NOOPs   250 Ok(   s   args   selfs   push(   s   selfs   arg(    (    s   /usr/lib/python2.2/smtpd.pys	   smtp_NOOP s   
c    s$     |  i d   |  i   d  S(   Ns   221 Bye(   s   selfs   pushs   close_when_done(   s   selfs   arg(    (    s   /usr/lib/python2.2/smtpd.pys	   smtp_QUIT s   c    s     t  }  t |  }  | |  i   | j oo  | | i   }  | o  nG  | d d j o | d d j o
 | d j o  | d d !} n n  | Sd  S(   Ni    s   <is   >s   <>i   (   s   Nones   addresss   lens   keywords   keylens   args   uppers   strip(   s   selfs   keywords   args   addresss   keylen(    (    s   /usr/lib/python2.2/smtpd.pys	   __getaddr s   	2c    s     t  d I| IJ |  i d |  }  | o  |  i d   d  Sn  |  i o  |  i d   d  Sn  | |  _  t  d I|  i IJ |  i d  d  S(   Ns	   ===> MAILs   FROM:s   501 Syntax: MAIL FROM:<address>s   503 Error: nested MAIL commands   sender:s   250 Ok(   s   DEBUGSTREAMs   args   selfs   _SMTPChannel__getaddrs   addresss   pushs   _SMTPChannel__mailfrom(   s   selfs   args   address(    (    s   /usr/lib/python2.2/smtpd.pys	   smtp_MAIL s   c    s     t  d I| IJ |  i o  |  i d   d  Sn  |  i d |  }  | o  |  i d   d  Sn  | i   i d  o  |  i d |   d  Sn  |  i	 i
 |   t  d I|  i	 IJ |  i d  d  S(	   Ns	   ===> RCPTs   503 Error: need MAIL commands   TO:s   501 Syntax: RCPT TO: <address>s   stimpys   503 You suck %ss   recips:s   250 Ok(   s   DEBUGSTREAMs   args   selfs   _SMTPChannel__mailfroms   pushs   _SMTPChannel__getaddrs   addresss   lowers
   startswiths   _SMTPChannel__rcpttoss   append(   s   selfs   args   address(    (    s   /usr/lib/python2.2/smtpd.pys	   smtp_RCPT s   c    so     | o  |  i d   d  Sn  t |  _ g  |  _ d |  _ |  i |  _ |  i d  d  S(   Ns   501 Syntax: RSETs    s   250 Ok(	   s   args   selfs   pushs   Nones   _SMTPChannel__mailfroms   _SMTPChannel__rcpttoss   _SMTPChannel__datas   COMMANDs   _SMTPChannel__state(   s   selfs   arg(    (    s   /usr/lib/python2.2/smtpd.pys	   smtp_RSET s   
c    s   |  i o |  i d  	d  Sn 
| o |  i d  d  Sn |  i |  _ |  i d  |  i d  d  S(   Ns   503 Error: need RCPT commands   501 Syntax: DATAs   
.
s#   354 End data with <CR><LF>.<CR><LF>(   s   selfs   _SMTPChannel__rcpttoss   pushs   args   DATAs   _SMTPChannel__states   set_terminator(   s   selfs   arg(    (    s   /usr/lib/python2.2/smtpd.pys	   smtp_DATAs   
(   s   __name__s
   __module__s   COMMANDs   DATAs   __init__s   pushs   collect_incoming_datas   found_terminators	   smtp_HELOs	   smtp_NOOPs	   smtp_QUITs   _SMTPChannel__getaddrs	   smtp_MAILs	   smtp_RCPTs	   smtp_RSETs	   smtp_DATA(    (    (    s   /usr/lib/python2.2/smtpd.pys   SMTPChannell s   			1
c      s/   t  Z d   Z "d   Z (d   Z RS(   Nc    s   | |  _ | |  _ t i i |   |  i t	 i
 t	 i  |  i   |  i |  |  i d  t d |  i i t i t i    | | f IJd  S(   Ni   s0   %s started at %s
	Local addr: %s
	Remote addr:%s(   s	   localaddrs   selfs
   _localaddrs
   remoteaddrs   _remoteaddrs   asyncores
   dispatchers   __init__s   create_sockets   sockets   AF_INETs   SOCK_STREAMs   set_reuse_addrs   binds   listens   DEBUGSTREAMs	   __class__s   __name__s   times   ctime(   s   selfs	   localaddrs
   remoteaddr(    (    s   /usr/lib/python2.2/smtpd.pys   __init__s   c    sH   "#|  i   \ } } $t d t |  IJ%t |  | |  } d  S(   Ns   Incoming connection from %s(   s   selfs   accepts   conns   addrs   DEBUGSTREAMs   reprs   SMTPChannels   channel(   s   selfs   addrs   conns   channel(    (    s   /usr/lib/python2.2/smtpd.pys   handle_accept"s   c    s   (=>t   d S(   sI  Override 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.

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

        N(   s   NotImplementedError(   s   selfs   peers   mailfroms   rcpttoss   data(    (    s   /usr/lib/python2.2/smtpd.pys   process_message(s   (   s   __name__s
   __module__s   __init__s   handle_accepts   process_message(    (    (    s   /usr/lib/python2.2/smtpd.pys
   SMTPServers   	c      s   Bt  Z Dd   Z RS(   Nc    s   DEd } F| i d  } Gd GHHxH | DH]= } J| o | o Kd G| d GHLd } n M| GHq0 WNd GHd  S(   Ni   s   
s%   ---------- MESSAGE FOLLOWS ----------s   X-Peer:i    s%   ------------ END MESSAGE ------------(   s	   inheaderss   datas   splits   liness   lines   peer(   s   selfs   peers   mailfroms   rcpttoss   datas   lines	   inheaderss   lines(    (    s   /usr/lib/python2.2/smtpd.pys   process_messageDs   	
 	(   s   __name__s
   __module__s   process_message(    (    (    s   /usr/lib/python2.2/smtpd.pys   DebuggingServerBs   	c      s#   Rt  Z Sd   Z ad   Z RS(   Nc 	   s   ST| i d  } Vd } Wx1 | DW]& } X| o YPn Z| d 7} q( W[| i | d | d  \t i |  } ]|  i
 | | |  } _t d IJd  S(   Ns   
i    i   s
   X-Peer: %ss   we got some refusals(   s   datas   splits   liness   is   lines   inserts   peers   NEWLINEs   joins   selfs   _delivers   mailfroms   rcpttoss   refuseds   DEBUGSTREAM(	   s   selfs   peers   mailfroms   rcpttoss   datas   is   liness   refuseds   line(    (    s   /usr/lib/python2.2/smtpd.pys   process_messageSs   	
 	c    sQ  abd  k  }	 ch  } dyg e|	 i   } f| i |  i d |  i d  gz h| i | | |  } Wd  ij| i   XWn k|	 i j
 o" } lt d IJm| i } n nt i |	 i f j
 os } ot d I| i IJst | d d  } tt | d d  }
 ux$ | Du] } v| |
 f | | <q!Wn Xw| Sd  S(	   Ni    i   s   got SMTPRecipientsRefuseds   gots	   smtp_codeis
   smtp_errors   ignore(   s   smtplibs   refuseds   SMTPs   ss   connects   selfs   _remoteaddrs   sendmails   mailfroms   rcpttoss   datas   quits   SMTPRecipientsRefuseds   es   DEBUGSTREAMs
   recipientss   sockets   errors   SMTPExceptions	   __class__s   getattrs   errcodes   errmsgs   r(   s   selfs   mailfroms   rcpttoss   datas   es   errcodes   refuseds   ss   rs   smtplibs   errmsg(    (    s   /usr/lib/python2.2/smtpd.pys   _deliveras(   	!
 	(   s   __name__s
   __module__s   process_messages   _deliver(    (    (    s   /usr/lib/python2.2/smtpd.pys	   PureProxyRs   	c      s   {t  Z |d   Z RS(   Nc    s  |}d k  l }
 ~d k l } d k l } d k l } g  } x | D] } | i	   i
 d  d } | i
 d  } t |  d j o
 qV n | d } t |  d j o | d	 } n
 d
 } | i |  p | d
 d d d d d f j o
 qV n | i | | | f  qV Wx* | D] \ } } } | i |  qNWt d Id i |  IJ| o) |  i | | |  } t d IJn h  } |
 |  } | i |  } | i d  o | | d <n | i d  o  t i t i    | d <n xy| D]n\ } } } t d I| IJ| i  |  }	 |	 o) | i | d d }	 |	 | | <n | d
 j o | i" |	 d d	 n | d j o | i" |	 d d	 n | d j o | i" |	 d d	 n | d j o | i" |	 d d	 n_ | d d f j oH | d j o d | d <n d | d <| i" |	 d d	 n qPWd  S(    N(   s   StringIO(   s   Utils(   s   Message(   s   MailLists   @i    s   -i   i   s    s   admins   owners   requests   joins   leaves   forwarding recips:s    s   we got refusalss   froms   Froms   dates   Dates   sending message tos   locks   tolists   toadmins   toowners	   torequests	   subscribes   Subjects   unsubscribe(#   s	   cStringIOs   StringIOs   Mailmans   Utilss   Messages   MailLists	   listnamess   rcpttoss   rcpts   lowers   splits   locals   partss   lens   listnames   commands   list_existss   appends   removes   DEBUGSTREAMs   joins   selfs   _delivers   mailfroms   datas   refuseds   mlistss   ss   msgs	   getheaders   times   ctimes   gets   mlists   Enqueue(   s   selfs   peers   mailfroms   rcpttoss   datas	   listnamess   listnames   mlistss   refuseds   mlists   StringIOs   Utilss   MailLists   rcpts   ss   partss   commands   msgs   Messages   local(    (    s   /usr/lib/python2.2/smtpd.pys   process_message|sh   	
 	
	3

 
	 
 (   s   __name__s
   __module__s   process_message(    (    (    s   /usr/lib/python2.2/smtpd.pys   MailmanProxy{s   	s   Optionsc      s   t  Z d Z d Z RS(   Ni   s	   PureProxy(   s   __name__s
   __module__s   setuids	   classname(    (    (    s   /usr/lib/python2.2/smtpd.pys   Optionss   		c  	   sV  y; t  i  t i d d d d d d d g  \ } } Wn+ t  i j
 o } t d |  n Xt   } x | D] \ }  } |  d d	 f j o t d
  n |  d d f j o$ t i t IJt i d
  ns |  d d f j o d
 | _ nM |  d d f j o | | _ n' |  d d f j o t i a n q Wt |  d j  o d } d } n t |  d j  o | d
 } d } nR t |  d j  o | d
 } | d } n t d d t i |   | i d  } | d
 j  o t d d |  n | |  | _ y t | | d  | _ Wn* t j
 o t d d |  n X| i d  } | d
 j  o t d d |  n  | |  | _ y t | | d  | _ Wn* t j
 o t d d |  n X| Sd  S(   Ni   s   nVhc:ds   class=s   nosetuids   versions   helps   debugs   -hs   --helpi    s   -Vs	   --versions   -ns
   --nosetuids   -cs   --classs   -ds   --debugs   localhost:8025s   localhost:25i   i   s   Invalid arguments: %ss   :s   Bad local spec: %ss   Bad local port: %ss   Bad remote spec: %ss   Bad remote port: %s(   s   getopts   syss   argvs   optss   argss   errors   es   usages   Optionss   optionss   opts   args   stderrs   __version__s   exits   setuids	   classnames   DEBUGSTREAMs   lens	   localspecs
   remotespecs
   COMMASPACEs   joins   finds   is	   localhosts   ints	   localports
   ValueErrors
   remotehosts
   remoteport(	   s   opts   es   is   argss	   localspecs
   remotespecs   args   optionss   opts(    (    s   /usr/lib/python2.2/smtpd.pys	   parseargss^   %
 	s   __main__s7   Cannot import module "pwd"; try running with -n option.i   s   nobodyi   s3   Cannot setuid "nobody"; try running with -n option.(3   s   __doc__s   syss   oss   errnos   getopts   times   sockets   asyncores   asynchats   __all__s   argvs   programs   __version__s   Devnulls   DEBUGSTREAMs   NEWLINEs   EMPTYSTRINGs
   COMMASPACEs   usages
   async_chats   SMTPChannels
   dispatchers
   SMTPServers   DebuggingServers	   PureProxys   MailmanProxys   Optionss	   parseargss   __name__s   optionss   setuids   pwds   ImportErrors   stderrs   exits   getpwnams   nobodys   OSErrors   es   EPERMs   __main__s   getattrs	   classnames   class_s	   localhosts	   localports
   remotehosts
   remoteports   proxys   loops   KeyboardInterrupt(   s   Optionss   nobodys   asyncores   times   syss   class_s   pwds   __main__s   proxys   Devnulls   EMPTYSTRINGs   __version__s   DebuggingServers   asynchats   es   sockets   __all__s	   parseargss   MailmanProxys   NEWLINEs	   PureProxys   programs   errnos   usages   getopts   SMTPChannels
   SMTPServers   oss   optionss
   COMMASPACE(    (    s   /usr/lib/python2.2/smtpd.pys   ?$ s`   %				/)O9 
