+
    oFjUZ                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ]
P0                  P3                  RR4      t]
P0                  P3                  RR4      t^tR	tR
t ! R R]P>                  P@                  4      t!R R lt"R R lt#R R lt$R R lt%R R lt&R t'R R lt(R R lt)R R lt*R R lt+]PX                  ! R 4      t-R! R" lt.]P^                  R# R$ l4       t0R% R& lt1R' R( lt2R) R* lt3R+ R, lt4R- R. lt5R/ R0 lt6R1 R2 lt7R3 R4 lt8R5 R6 lt9RVR7 R8 llt:R9 R: lt;]P^                  R; R< l4       t<RWR= lt=R> R? lt>R@ RA lt?RB RC lt@RD RE ltARF RG ltBRVRH RI lltCRXRJ RK lltDRL RM ltERN RO ltFRP RQ ltGRR RS ltHRT RU ltIR# )Yz0Functions to manage apport problem report files.N)IO)impl)ProblemReportAPPORT_REPORT_DIRz
/var/crashAPPORT_COREDUMP_DIRz/var/lib/apport/coredumpz~/.config/apport/settingsz/run/snapd.socketc                   8   a  ] tR t^/t o R tV 3R lR ltRtV tR# )UHTTPConnectionc                f    \         P                  P                  P                  V R 4       Wn        R# )	localhostN)httpclientHTTPConnection__init__path)selfr   s   &&2/usr/lib/python3/dist-packages/apport/fileutils.pyr   UHTTPConnection.__init__0   s!    ""++D+>	    c                   < V ^8  d   QhRR/# )   returnN )format__classdict__s   "r   __annotate__UHTTPConnection.__annotate__4   s       r   c                    \         P                   ! \         P                  \         P                  4      pVP                  V P                  4       Wn        R # N)socketAF_UNIXSOCK_STREAMconnectr   sock)r   r"   s   & r   r!   UHTTPConnection.connect4   s1    }}V^^V-?-?@TYY	r   )r   r"   N)__name__
__module____qualname____firstlineno__r   r!   __static_attributes____classdictcell__)r   s   @r   r   r   /   s      r   r   c                $    V ^8  d   QhR\         /# r   r   )bool)r   s   "r   r   r   :   s     	 	4 	r   c                     \         P                  ! R\         P                  4      '       g   R#  . ROp \        P                  ! V 4      ^ 8H  #   \
         d     R# i ; i)z)Check whether crash reporting is enabled.z/usr/bin/whoopsieTF)z/bin/systemctlz-qz
is-enabledzwhoopsie.path)osaccessX_OK
subprocesscallOSError)cmds    r   allowed_to_reportr5   :   sK    99("''22Es#q(( s   A AAc                >    V ^8  d   QhR\         R\         R,          /# )r   	dbus_addrr   Nstr)r   s   "r   r   r   F   s      s sTz r   c                    V '       g   R# V P                  R4      '       g   R# RV 9   d   R# R F  pW9   g   K   R# 	  V P                  R4      p\        V4      ^8w  d   R# V^,          # )z'Extract the socket from a DBus address.Nzunix:path=/run/user/z../=)%,;)
startswithsplitlen)r7   searchpartss   &  r   get_dbus_socketrD   F   sh      677 	 " " OOC E
5zQ8Or   c                L    V ^8  d   QhR\         R,          R\         R,          /# )r   packageNr   r8   )r   s   "r   r   r   `   s"      cDj S4Z r   c                   V f   R# Rp\         P                  ! V 4       F  pVP                  R4      '       g   K  VP                  R4      '       g   VP                  R4      '       g   KL  V'       d    R#  \	        VR4      ;_uu_ 4       pRVP                  4       9  d   TpRRR4       K  	  V#   + '       g   i     K  ; i  \         d     K  i ; i)zReturn a package's .desktop file.

