ó
Bü½cc           @   s:  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 m
 Z
 d d l	 m Z d d l	 m Z d d l	 m Z d d l	 m Z d d l	 m Z d d	 l m Z d d
 l Td d l m Z d Z d Z d Z e j Z e j e
 j ƒ d „  Z d „  Z d „  Z d S(   s;   Process subscription or roster requests from listinfo form.iÿÿÿÿN(   t   mm_cfg(   t   Utils(   t   MailList(   t   Errors(   t   i18n(   t   Message(   t   UserDesc(   t   *(   t   syslogt   /s   

<p>s   , c    	      C   s&  t  ƒ  }  |  j t j ƒ t j ƒ  } | so |  j t d t d ƒ ƒ ƒ |  j t	 t d ƒ ƒ ƒ |  j
 ƒ  GHd  S| d j ƒ  } y t j | d d ƒ} Wn~ t j k
 r} t j | ƒ } |  j t d t d ƒ ƒ ƒ |  j t	 t d ƒ ƒ ƒ d GH|  j
 ƒ  GHt d d	 | | ƒ d  SXt j ƒ  } y | j d
 d ƒ } WnW t k
 r”|  j t d t d ƒ ƒ ƒ |  j t	 t d ƒ ƒ ƒ d GH|  j
 ƒ  GHd  SXt j | ƒ s°| j } n  t j | ƒ |  j | ƒ | d „ } | j ƒ  z4 t j t j | ƒ t | |  | | ƒ | j ƒ  Wd  | j ƒ  Xd  S(   Ni   t   Errors   Invalid options to CGI scripti    t   locks&   No such list <em>%(safelistname)s</em>s   Status: 404 Not Foundt   errors!   subscribe: No such list "%s": %s
t   languaget    s   Invalid options to CGI script.s   Status: 400 Bad Requestc         S   s   | j  ƒ  t j d ƒ d  S(   Ni    (   t   Unlockt   syst   exit(   t   signumt   framet   mlist(    (    s4   /export/web/mailman/mailman/Mailman/Cgi/subscribe.pyt   sigterm_handlerd   s    
(   t   Documentt   set_languageR    t   DEFAULT_SERVER_LANGUAGER   t   GetPathPiecest   AddItemt   Headert   _t   Boldt   Formatt   lowerR   R   t   MMListErrort   websafeR   t   cgit   FieldStoraget   getfirstt	   TypeErrort
   IsLanguaget   preferred_languageR   t   Lockt   signalt   SIGTERMt   process_formt   SaveR   (	   t   doct   partst   listnameR   t   et   safelistnamet   cgidataR   R   (    (    s4   /export/web/mailman/mailman/Mailman/Cgi/subscribe.pyt   main1   sN    	

c   #   	   C   s  |  j  ƒ  } |  j } g  } | j d d ƒ j ƒ  } | sO | j t d ƒ ƒ n  | j d d ƒ } t j | | ƒ } t j	 j
 d t j	 j
 d t j	 j
 d d ƒ ƒ ƒ }	 t j r‹t j d	 d
 d t j i t j d 6| j d d ƒ d 6|	 d 6ƒ ƒ }
 y_ t j |
 ƒ } t j | ƒ } | j ƒ  | d sRt j | d ƒ } | j t d ƒ ƒ n  Wq‹t j k
 r‡} | j } | j t d ƒ ƒ q‹Xn  t j r‘t t j ƒ  ƒ } |	 j d ƒ d k rÔ|	 j d d ƒ d } n |	 j d d ƒ d } y4 | j d d ƒ j d ƒ \ } } } t | ƒ } Wn% t  k
 rEd } } } d } n Xt j! t j d | d | d |  j" ƒ  d | ƒ j# ƒ  } | r³| | t j$ k r³| j t d ƒ ƒ n  | râ| | t j% k  râ| j t d ƒ ƒ n  | r
