
    z#gU                     0   S SK r S SKrS SKrS SKrS SKJrJrJrJr  S SK	r	S SK
r
S SKrS SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKrS	S
KJrJr  S	SKJrJrJr  S	SK J!r!  S	SK"J#r"  S	SK$J%r%  Sr&SRO                  \(" SS5       V s/ s H  n \)" U 5      PM     sn 5      r*\RV                  " S\RX                  " \*5      -   S-   5      r-\RV                  " S\RX                  " \*5      -   S-   5      r.S r/SS jr0S r1SS jr2       SS jr3gs  sn f )    N)runPopenSTDOUTPIPE)MIMEMultipart)MIMEText)	MIMEAudio)	MIMEImage)MIMEBase)MIMEMessage   )VERSIONVERSION_NUMBER)TempFileopen_write_safetempfile_prefix)	NoMessage)text_ui)get_email_addrF        z[^]z\s]c                  B    [         =(       d    [        R                  " U 6 $ N)quietlyuilog_message)argss    2/usr/lib/python3/dist-packages/reportbug/submit.pyewriter!   7   s    +bnnd++    c                    U(       d  [        U5      S   n[        [        US5      US9u  pgUR                  U 5        UR	                  5         [        [        US5      US9u  pUR	                  5         US:X  al  [
        R                  " U	5        S[
        R                  ;  a  SU-  n
OSU-  n
U
S	[        R                  " U	5      -   S
-   [        R                  " U5      -   -  n
O;SU-  n
U
S[        R                  " U5      -   S-   [        R                  " U	5      -   -  n
 [
        R                  " U
5        [        U	SSS9 nUR                  5       nSSS5        [
        R                  R                  U5      (       a  [
        R                  " U5        [
        R                  R                  U	5      (       a  [
        R                  " U	5        W(       d  [        eUn U $ ! , (       d  f       N= f! [        [         4 aH    [        [        U5      US9u  pUR                  U 5        UR	                  5         [#        SU5        Sn  U $ f = f)aA  
Sign message with pgp key

Parameters
----------
body : str
    body of the message to be signed
fromaddr : str
    email address of the sender. Ignored if pgp_addr is given.
package : str, optional
    name of the package affected by the bug
pgp_addr : str, optional
    email address identifying the ID with which to sign the message
sign : str, optional
    if set to 'gpg', GnuPG is used for signing, otherwise PGP
draftpath : str, optional
    directory to use for creating temporary files

Returns
-------
str
    a signed message body, or None if signing did not work.
r   unsignedprefixdirsignedgpgGPG_AGENT_INFOz"gpg --local-user '%s' --clearsign z.gpg --local-user '%s' --use-agent --clearsign z	--output  zpgp -u '%s' -fast<z >rbackslashreplace)errorsNz!gpg/pgp failed; input file in %s
)r   r   r   writecloseosunlinkenvironshlexquotesystemopenreadpathexistsr   OSErrorr!   )bodyfromaddrpackagepgp_addrsign	draftpathr$   file1r(   file2signcmdx
signedbodyfhtmpfile2s                  r    sign_messagerJ   ;   s   0 !(+A. !(LR[\XNN4NN ogx&HiXOV
LLNu}
		%2::-:XEGFQG;U!33c9EKK<NNN%03U++d2U[[5GGG
		'%%78AJ 9 77>>%  IIe77>>%  IIeO K# 98 w w'?YO


3X>Ks,   !!G1 G BG1  
G.*G1 1AI	I	c                     [        U 5      nUR                  5       S:X  aK  [        S U R                  5        5       5      S:  a'  [        R
                  R                  U5        US	 SUS'   U$ )Nus-asciic              3   8   #    U  H  n[        U5      v   M     g 7fr   )len).0lns     r    	<genexpr>$_MIMEText_wrapper.<locals>.<genexpr>   s     4"3BB"3s   i  zContent-Transfer-Encodingzquoted-printable)r   get_content_charsetmax
splitlinesemailencodersencode_quopri)textmsgs     r    _MIMEText_wrapperr[      se    
4.C
  J.4$//"344s:$$S) +,+='(Jr"   c                    [         R                  " 5         [        S5      n[        U 5      nUR	                  SS5        SUl        SUl        UR                  U5        SnU GHM  n [        U5      nUR                  5         S	n
[        S
SSSU/[        [        S9R!                  5       S   R#                  S5      nU(       a9  [$        R&                  " SU5      nU(       a  UR)                  5       u  pnSU
;  a  S	n
U
(       d  [         R*                  " USS9u  pU
(       d  Sn
U
R-                  SS5      u  nnUS:X  a1   [        US5       n[        UR/                  5       5      nS	S	S	5        GOUS:X  a4  [        US5       n[=        [6        R>                  " U5      US9nS	S	S	5        OUS:X  a.  [        US5       n[A        UR/                  5       US9nS	S	S	5        OUS:X  a.  [        US5       n[C        UR/                  5       US9nS	S	S	5        O_[3        UU5      n[        US5       nUR5                  UR/                  5       5        S	S	S	5        [6        R8                  R;                  U5        WR	                  SS[D        RF                  RI                  U5      S9  UR                  U5        GMP     XF4$ ! [         a%  n	[        SUU	R                  5        Sn S	n	A	GM  S	n	A	ff = f! , (       d  f       N= f! [0         au    [3        UU5      n[        US5       nUR5                  UR/                  5       5        S	S	S	5        O! , (       d  f       O= f[6        R8                  R;                  U5         GNf = f! , (       d  f       GN= f! , (       d  f       GN-= f! , (       d  f       GN?= f! , (       d  f       GNp= f)a  
Compose a Multipart MIME message from body text and attachments

Parameters
----------
body : str
    message body text
attachments : [str, ...]
    list of files to attach
charset
    ignored
body_charset
    unused

Returns
-------
(email.Message, bool)
    Tuple with MIME multipart message and a bool indicating whether
    an error occurred when attaching files (False means no errors)
mixedzContent-Dispositioninlinez6This is a multi-part MIME message sent by reportbug.

r   Fz"Warning: opening '%s' failed: %s.
TNfilez--mimez--briefz--dereference)stdoutstderrr   asciiz([^;, ]*)(,[^;]+)?(?:; )?(.*)/)strictzapplication/octet-streamr   rY   r-   rbmessage)_subtypeimageaudio
attachment)filename)%	mimetypesinitr   r[   
add_headerpreambleepilogueattachr8   r1   EnvironmentErrorr!   strerrorr   r   r   communicatedecoderematchgroups
guess_typesplitr9   UnicodeDecodeErrorr   set_payloadrV   rW   encode_base64r   message_from_binary_filer
   r	   r2   r:   basename)r=   attachmentscharsetbody_charsetrf   bodypartfailedrj   fpexctypeinforw   junkextrasencodingmaintypesubtypeparts                      r    mime_attachr      s    * NNG$G &H-x8QGGNN8F!
	j!BHHJ fh	?JO 11<qBBH&/ 	HH=tDE&+lln#Ve# E'225*OE.E!KKQ/'v3*c*b,RWWY7D +* "j$'2"5#A#A"#E,35 ('  j$'2 W= (' j$'2 W= (' Hg.Dj$'2  + (NN((.-|!#!1!1*!= 	 	?tk "l e   	8*;; F		2 +*% 3'2*d+r$$RWWY/ ,++,,T2	3 (' (' (' ('s   &J6>K9
K($K9 M;:N.N( N16
K% K  K%(
K6	2K96K99"M8 M;	M8
M&M87M8;
N
	
N	
N.	1
O 	c                    S=nnSnU(       a	  U(       a  SnU(       a  US:X  a  SnSn[        U5      nU(       a0  U(       d)  [        XU	U5      u  n nU(       a  [        S5        S=n=nnO[        U 5      n UU S'   UU S	'   U H  u  n!n"U"U U!'   M     U(       a  UU S
'   U(       a  UU S'   [        R
                  R                  SU5      nU(       a  UU S'   U
(       aL  [        R                  R                  S5      U S'   [        U S'   [        R                  R                  SS9U S'   OU(       a  U(       d  U(       d	  [        U S'   U R                  S	/ 5      U R                  S
/ 5      -   U R                  S/ 5      -    V#s/ s H  n#[        U#5      PM     n$n#[        R                  R                  U$5      n%U R                  S/ 5       V#s/ s H  n#[        U#5      PM     n&n#[        R                  R                  U&5      n'U&(       a  U S	 SR!                  U&5      n(U(U S'   U(       d  U(       d   U S	 U R%                  5       n U(       aD  U(       d=  U(       d6  [&        R(                  " U SS9  [&        R*                  " SSS5      (       d  S=nnSn)U(       d  U(       a  [,        R.                  n*GOU(       a  [1        UUS9u  n*n)GOU(       am  [        R2                  R5                  U5      n[        R2                  R7                  U5      (       a   [        R8                  " UUS-   5         [=        US5      n*GOwU(       a$  [        R2                  R7                  U5      (       d  U(       d  [1        UUS9u  n*nGO6U(       Ga.  [        R2                  R7                  U5      (       Ga	  U(       Gd   [        R>                  " 5       n#U% V-s/ s H  n-[B        RD                  " U-S!   5      PM     n.n-S"R!                  U.5      n/[        R                  RG                  U5      S!   n0Ub#  [        R                  RG                  U5      S!   n1OU0n1[        S#U5        U1S:X  a  [        RH                  " U S$U/ 3S5      n*O6[        RH                  " U< S%[B        RD                  " U15      < S$U/< 3S5      n*Sn[1        [        U5      US9u  n2n3U2RK                  U 5        U2RM                  5         U(       Ga  U% V#s/ s H  n#U#S!   PM
     n4n# URO                  S&5      u  nn5[Q        U55      n5Sn6Sn7S'n8U6(       Ga[  Sn6[        S(U5         Sn9URU                  5       S:X  a  [V        RX                  " US)5      n9O7U5S*:X  a  Sn[V        RZ                  " US*5      n9O[V        RX                  " UU55      n9U9R]                  5       n:S+U:S'   s=::  a  S,::  d  O  U9R_                  5         U(       aB  U9Ra                  5         U9R]                  5       n:S+U:S'   s=::  a  S,::  d  O  U9R_                  5         U(       a8  U(       d  [&        Rb                  " S-U< S.U< S/35      nU9Re                  UU5        U9Rg                  UU4U 5      n7U9Ri                  5         U6(       a  GM[  U7(       a0  U7Ru                  5        H  u  n<n=[        S6U<U=S'   U=S!   5        M     U3nO_ W*RK                  U 5        U*Rw                  5         U(       d  U*RM                  5       (       a!  U(       a  SnU3n[&        Rx                  " S75        U(       a  [        S8URz                  5        UR}                  U)U5      n>S'n? UR~                  (       d  [        U>SS99R                  n?O[&        R                  " U>5      n?U?S':X  a  GO[        S:5        S;n@S<nAS=S>S?.nB[&        R                  " U@UAUB5      n#U#S@:X  a  SnU3nOM}  U(       d  U(       d  U(       a  U(       a  [        SAU5        O[        SBU5        / nCU% H?  n<U<S!   [        R                  RG                  U5      S!   :w  d  M.  WCR                  U<5        MA     [        WC5      (       a   [        SC5        U$ H  nD[        SDUD5        M     U'(       a&  USE:X  a   [        SF5        U& H  nD[        SDUD5        M     U)(       a_  [        R2                  R7                  U5      (       a;  [        R2                  R7                  U)5      (       a   [        R                  " U)5        U3U:w  a   [        R                  " U35        U(       a>  [        R2                  R7                  U5      (       a  [&        R                  " SGU 35        gU(       dW  U(       dP  USE:X  aJ  U(       aC  SHU;   a=  U(       d6  U
(       a/  [        SI5        [&        R                  " SJUSH   SK-  USH   SL-  5        gs  sn#f s  sn#f ! ["         a     GNf = f! [:         a    [        SUU5         GNf = f! [:         a"    [1        UUS9u  n+n,[        SUU,5        U,nU+n* GNf = f! [:         a    [        R@                  " S 5         GNf = fs  sn-f s  sn#f ! [R         a    S'n5 GNWf = f! [j        Rl                  [V        Rn                  4 a{  n;[q        U;[V        Rr                  5      (       a#  [        S05        Sn6SnU8S!-  n8U8S1::  a   Sn;A;GM  Sn6[&        R*                  " S2U; S33S4S55      (       a	  Sn6 Sn;A;GM  SnU3n Sn;A;GNSn;A;ff = f! [:         a    SnW*RM                  5          GNYf = f! ["         a     GN?f = f! ["         a     GN3f = f)Ma	  Send a report

This function handles all variants supported by reportbug of
'sending' a report, including:
 - passing to a local MUA (mutt, thunderbird, evolution etc.),
 - submitting through a remote smarthost,
 - passing to a local MTA (exim, sendmail etc.),
 - saving to a file,
 - piping the message to standard output.

Parameters
----------
body : str
    message body text
attachments : [str, ...]
    list of files to attach
mua : reportbug.utils.Mua()
    mail user agent to use for submitting the report
fromaddr : str
    Mail address to use in the From: header
sendto : str
    recipient address
ccaddr : str
    mailaddress to put in CC: header
bccaddr
    mailaddress to put in BCC: header
headers : [(str, str), ...]
    list of (header, value) tuples
package : str, optional
    name of the package the report is about
charset : str, optional
    passed to mime_attach
mailing : bool, optional
    if True, create Message-ID, X-Mailer and Date headers
sysinfo : dict, optional
    dictionary with system info
rtype : str, optional
    should be 'debbugs' for best results
exinfo : str or bool, optional
    whether the message is extra info on an existing bug (followup)
    or not
replyto : str, optional
    mailaddress to put in Reply-To: header. If there is REPLYTO
    environment variable, the value of the variable will be used
    instead.
printonly : bool, optional
    if True, do not send the report, just print it to standard
    output
template : bool, optional
    if True, do not send the report, just print it to standard
    output (same effect as `printonly`)
outfile : str, optional
    name of a file to which to write the message
mta : str, optional
    path of a mail transfer agent to use
kudos : bool, optional
    if True, indicates the message is meant as appreciation mail to
    the maintainer rather than bug information
smtptls : bool, optional
    if True, try to use TLS during submission to smtp host
smtphost : str, optional
    host name of the SMTP host
smtpuser : str, optional
    user name to use for authentication at the SMTP host
smtppasswd : str, optional
    password to use for authentication at the SMTP host
paranoid : bool, optional
    if True, view the report in a pager again and ask for
    confirmation before finally submitting
draftpath : str, optional
    directory where to store temporary files
envelopefrom : str, optional
    sender address to use in envelope when using a local mta

Returns
-------
None
Fr   zreportbug.debian.orgzpackages.debian.orgzutf-8z,Error: Message creation failed, not sending
NFromToCcBccREPLYTOzReply-To	reportbugz
Message-IDzX-MailerT)	localtimeDatezX-Reportbug-VersionzX-Debbugs-Ccz, )presubjz"Does your report seem satisfactoryzYes, send it.zNo, don't send it.r%   ~z$Unable to rename existing %s as %s~
wz'Writing to %s failed; using instead %s
rc   r   r+   zSending message via %s...
z
 -oi -oem z -f :r   zConnecting to %s via SMTP...
iK  i     i+  zEnter SMTP password for @z: z/SMTP error: authentication failed.  Try again.
   zSMTP send failure: zC. You can retry, or save the report and exit. Do you want to retry?zYes, please retry.zNo, save and exit.z#Unable to send report to %s: %d %s
z>Error: send/write operation failed, bug report will be saved.
zSpawning %s...
)shellzMMutt users should be aware it is mandatory to edit the draft before sending.
z9Report has not been sent yet; what do you want to do now?EqzEdit the message.z3Quit reportbug; will save the draft for future use.)eqr   z
Message sent to: %s
z
Bug report submitted to: %s
zCopies sent to:
z  %s
debbugsz)Copies will be sent after processing to:
z_Bug report written to a temporary file.
You can resume the unsent report using:
  reportbug -r rV   
a  If you want to provide additional information, please wait to receive the bug tracking number via email; you may then send any extra information to %s (e.g. %s), where n is the bug number.  Normally you will receive an acknowledgement via email including the bug report number within an hour; if you haven't received a confirmation, then the bug reporting process failed at some point (reportbug or MTA failure, BTS maintenance, etc.).
nnnnnnn)Ir   r   r!   r[   r2   r4   getrV   utils
make_msgidr   
formatdater   get_allstrgetaddressesjoin	Exception	as_stringr   display_reportyes_nosysr`   r   r:   
expanduserr;   renamer<   r   getcwdchdirr5   r6   	parseaddrpopenr0   r1   rz   int
ValueErrorlowersmtplibSMTPSMTP_SSLehlohelostarttlsget_passwordloginsendmailquitsocketerrorSMTPException
isinstanceSMTPAuthenticationErroritemsflushdisplay_failure
executableget_send_commandneeds_terminalr   
returncoder7   select_optionsappendrN   r3   long_messagefinal_message)Er=   r   muar>   sendtoccaddrbccaddrheadersr?   r   mailingsysinfortypeexinforeplyto	printonlytemplateoutfilemtakudossmtptlssmtphostsmtpuser
smtppasswdparanoidrB   envelopefromr   using_sendmailmsgnamer   tfprefixrf   headervaluerF   addrsalistcclist
debbugs_ccaddrlistrk   piperH   
newmsgnameamalistjalistfaddrenvfrombackupfh
backupnametoaddrssmtpporttryagainrefusedretryconnresponser   addrerrsendcmdreturnvaluemtitlemopts	moptsdesc	addressesaddresssE                                                                        r    send_reportr     s	   l $#F^G
x 33(Lw'H3'7LQ&BC#''C'##D) GFOGDM" #  jjnnY0G%
 % 6 6{ C%
++0040@	i8)7%&%oodB7 'b 9: 'r :; = ;SV ;E = KK$$U+E%oonbABAc!fAFB))&1JN#99V$"* 3	 !GY
'40yy=.0 0!!HsH9zz	!yAh	''$$W-77>>'"")		'7S=1
	"7C0D rww~~c**x i@g
"''..%%x			A .33U%++ad#U3&!%%h/2#kk++L9!<GG,c2b=88se:fX6<D88U[[)63479D $?7+CSHjNN7NN!&'A1Q4'	!)!4Hh8}H H3X>0) >>#'=="<<#6D_"G"++Hc:D"<<(;D99;x{1c1IIKMMO#yy{H8A;5#5		%%'__%x1&2
 JJx4--'7C		= hl &}}s=tSV1v  / !G	JJwJJL
 djjll~F G`a
!3>>2&&x=%%!'6AA ii0acdPFE1SUI!!&%;ACx$# & 8,f54f=	DAw%++//7::  &  y>>&' x) ! %9,?@!x) "
 BGGNN7++x0H0H	IIh W	IIj! 277>>'**
 **14 	5"  5I#5'gQXFXagt
$ W#ww'7('B	E _=
 C  		(  )>))
  	%X9ENB
 ()0*> G D	  	HHSM	 4, (
  	H	J LL'"7"78 )b'"A"ABBMN#H!%JQJEz #( 9922$6yz113 3  $H!F(G))@  	FJJL	t  		  		s   ?g	g.g g- *h /h: #i!2i&i+  Ei> !l  ;m m 
g*)g*-hh(h76h7: ii+i;:i;>$l"9l"%lll m ?m 
mm
m"!m")rF   Nr)   Nr   )rF   rL   TNr   NNFFNr   FF	localhostNNFNN)4r   r2   rv   r5   
subprocessr   r   r   r   rV   r   r   email.mime.multipartr   email.mime.textr   email.mime.audior	   email.mime.imager
   email.mime.baser   email.mime.messager   rl   __init__r   r   	tempfilesr   r   r   
exceptionsr   r   r   r   r   r   r   rangechrascii_rangecompileescapenotascii	notascii2r!   rJ   r[   r   r  )ais   0r    <module>r$     s   ,  	 	  / /    . $ & & $ *  - A A  !
ggr382s2w89::ebii44s:;JJuryy55>?	
,BJ"Tp CGFK<A(3JN!sq 9s   D