If given package is installed and has a single .desktop file, return the
path to it, otherwise return None.
Nz.desktopz/etc/xdg/autostartz/usr/share/applications/rbs   NoDisplay=true)	packaging	get_filesendswithr?   openreadFileNotFoundError)rF   desktopfilelinefs   &   r   find_package_desktopfilerR   `   s     K##G,==$$??#788*B B $%%(8&* &% -&  &%% % s0   7CB1#C1C<CCCCc                0    V ^8  d   QhR\         R\        /# )r   filer   r9   r,   )r   s   "r   r   r      s      # $ r   c                    . ROpRpV F  pV P                  V4      '       g   K  Rp M	  T;'       d5    V P                  R4      '       * ;'       d    V P                  R4      '       * # )a  Check whether the given file is likely to belong to a package.

This is semi-decidable: A return value of False is definitive, a True value
is only a guess which needs to be checked with find_file_package().
However, this function is very fast and does not access the package
database.
FTz/usr/local/z	/var/lib/)	z/bin/z/bootz/etc/z/initrdz/libz/sbin/z/optz/usr/z/var)r?   )rT   pkg_allowlistallowlist_matchis   &   r   likely_packagedrZ      sm    
M O??1"O 
 	 	- 	-..	- 	-,,r   c                >    V ^8  d   QhR\         R\         R,          /# )r   rT   r   Nr8   )r   s   "r   r   r      s     , ,C ,C$J ,r   c                \   \         P                  P                  V 4      w  r\         P                  P                  V4      p\         P                  P	                  V4      '       d    \         P                  P                  W24      p \        V 4      '       g   R# \        P                  ! V 4      # )zSReturn the package that ships the given file.

Return None if no package ships it.
N)	r.   r   r@   realpathisdirjoinrZ   rI   get_file_package)rT   	directorynameresolved_dirs   &   r   find_file_packagerd      sp     ggmmD)OI77##I.L	ww}}\""ww||L/4  %%d++r   c                    \         P                  ! \        \        4      4      ;_uu_ 4       pRV  2pVP	                  RV4       VP                  4       pVP                  ^8X  d6   \        P                  ! VP                  4       4      R,          uuRRR4       #  RRR4       R#   + '       g   i     R# ; i  \        P                  P                  \        P                  \        3 d     R# i ; i)zZReturn the data of the given snap.

Return None if the snap is not found to be installed.
z
/v2/snaps/GETresultN)
contextlibclosingr   SNAPD_SOCKETrequestgetresponsestatusjsonloadsrM   r   r   HTTPExceptionJSONDecodeErrorr3   )snapcurlresponses   &   r   	find_snaprv      s    
 =>>!tf%CIIeS!}}H#%zz(--/28< ?> &	 ?  ?>  KK%%t';';WE s5   +B: A#B&
B: B: &B7	1B: 7B: :4C21C2c                0    V ^8  d   QhR\         R\        /# r   reportr   rU   )r   s   "r   r   r      s     < < < <r   c                    \         P                  ! V 4      pVP                  VP                  8  ;'       g    VP                  ^ 8H  # )zACheck whether the report file has already been processed earlier.)r.   statst_atimest_mtimest_size)ry   sts   & r   seen_reportr      s2    	BKK"++%;;2::?;r   c                (    V ^8  d   QhR\         RR/# r   ry   r   Nr8   )r   s   "r   r   r      s     
 
s 
t 
r   c                 ,   V P                  R ^4      ^ ,           R2pV P                  R ^4      ^ ,           R2p\        P                  P                  V4      '       d   \        P                  P                  V4      '       d^   \        P                  ! V 4      p\        P                  ! V4      pVP
                  VP
                  8  d   \        P                  ! V4       \        VRRR7      ;_uu_ 4         RRR4       R#   + '       g   i     R# ; i).z.uploadz	.uploadedautf-8encodingN)rsplitr.   r   existsr{   r}   unlinkrL   )ry   uploaduploaded	report_st	upload_sts   &    r   mark_report_uploadr      s    c1%a()1F--Q'*+95H	ww~~hBGGNN6$:$:GGFO	GGFO		 2 22IIf	fcG	,	, 
-	,	,	,s   6DD	c                4    V ^8  d   QhR\         R\        RR/# )r   ry   pidr   N)r   int)r   s   "r   r   r      s!     
 
 
S 
T 
r   c                 `   R V 9   d   V R ,          P                  RR4      pM\        R4      h\        P                  ! 4       pV R\	        V4       RV R2p\        P
                  P                  \        V4      p\        VRRR7      ;_uu_ 4         R	R	R	4       R	#   + '       g   i     R	# ; i)