| | k r
| j t d ƒ ƒ n  | s9| j t d ƒ ƒ | j t d ƒ ƒ n  t& t j' t( ƒ r‘| j d d ƒ } t j) | | t j' ƒ sŽ| j t d ƒ ƒ qŽq‘n  | |  j* ƒ  k rÌt+ d  d! | |	 ƒ | j t d" ƒ ƒ n  | j d# d ƒ j ƒ  } | j d$ d ƒ j ƒ  } | r| rt j, ƒ  } nF | s'| r=| j t d% ƒ ƒ n" | | k r_| j t d& ƒ ƒ n  | j d' ƒ } | r§y t | ƒ } Wq°t- t  f k
 r£d } q°Xn	 |  j. } |  j/ sÂd } n |  j0 sÔd } n  | rút1 |  t2 j | ƒ | | ƒ d  S|  j3 d k rd } n t d( ƒ } y2 t4 | | | | | ƒ } |  j5 | |	 ƒ d } Wnút6 j7 k
 rrt d) ƒ } nöt6 j8 k
 r‘t d* ƒ } n×t6 j9 k
 r°t d+ ƒ } n¸t6 j: k
 rÞ| rÏ| } qht d, ƒ } nŠt6 j; k
 r } | rÿ| } qht t< | ƒ ƒ } t d- ƒ } nHt6 j= k
 r?t d. ƒ } n)t6 j> k
 r| sdt d/ ƒ } n | } | rht j? rh|  j* ƒ  } |  j@ | ƒ }  tA jB ƒ  }! tA jC |  ƒ z= tD jE |  jF | ƒ |  jG ƒ  t d0 ƒ t d1 ƒ d2 |  ƒ}" Wd  tA jH |! ƒ X|" jI |  ƒ qhnZ t6 jJ k
 r-t d3 ƒ } n; t6 jK k
 rLt d4 ƒ } n X| r\| } n t d5 ƒ } t1 |  | | | ƒ d  S(6   Nt   emailR   s&   You must supply a valid email address.t   fullnamet   HTTP_FORWARDED_FORt   HTTP_X_FORWARDED_FORt   REMOTE_ADDRs   unidentified origint   urls/   https://www.google.com/recaptcha/api/siteverifyt   datat   secrets   g-recaptcha-responset   responset   remoteipt   successs   error-codess(   reCAPTCHA validation failed: %(e_codes)ss.   reCAPTCHA could not be validated: %(e_reason)st   .i    i   t   :t   sub_form_tokens*   The form is too old.  Please GET it again.sD   Please take a few seconds to fill out the form before submitting it.s3   The hidden token didn't match.  Did your IP change?sA   There was no hidden token in your submission or it was corrupted.s+   You must GET the form before submitting it.t   captcha_answers6   This was not the right answer to the CAPTCHA question.t   mischiefs    Attempt to self subscribe %s: %ss'   You may not subscribe a list to itself!t   pws   pw-confs.   If you supply a password, you must confirm it.s   Your passwords did not match.t   digestsV  Your subscription request has been received, and will soon be acted upon.
Depending on the configuration of this mailing list, your subscription request
may have to be first confirmed by you via email, or approved by the list
moderator.  If confirmation is required, you will soon get a confirmation
email which contains further instructions.s®   The email address you supplied is banned from this
        mailing list.  If you think this restriction is erroneous, please
        contact the list owners at %(listowner)s.sL   The email address you supplied is not valid.  (E.g. it must contain an
`@'.)sP   Your subscription is not allowed because the email address you gave is
insecure.sñ   Confirmation from your email address is required, to prevent anyone from
subscribing you without permission.  Instructions are being sent to you at
%(email)s.  Please note your subscription will not start until you confirm
your subscription.sÎ   Your subscription request was deferred because %(x)s.  Your request has been
forwarded to the list moderator.  You will receive email informing you of the
moderator's decision when they get to your request.s4   You already have a subscription pending confirmations   You are already subscribed.s   Mailman privacy alerts´  An attempt was made to subscribe your address to the mailing list
%(listaddr)s.  You are already subscribed to this mailing list.

Note that the list membership is not public, so it is possible that a bad
person was trying to probe the list for its membership.  This would be a
privacy violation if we let them do this, but we didn't.

If you submitted the subscription request and forgot that you were already
subscribed to the list, then you can ignore this message.  If you suspect that
an attempt is being made to covertly discover whether you are a member of this
list, and you are worried about your privacy, then feel free to send a message
to the list administrator at %(listowner)s.
t   langs+   This list does not support digest delivery.s(   This list only supports digest delivery.sG   You have been successfully subscribed to the %(realname)s mailing list.(L   t   GetOwnerEmailt	   real_nameR$   t   stript   appendR   R   t   canonstrt   ost   environt   getR    t   RECAPTCHA_SECRET_KEYt   urllib2t   Requestt   urllibt	   urlencodet   getvaluet   urlopent   jsont   loadt   closet
   COMMASPACEt   joint   URLErrort   reasont   SUBSCRIBE_FORM_SECRETt   intt   timet   findt   rsplitt   splitt
   ValueErrort   sha_newt   internal_namet	   hexdigestt   FORM_LIFETIMEt   SUBSCRIBE_FORM_MIN_TIMEt
   isinstancet   CAPTCHASt   dictt   captcha_verifyt   GetListEmailR   t   MakeRandomPasswordR%   t   digest_is_defaultt
   digestablet   nondigestablet   print_resultst   ERRORSEPt   private_rosterR   t	   AddMemberR   t   MembershipIsBannedt   MMBadEmailErrort   MMHostileAddresst   MMSubscribeNeedsConfirmationt   MMNeedApprovalt   strt   MMAlreadyPendingt   MMAlreadyAMembert   WARN_MEMBER_OF_SUBSCRIBEt   getMemberLanguageR   t   get_translationR   R   t   UserNotificationt   getMemberCPAddresst   GetBouncesEmailt   set_translationt   sendt   MMCantDigestErrort   MMMustDigestError(#   R   R-   R2   RF   t	   listownert   realnamet   resultsR4   R5   t   remotet   requestt   httprespt   captcha_responset   e_codesR0   t   e_reasont   nowt   remote1t   ftimet   fcaptcha_idxt   fhasht   thent   tokenRB   t   passwordt	   confirmedt
   digestflagRE   t   privacy_resultst   userdesct   xt   listaddrt   mlangt   otranst   msg(    (    s4   /export/web/mailman/mailman/Mailman/Cgi/subscribe.pyR+   x   s    				


		
(								
						c         C   sS   d | _  |  j | ƒ } | | d <|  j d | | ƒ } | j | ƒ | j ƒ  GHd  S(   Ni   s   <mm-results>s   subscribe.html(   t   suppress_headt   GetStandardReplacementst	   ParseTagsR   R   (   R   RŠ   R-   RF   t   replacementst   output(    (    s4   /export/web/mailman/mailman/Mailman/Cgi/subscribe.pyRr   _  s    	
(   t   __doc__R   RL   R"   R_   R)   RR   RP   RV   t   MailmanR    R   R   R   R   R   t   Mailman.UserDescR   t   Mailman.htmlformatt   Mailman.Logging.SyslogR   t   SLASHRs   RY   R   R   R   R3   R+   Rr   (    (    (    s4   /export/web/mailman/mailman/Mailman/Cgi/subscribe.pyt   <module>   s2   
		G	ç