Ϫfh(^dZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZmZddlmZd Zej(j+d Zd Zd Zeej2Zee ZGddZdZedZdZ GddZ!dZ"dZ#da$dZ%dZ&dZ'dZ(dZ)y)z4 Implementation module for the I{mailmail} command. N) ConfigParser)StringIO)version)reactor)LoggertextFileLogObserver)smtpz /etc/mailmailz~/.twisted/mailmailz 127.0.0.1zSubject: Failed Message Delivery Message delivery failed. The following occurred: %s -- The Twisted sendmail application. )observerceZdZdZy)Optionsat Store the values of the parsed command-line options to the I{mailmail} script. @type to: L{list} of L{str} @ivar to: The addresses to which to deliver this message. @type sender: L{str} @ivar sender: The address from which this message is being sent. @type body: C{file} @ivar body: The object from which the message is to be read. N)__name__ __module__ __qualname____doc__?/usr/lib/python3/dist-packages/twisted/mail/scripts/mailmail.pyr r (s rr cr tjS#t$rtjcYSwxYwN)osgetlogin BaseExceptiongetpassgetuserrrrrr8s/!{{} !  !s 66zUnsupported option.cdt}|Dcgc]}|jdr|c}|_t|_d|vrt dt td|vrtd|vrtd|vrA||jddz|_|jj|jd|vsd |vrtd |vrd |_ nd |_ d |vrd |_ nd |_ d|vsd|vrd |_ nd |_ d|vrtd|vr d |_ |j|_g|_nd |_ g|_gggggd}t!} d}t"j$j'}|j)sn|j+dd}|dj-}|jrK|dvrG|jj/t0j2j5|ddg|dk(r2d}n/|dk(r*t0j2j5|dd|_||vr||j7|d|r|j9| |ds|j9d|jd|dsP|js td|j9dj;dj=|j|ds'|j9dt?j@d|j9||jr-|jD]} |jj|  |jEddt!|jGt"j$jIz|_%|Scc}w#tB$rYwxYw) N-z --versionzmailmail version:z-bpz-bsz-Fz-iz-oiz-odbTFz-odfz-oepz-epz-omz-t)fromtoccbccdatez: r)rr r!r!rzFrom: z rzNo recipients specified.zTo: {} z, r"zDate: )&r startswithrrsenderprintr SystemExit_unsupportedOptionindexremove background printErrorsrecipientsFromHeadersexcludeAddressesexludeAddressesrsysstdinreadlinestripsplitlowerextendemailutils parseaddrappendwriteformatjoinr rfc822daterseekgetvaluereadbody) argvoerequiredHeadersbufferr:linehdrshdras r parseOptionsrKBsb A 5!1<<#4A 5ADzAHd !7+l }   }   t| 4(1,-  AHH  %4-  ~  ~  $ETM   }   t|"&TT"' OZF yy!!#zz| zz$"1gmmo " "s.A'A DDKK..tAw7:; <e| F]{{,,T!W5a8AH / ! C ' 'Q 0  LL ) , 6 " vahhZt,- 4 tt78 8 \((1449: 6 " vdoo/056 LL## A  A   KK1 foo'#))..*:: ;AF Hk 6`!  sNN0N## N/.N/ceZdZdZdZy) Configurationa @ivar allowUIDs: A list of UIDs which are allowed to send mail. @ivar allowGIDs: A list of GIDs which are allowed to send mail. @ivar denyUIDs: A list of UIDs which are not allowed to send mail. @ivar denyGIDs: A list of GIDs which are not allowed to send mail. @type defaultAccess: L{bool} @ivar defaultAccess: L{True} if access will be allowed when no other access control rule matches or L{False} if it will be denied in that case. @ivar useraccess: Either C{'allow'} to check C{allowUID} first or C{'deny'} to check C{denyUID} first. @ivar groupaccess: Either C{'allow'} to check C{allowGID} first or C{'deny'} to check C{denyGID} first. @ivar identities: A L{dict} mapping hostnames to credentials to use when sending mail to that host. @ivar smarthost: L{None} or a hostname through which all outgoing mail will be sent. @ivar domain: L{None} or the hostname with which to identify ourselves when connecting to an MTA. cg|_g|_g|_g|_d|_d|_i|_d|_d|_d|_ y)NdenyT) allowUIDsdenyUIDs allowGIDsdenyGIDs useraccess groupaccess identities smarthostdomain defaultAccess)selfs r__init__zConfiguration.__init__sJ   ! !rN)r rrrr[rrrrMrMs 6 "rrMc ht}tj|tjs|St }|j ||j }|j}|j}|j}d||fd||ffD]\}}} |j|sd|fd| ffD]n\} } |j|| s|j|| s,|j|| jdD]} t| } | j| !p|j|d } | jdDcgc]}|j)c}Dcgc]}|j} }| ddk(rt+||dt+||d|jd r`|j-d D]L\}}|jd d }t/|d k7rt"j%d|>||j0|<N|jdrR|jddr|jdd|_|jddr|jdd|_|S#t $r.t"j%d|dj'|| YwxYwcc}wcc}w)NrTrUallowrO,z6Illegal {prefix}ID in [{section}] section: {sectionID}r)prefixsection sectionIDorderidentity:rz.Illegal entry in [identity] section: {section})r` addressesrWdefault_domain)rMraccessR_OKrr@rPrQrRrS has_section has_optiongetr3intr9 ValueError_logerrorupperr4setattritemslenrVrWrX)pathcpauduagdgr`rJdmodeLrarbshostuppartss r loadConfigrst A 99T277 #AFF4L B B B B'R0="b2IJ, A == !$aL61+6 0a<<.155$3G%&UU7D%9%?%?%D 0  0(+IIHHY/ 0 0EE'7+EJ*J/03J' &J' c,tjyrrstop)results rsuccessr,s  LLNrc0tj|ayr)rrfailed)fs rfailurer3s LLN Frctj||j|j|j}|j t ttjyr) r sendmailr$rrA addCallbacksrrrrun)roptionsidentr|s rrr9s9 dGNNGJJ EANN7G$ KKMrcj|jg}djtjdtj j d}t}|j|tt|jz}t jd|||}|jdy)Nz2"Internally Generated Message ({})"rasciifile localhostc*tjSrr)_s rzsenderror..Hs  r) r$r;r/rBr DNSNAMEdecoderprintTraceback ERROR_FMTr?raddBoth)rr recipientr$rprAr|s r senderrorr?s I A H H  T\\((1F JE & I 00 1D k69d;AII&'rctj}tj}|jdk(r||jvry||j vry||j vry||jvry|j dk(r+||jvry||jvry|j S||jvry||jvry|j S)NrOTF) rgetuidgetgidrTrQrPrUrSrRrY)confuidgids rrOrOKs ))+C ))+C & $--  $..  $..  $--  6! $--  $.. !! !! $..  $-- !! !!rcttjdd}tt}tt }t |s t |rtjdy|jxs|jxst}|jj}|j|j|jr|jt_n!|jr|jt_t#|||t$rL|j&r/t$j)tj*t-dt/t$|yy)NrzPermission deniedr)rKr/rBr GLOBAL_CFG LOCAL_CFGrOrorprW SMARTHOSTrVcopyupdaterXr rrrr+rstderrr&r)rCgConflConfrrs rrrhsSXXab\"A z "E y !E E{d5k &' ?? :eoo :D    ! ! #E LL!!" |||| ||  T1e ==  ! !szz ! 2Q-  fa r)*r email.utilsr6rrr/ configparserriortwisted.copyrightrtwisted.internetrtwisted.loggerrr twisted.mailr rru expanduserrrrr _logObserverror rr&r'rKrMrrrrrrrOrrrrrs   %%$6  GG  4 5    #3::.  |$   ! 56w t("("VB J   (":!r