ExecutablePath/_z1report does not have the ExecutablePath attributer   z.hangingr   r   r   N)	replace
ValueErrorr.   geteuidr9   r   r_   
report_dirrL   )ry   r   subjectuidbaser   s   &&    r   mark_hanging_processr      s    6!)*223<LMM
**,CYaCz3%x0D77<<
D)D	dC'	*	* 
+	*	*	*s   BB-	c                (    V ^8  d   QhR\         RR/# r   r8   )r   s   "r   r   r      s     " "S "T "r   c                P   \         P                  ! V 4      p \         P                  ! WP                  VP                  ^,
          34       R#   \         d    ^pT^ 8  d   \        T RR7      ;_uu_ 4       pTP                  ^4       RRR4       M  + '       g   i     M; i \         P                  ! T 4      pM  \         d      R# i ; iTP                  TP                  8  d   M!\        P                  ! R4       T^,          pK  T^ 8X  d   \        T 4        R#  R# i ; i)zMark given report file as seen.r   r   Ng?)r.   r{   utimer}   r3   rL   rM   r|   timesleepdelete_report)ry   r   timeoutreport_files   &   r   mark_report_seenr      s    	B"
++r{{Q78 "
 kfw//;  # 0///WWV_  {{R[[(JJsOqLGa<&! '"sN   3A )D%6B	D%B!D%%B<;D%<CD%CAD%$D%zH^\s*(?P<name>[A-Z0-9_]+)\s+(?P<quote>[\"\']?)(?P<value>.*)(?P=quote)\s*$c                f    V ^8  d   QhR\         P                  R\        \        \        3,          /# )r   linesr   )ioTextIOWrapperdictr9   )r   s   "r   r   r     s(      R-- $sCx. r   c                     / pV  FD  p\         P                  V4      pV'       g   K"  VP                  R 4      WP                  R4      &   KF  	  V# )valuerb   )_LOGIN_DEFS_REmatchgroup)r   defsrP   r   s   &   r   _parse_login_defsr     sH    D$$T*$)KK$8[[ !	 
 Kr   c                F    V ^8  d   QhR\         \        \        3,          /# r+   )r   r9   )r   s   "r   r   r     s      S#X r   c                      \        RRR7      ;_uu_ 4       p \        V 4      uuRRR4       #   + '       g   i     R# ; i  \         d    / u # i ; i)z?Parse /etc/login.defs and return a dictionary with its content.z/etc/login.defsr   r   N)rL   r   rN   )login_defs_files    r   get_login_defsr     sA    #g66/$_5 7666 	s(   A -
A >	A A AAc                $    V ^8  d   QhR\         /# r+   r   )r   s   "r   r   r            r   c                 h     \        \        4       R,          4      #   \        \        3 d     R# i ; i)zBReturn maximum system group ID (SYS_GID_MAX from /etc/login.defs).SYS_GID_MAX  r   r   KeyErrorr   r   r   r   get_sys_gid_maxr     1    >#M233j!     11c                $    V ^8  d   QhR\         /# r+   r   )r   s   "r   r   r   "  r   r   c                 h     \        \        4       R,          4      #   \        \        3 d     R# i ; i)zAReturn maximum system user ID (SYS_UID_MAX from /etc/login.defs).SYS_UID_MAXr   r   r   r   r   get_sys_uid_maxr   "  r   r   c                :    V ^8  d   QhR\         \        ,          /# r+   listr9   )r   s   "r   r   r   *  s      c r   c                    . p \         P                   ! \        P                  P                  \        R4      4       F}  p \        P                  P                  V4      ^ 8  dV   \        P                  ! V\        P                  \        P                  ,          4      '       d   V P                  V4       K{  K}  K  	  V #   \         d     K  i ; i)zCReturn a list with all report files accessible to the calling user.*.crash)globr.   r   r_   r   getsizer/   R_OKW_OKappendr3   reportsrs     r   get_all_reportsr   *  s    GYYrww||J	:;	wwq!A%"))Arww7H*I*Iq! +J% < N	  	 	s   A#B>#B>>CCc                :    V ^8  d   QhR\         \        ,          /# r+   r   )r   s   "r   r   r   8  s      c r   c                     . p \        4        F(  p \        V4      '       g   V P                  V4       K(  K*  	  V #   \         d     K<  i ; i)zGet new reports for calling user.

Return a list with all report files which have not yet been processed
and are accessible to the calling user.
)r   r   r   r3   r   s     r   get_new_reportsr   8  sR     G	q>>q! "  N	  	 	s   ";A
	A
c                :    V ^8  d   QhR\         \        ,          /# r+   r   )r   s   "r   r   r   J  s      S	 r   c                    . p \        4       p\        P                  ! \        P                  P	                  \
        R4      4       F  p \        P                  ! V4      pVP                  ^ 8  dl   VP                  V8:  dY    \        P                  ! VP                  4      pVP                  P                  R4      '       d   K   V P                  V4       K  K  K  	  V #   \         d     L(i ; i  \         d     K  i ; i)a  Get all system reports.

Return a list with all report files which belong to a system user.
The maximum system user group ID is taken from SYS_UID_MAX from
/etc/login.defs (defaults to 999 on Debian based systems and LSB
specifies 499 in "User ID Ranges").
r   guest)r   r   r.   r   r_   r   r{   r~   st_uidpwdgetpwuidpw_namer?   r   r   r3   )r   sys_uid_maxr   r   pws        r   get_all_system_reportsr   J  s     G!#KYYrww||J	:;	BzzA~")){":bii0Bzz,,W55  6
 q! #;~ <$ N     	 	s7   	8C2A C!C2!C/,C2.C//C22D Dc                :    V ^8  d   QhR\         \        ,          /# r+   r   )r   s   "r   r   r   i  s     G GS	 Gr   c                 f    \        4        U u. uF  p \        V 4      '       d   K  V NK  	  up # u up i )a!  Get new system reports.

Return a list with all report files which have not yet been processed
and belong to a system user. The maximum system user group ID is taken
from SYS_UID_MAX from /etc/login.defs (defaults to 999 on Debian based
systems and LSB specifies 499 in "User ID Ranges").
)r   r   )r   s    r   get_new_system_reportsr   i  s)     ./F/!{1~AA/FFFs   ..c                (    V ^8  d   QhR\         RR/# r   r8   )r   s   "r   r   r   t  s     
 
# 
$ 
r   c                     \         P                  ! V 4       R#   \         dJ    \        T RRR7      ;_uu_ 4       pTP	                  ^ 4       RRR4        R#   + '       g   i      R# ; ii ; i)zDelete the given report file.

If unlinking the file fails due to a permission error (if report_dir is not
writable to normal users), the file will be truncated to 0 bytes instead.
wr   r   N)r.   r   r3   rL   truncate)ry   rQ   s   & r   r   r   t  sM    
		& &#00AJJqM 1000s&    !A.AA.A*#A.*A.c                F    V ^8  d   QhR\         \        ,          R\        /# rx   )r   bytesr   )r   s   "r   r   r     s      r%y S r   c                n   \        4       pVP                  V RRR.R7        \        VR,          4      p\        P                  ! \        P
                  ! VR,          4      4      p\        P                  ! \        P                  ! 4       4      pWC,
          R8  d   ^ # V#   \        \        3 d     ^ # i ; i)zReturn the number of recent crashes for the given report file.

Return the number of recent crashes (currently, crashes which happened more
than 24 hours ago are discarded).
FCrashCounterDate)
key_filteriQ )	r   loadr   r   mktimestrptime	localtimer   r   )ry   prcountreport_timecur_times   &    r   get_recent_crashesr     s     
BGGFE~v&>G?	B~&'kk$--6
";<;;t~~/0!I-! s   A9B B B43B4c                4    V ^8  d   QhR\         R\        RR/# r   ry   filenamer   Nr   r9   )r   s   "r   r   r     s!     
4 
4M 
4S 
4T 
4r   c                   \        V4      '       g   R# \        P                  ! V\        P                  \        P                  ,          \        P
                  ,          4      p\        P                  ! V4      p\        P                  ! VP                  4      '       dK   \        P                  ! VR4      ;_uu_ 4       p\        V4      ^,           pRRR4       \        X4      V R&   R# R#   + '       g   i     L"; i)z/Increment the crash counter if report was seen.NrH   r   )r   r.   rL   
O_NOFOLLOWO_RDONLY
O_NONBLOCKfstatr{   S_ISREGst_modefdopenr   r9   )ry   r   fdr   rQ   crash_counters   &&    r   increment_crash_counterr    s    x  	2==2;;6F	GB	"B||BJJYYr4  A.q1A5M !!$]!3~    s   >C++C;	c                v    V ^8  d   QhR\         R\        \        ,          R,          R\        \        ,          /# )r   ry   r   Nr   )r   r   r9   r   r   )r   s   "r   r   r     s/      ] sT1A RPUY r   c                Z   RV 9   d   V R,          P                  RR4      pM3RV 9   d"   V R,          P                  R^4      ^ ,          pM\        R4      hVf   \        P                  ! 4       p\        P
                  P                  \        V R\        V4       R24      p\        VR	4      # )
a#  Construct a canonical pathname for a report and open it for writing.

If uid is not given, it defaults to the effective uid of the current
process. The report file must not exist already, to prevent losing
previous reports or symlink attacks.

Return an open file object for binary writing.
r   r   r   PackageNz7report has neither ExecutablePath nor Package attributer   z.crashxb)
r   r@   r   r.   r   r   r_   r   r9   rL   )ry   r   r   r   s   &&  r   make_report_filer    s     6!)*223<	f	#))$215RSS
{jjl77<<
wiqS
&$ABDdr   c                F    V ^8  d   QhR\         R\        \         ,          /# )r   sumfiler   )r9   r   )r   s   "r   r   r     s      S T#Y r   c           	        \         P                  P                  V 4      '       g   Q h\        P                  ! RRV .R\        P
                  \        P
                  R/ R7      pVP                  ^ 8X  d   . # . pVP                  P                  4       P                  4        FD  pVP                  R4      '       g   K  VP                  VP                  R^4      ^ ,          4       KF  	  V# )zCheck file integrity against md5 sum file.

sumfile must be md5sum(1) format (relative to /).

Return a list of files that don't match.
z/usr/bin/md5sumz-cFr   )checkstdoutstderrcwdenvFAILED:)r.   r   r   r1   runPIPE
returncoder  decode
splitlinesrK   r   r   )r  md5sum
mismatchesrP   s   &   r   check_files_md5r    s     77>>'""""^^	D'*F A	J$$&113==""dkk#q1!45 4 r   c                D    V ^8  d   QhR\         R\        P                  /# r   r   r   )r9   configparserConfigParser)r   s   "r   r   r     s       S \%>%> r   c                    \         P                  ! R R7      pRpR pR p \        P                  ! V \        P                  \        P
                  ,          4      p\        P                  ! V4      p\        P                  ! VP                  4      '       d)   \        P                  ! VR4      pVP                  R4      pTe   TP                  4        MTe   \        P                  ! T4        TP                  T4       T#   \         d     LPi ; i  Te   TP                  4        i Te   \        P                  ! T4       i i ; i  \         P                   d     T# i ; i)N)interpolation r   i  )r!  r"  r.   rL   r   r   r  r{   r  r  r  rM   r3   closeread_stringMissingSectionHeaderError)r   configcontentsr  rQ   r   s   &     r   _get_config_parserr+    s   &&T:FH	BAWWT2==2;;67XXb\<<

##		"c"Avvc{H =GGI^HHRL8$ M   =GGI^HHRL 
 11 Ms6   BD  -E  DD DD 2EEEc                d   V'       gG   \         P                  ! \        P                  ! 4       4      ^,          p\        P                  RV4      p\        V4      p V'       d   VP                  W4      # VP                  W4      #   \        P                  \        P                  3 d    Tu # i ; i)zReturn a setting from user configuration.

This is read from ~/.config/apport/settings or path. If bool is True, the
value is interpreted as a boolean.

Privileges may need to be dropped before calling this.
~)r   r   r.   r   _CONFIG_FILEr   r+  
getbooleangetr!  NoOptionErrorNoSectionError)sectionsettingdefaultr   booleanhomedirr)  s   &&&&&  r   
get_configr8    s     ,,rzz|,Q/##C1%F$$W66zz'++&&(C(CD s   B 4B 'B/.B/c                0    V ^8  d   QhR\         R\        /# )r   r*  r   )r9   r   )r   s   "r   r   r   
  s     % %C %C %r   c                v    W P                  R4      ^,           R p\        VP                  4       ^,          4      # )z7Extract the starttime from the contents of a stat file.)N)rfindr   r@   )r*  strippeds   & r   get_starttimer>  
  s4     s+a/12Hx~~#$$r   c                n    V ^8  d   QhR\         R\        \        R,          \        R,          3,          /# )r   r*  r   N)r9   tupler   )r   s   "r   r   r     s,        c  eC$Jd
,B&C  r   c                   RpRpV P                  4        F  pVP                  R4      '       dA   \        VP                  4       4      ^8  d#   \	        VP                  4       ^,          4      pKZ  VP                  R4      '       g   Ks  \        VP                  4       4      ^8  g   K  \	        VP                  4       ^,          4      pK  	  W3# )z;Extract the uid and gid from the contents of a status file.NzUid:zGid:)r  r?   rA   r@   r   )r*  real_uidreal_gidrP   s   &   r   get_uid_and_gidrD    s    HH##% ??6""s4::<'81'<4::<?+H__V$$TZZ\):Q)>4::<?+H & r   c                R    V ^8  d   QhR\         \        ,          R\        R\        /# )r   mapfdr   r   )r   r9   r   r,   )r   s   "r   r   r   $  s%      bg C D r   c                    V  Fe  pVP                  4       p\        V4      ^8w  d   K%  \        V^,          4      pV\        V^,          4      ,           pYAu;8:  d   V8:  g   K`    R#  Kg  	  R# )zSearch for an ID in a map fd.TF)r@   rA   r   )rF  r   rP   fields
host_starthost_ends   &&    r   
search_maprK  $  s]    v;!^
F1I.(( )  r   c                $    V ^8  d   QhR\         /# r+   r8   )r   s   "r   r   r   4  s      S r   c                     \        RRR7      ;_uu_ 4       p V P                  4       P                  4       pRRR4       V#   + '       g   i     X# ; i)zGet the kernel boot id.z/proc/sys/kernel/random/boot_idr   r   N)rL   rM   strip)rQ   boot_ids     r   get_boot_idrP  4  s>    	/'	B	Ba&&(.." 
CN 
C	BNs	   ?A	c                R    V ^8  d   QhR\         R\        \        \        3,          /# )r   proc_pid_fdr   )r   r   r9   )r   s   "r   r   r   ;  s&     X XS XT#s(^ Xr   c           	     ^  a  R V 3R llp\        RRRVR7      ;_uu_ 4       pVP                  4       P                  R4      pRRR4       X'       g   / # \        VP	                  R	4       Uu. uF  pR
V9   g   K  VP	                  R
^4      NK   	  up4      #   + '       g   i     L]; iu upi )zGet the process environ from a proc directory file descriptor.

Raises an OSError in case the environ file could not been read.
c                |    V ^8  d   QhR\         \        P                  \         ,          ,          R\        R\        /# r   r   flagsr   r9   r.   PathLiker   )r   s   "r   r   )get_process_environ.<locals>.__annotate__A  /     8 8S2;;s++ 8C 8C 8r   c                 4   < \         P                  ! WSR 7      # dir_fdr.   rL   r   rV  rR  s   &&r   opener#get_process_environ.<locals>.openerA      wwt;77r   environr   r   )r   errorsra  z  N r;   )rL   rM   rstripr   r@   )rR  ra  
environ_fdrd  entrys   f    r   get_process_environrj  ;  s    8 8 
GIf
 
	//#**51

 	'--2EV2EPU$S!$2EVWW
 
 Ws    B,	B*:B*B'	c                >    V ^8  d   QhR\         R,          R\        /# )r   rR  Nr   )r   r9   )r   s   "r   r   r   N  s      #*  r   c                d    V f   R#  \         P                  ! RV R7      #   \         d     R# i ; i)z;Get the process path from a proc directory file descriptor.unknownexer]  )r.   readlinkr3   )rR  s   &r   get_process_pathrp  N  s3    {{555 s     //c                    V ^8  d   QhR\         R,          R\        R,          R\         R,          R\         R,          R\         R,          R\        \        \        3,          /# )r   r   Nrn  r   	timestamprR  r   )r   r9   r@  )r   s   "r   r   r   X  s`     %" %"	t%"	t%" 
t%" Tz	%"
 t%" 38_%"r   c           
        a R V3R llpV eL   VfH   Se   RpMRV  R2p\        VRVR7      ;_uu_ 4       pVP                  4       pRRR4       \        X4      pVf   \        S4      pVP	                  R	R
4      P	                  RR
4      pVf   \
        P                  ! 4       pV f   RV RV R\        4        R2p	MRV RV R\        4        RV  RV 2
p	\
        P                  P                  \        V	4      p
W3#   + '       g   i     L; i)zGet the path to a core file.c                |    V ^8  d   QhR\         \        P                  \         ,          ,          R\        R\        /# rU  rW  )r   s   "r   r   #get_core_path.<locals>.__annotate__a  rZ  r   c                 4   < \         P                  ! WSR 7      # r\  r_  r`  s   &&r   ra  get_core_path.<locals>.openera  rc  r   Nr{   z/proc/z/statr   )r   ra  r   r   r   zcore.z.unknown.unknown)rL   rM   r>  rp  r   r.   getuidrP  r   r_   core_dir)r   rn  r   rr  rR  ra  stat_filename	stat_filestat_contents	core_name	core_paths   &&&&f      r   get_core_pathr  X  s   8 8 9,""M$SE/M-'&AAY%NN,M B!-0	
{{+
++c3

'
'S
1C
{iik {C5#a6FG	C5#aauAi[I	Xy1I!!) BAs   C==D	c                h    V ^8  d   QhR\         R\        \        \        \        3,          ,          /# )r   r   r   )r   r   r@  r9   float)r   s   "r   r   r     s(       U3:->(? r   c                   . p. p\         P                  P                  \        4      '       d   \         P                  ! \        R7      pV F  p VP                  R4      ^,          \        V 4      8X  dV   \         P                  P                  \         P                  P                  \        V4      4      pVP                  W434       K  K  	  V#   \        \        3 d     K  i ; i)zSearch the core file directory for files that belong to a
specified uid. Returns a list of tuples containing the filename and
the file modification time.
)r   r   )r.   r   r   ry  listdirr@   r9   getmtimer_   r   
IndexErrorrN   )r   
core_files	uid_filesrQ   core_file_times   &    r   find_core_files_by_uidr    s    
 JI	ww~~hZZX.
	wws|A#c(*!#!1!1"'',,x2K!L  !!45 +   -. 		s   A9CC%$C%c                (    V ^8  d   QhR\         RR/# )r   r   r   Nr   )r   s   "r   r   r     s     1 1c 1d 1r   c                   \        V 4      p\        V\        P                  ! ^4      R7      p\	        V4      \
        ^,
          8  d   \        \	        V4      \
        ,
          ^,           4       Fa  p\        P                  ! \        P                  P                  \        V^ ,          ^ ,          4      4       VP                  V^ ,          4       Kc  	  R# R# )z]Remove old files from the core directory if there are more than
the maximum allowed per uid.
)keyN)r  sortedoperator
itemgetterrA   MAX_COREFILES_PER_UIDranger.   remover   r_   ry  )r   r  sorted_filesr   s   &   r   clean_core_directoryr    s     's+I))<)<Q)?@L 9~-11s9~(==ABAIIbggll8\!_Q-?@AQ0 C 2r   c                R    V ^8  d   QhR\         R\        \         \         3,          /# r   )r9   r   )r   s   "r   r   r     s"     " "3 "4S> "r   c                f   / p\         P                  ! RV .\         P                  \         P                  RR7      ;_uu_ 4       pVP                  f   Q hVP                   Fs  p VP                  R^4      w  rETP                  4       pRT9   d   K1  TP                  4       ^ ,          P                  4       pTP                  R4      '       d   Ko  YQT&   Ku  	  VP                  P                  4        RRR4       XP                  ^ 8w  d   / # V#   \         d     K  i ; i  + '       g   i     L7; i)zGet libraries with which the specified binary is linked.

Return a library name -> path mapping, for example 'libc.so.6' ->
'/lib/x86_64-linux-gnu/libc.so.6'.
lddT)r  r  universal_newlinesNz=>z
linux-vdso()r1   Popenr  STDOUTr  r@   r   rN  r?   r&  r  )r   libsr  rP   rb   rests   &     r   shared_librariesr    s    D				  	
 

 
zz%%%JJD!ZZa0
 ::<Dt#::<?((*Ds##J  	

-
0 ~~	K!  
 
s7    D $D8AD $D D	D D	D  D0	c                J    V ^8  d   QhR\         R\        R\        R,          /# r   r   )r   s   "r   r   r     s%      m s sTz r   c                     \        V R,          4      pV^8  d   RV R2# \        P                  P                  V4      '       d   \        V4      '       g   RV R2# R#   \        \        3 d    ^ p L`i ; i)zCheck if the crash should be skipped for flood protection.

In case the crash should be skipped return a string with the reason.
Otherwise return None.
r   z this executable already crashed z times, ignoringzreport z< already exists and unseen, skipping to avoid disk usage DoSN)r   r   r   r.   r   r   r   )ry   r   r  s   && r   should_skip_crashr    s    F>23 q1-@PQQ	ww~~hH(=(= hZ  0 1	
  j! s   A A54A5c                <    V ^8  d   QhR\         R\         R\        /# )r   r   libr   rU   )r   s   "r   r   r     s!      C c d r   c                x    \        V 4      pW9   d   R# V F   pVP                  V R24      '       g   K   R# 	  R# )zCheck if the binary at path links with the library named lib.

path should be a fully qualified path (e.g. report['ExecutablePath']),
lib may be of the form 'lib<name>' or 'lib<name>.so.<version>'
Tz.so.F)r  r?   )r   r  r  
linked_libs   &&  r   links_with_shared_libraryr    s?     D!D
{
  C5..  r   r   )NNF)NNNNN)J__doc__r!  rh   	functoolsr   http.clientr   r   rn   r  r.   r   rer   r{   r1   r   typingr   apport.packaging_implr   rI   problem_reportr   rd  r0  r   ry  r  r.  rj   r   r   r   r5   rD   rR   rZ   rd   rv   r   r   r   r   compiler   r   cacher   r   r   r   r   r   r   r   r   r  r  r  r+  r8  r>  rD  rK  rP  rj  rp  r  r  r  r  r  r  r   r   r   <module>r     s   6      	   	 
 	      3 (ZZ^^/>
::>>/1KL *"dkk00 	4BB,""<

": O
  $>G
(
4.:  8.%  X&%"P*1"J*r   