JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr O6ufQrddlZddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZ ddlZdZdZdZd ZGd d eZGd d eZGddeZy#e$rY1wxYw)N)datetime)Lock) find_spec)sos_get_command_outputfilelinknodedirceZdZdZedZejdZdZ dZ e Z dZ dZdZd Zd Zd Zd ZddZddZdZdZdZdZdZdZdZdZdZy )Archivez!Abstract base class for archives.c|jS)z6Returns the archive class's name as a string. )__name__)clss -/usr/lib/python3/dist-packages/sos/archive.py archive_typezArchive.archive_type+s||sosunsetFc.d|jd|S)Nz [archive:z] )rselfmsgs r _format_msgzArchive._format_msg8s4,,./r#77rc||_yN)_debug)rdebugs r set_debugzArchive.set_debug;s  rcX|jj|j|yr)logerrorrrs r log_errorzArchive.log_error>s t'',-rcX|jj|j|yr)r warningrrs rlog_warnzArchive.log_warnAs ))#./rcX|jj|j|yr)r inforrs rlog_infozArchive.log_infoDs  d&&s+,rcr|jsy|jj|j|yr)rr rrrs r log_debugzArchive.log_debugGs'{{  t'',-rc|jSr)_namers rnamez Archive.nameLs zzrNctrNotImplementedError)rsrcdestforces radd_filezArchive.add_fileR!!rctrr0)rcontentr3modes r add_stringzArchive.add_stringUr6rctrr0)rr8r3s r add_binaryzArchive.add_binaryXr6rctrr0)rsource link_names radd_linkzArchive.add_link[r6rctrr0rpaths radd_dirzArchive.add_dir^r6rctrr0)rrCr9devices radd_nodezArchive.add_nodear6rct)zReturn a temporary directory that clients of the archive may use to write content to. The content of the path is guaranteed to be included in the generated archive.r0r-s r get_tmp_dirzArchive.get_tmp_dird "!rct)zReturn the maximum file name length this archive can support. This is the lesser of the name length limit of the archive format and any temporary file system based cache.r0r-s rname_maxzArchive.name_maxjrJrcy)aTReturn a string representing the path to the temporary archive. For archive classes that implement in-line handling this will be the archive file itself. Archives that use a directory based cache prior to packaging should return the path to the temporary directory where the report content is locatedNr-s rget_archive_pathzArchive.get_archive_pathps rcy)z:Clean up any temporary resources used by an Archive class.NrNr-s rcleanupzArchive.cleanupys rcy)aFinalize an archive object via method. This may involve creating An archive that is subsequently compressed or simply closing an archive that supports in-line handling. If method is automatic then the following methods are tried in order: xz, gzipNrNrmethods rfinalizezArchive.finalize}s rNFw)r __module__ __qualname____doc__ classmethodrlogging getLoggerr r,rr _path_lockrrr"r%r(r*r.r5r:r<r@rDrGrIrLrOrQrUrNrrr r (s+ '  E "C E FJ8.0-.  """"""" "    rr ceZdZdZdZdZdZ ddZdZdZ ddZ ddZ d Z dd Z dd Zd Zd ZdZdZdZdZdZddZdZdZdZdZdZdZdZdZy) FileCacheArchivezd Abstract superclass for archive types that use a temporary cache directory in the file system. Nc||_tjj|j|g|k(r%tjj |||_||_||_||_||_|xsd|_ ||_ tjj|||_ |j5tj|jdddd|jd|jdy#1swY)xYw)N/z'initialised empty FileCacheArchive at '')r,osrC commonprefixrelpath_tmp_dir_policy_threadsenc_optssysrootmanifestjoin _archive_rootr_makedirsr()rr.tmpdirpolicythreadsrmrnros r__init__zFileCacheArchive.__init__s 77  V 4 5 ?v6DJ     ~#   WW\\&$7 __ 3 KK**E 2 3 ,,-Q0 1 3 3s :!DD ctjj|r|jtj}tjj |j |Sr)rgrCisabslstripseprprq)rr.s r dest_pathzFileCacheArchive.dest_paths? 77== ;;rvv&D T//67rc|jr|j|jr|S|dtjk(r|dd}tjj |j|S)Nr)rn startswithrgrzrCrprBs r join_sysrootzFileCacheArchive.join_sysrootsQ||tt||<K 7bff 8Dww||DLL$//rc|jd||j|}fd}|jds|}nRtjj |j |r|n!tjj|d}|}g}|dk7rE|dk7r@tjj|\}} |j| |}|dk7r|dk7r@|j} d} |D]} tjj| | } || s-tjj| | } tjj| rm|jd| tjj| rtjj | rtj| } tjj| d}tjj|| }|j||}tjj|}tjj!| r tjj#| |} |jd| d | d tj$| | |jd | tj&| || }|S) aCreate leading path components The standard python `os.makedirs` is insufficient for our needs: it will only create directories, and ignores the fact that some path components may be symbolic links. :param src: The source path in the host file system for which leading components should be created, or the path to an sos_* virtual directory inside the archive. Host paths must be absolute (initial '/'), and sos_* directory paths must be a path relative to the root of the archive. :param mode: An optional mode to be used when creating path components. :returns: A rewritten destination path in the case that one or more symbolic links in intermediate components of the path have altered the path destination. zMaking leading paths for cb|jtjjdS)z>Test whether path ``path`` is inside the archive. rb)r~rgrCrp)rCroots r in_archivez8FileCacheArchive._make_leading_paths..in_archives#??277<<b#9: :rrdrrbz Making path r9zMaking symlink '' -> 'rfzMaking directory )r*rqr~rgrCisdirrsplitappendreverserpexistsislinkreadlink_make_leading_pathsnormpathrxrisymlinkmkdir)rr2r9r3rsrc_dirrC path_compsheadtailabs_pathsrc_pathcomptarget target_dir target_srcrs @rrz$FileCacheArchive._make_leading_pathss\, 23%89!! ; ~~c"G!ggmmD,=,=c,BCsGGMM#.q1  ckdbjt,JD$   d #Dckdbj % $Dww||Hd3Hh'ww||Hd3H77>>(+hZ8977>>(+ h0G[[2F"$x!8!;J"$j&!AJ 33JT3JD77++D1Dww}}V,!#!DNN%5hZ@''-ha$12JJvx0NN%6xj#ABHHXt,#DK% $N rc |xs|j|}|tk(r|}n"tjj |d}|s|Stjj |r.tjj |std|dtjj |s>|tk(r|n!tjj |d}|j|d}|r|Stjj |rtj|}d} |tk(r/tj|jst| |dfz|tk(r/tj|jst| |dfz|t k(r"||jst| |dfz|tk(r/tj"|jst| |d fzy |S) a4Check a new destination path in the archive. Since it is possible for multiple plugins to collect the same paths, and since plugins can now run concurrently, it is possible for two threads to race in archive methods: historically the archive class only needed to test for the actual presence of a path, since it was impossible for another `Archive` client to enter the class while another method invocation was being dispatched. Deal with this by implementing a locking scheme for operations that modify the path structure of the archive, and by testing explicitly for conflicts with any existing content at the specified destination path. It is not an error to attempt to create a path that already exists in the archive so long as the type of the object to be added matches the type of object already found at the path. It is an error to attempt to re-create an existing path with a different path type (for example, creating a symbolic link at a path already occupied by a regular file). :param src: the source path to be copied to the archive :param path_type: the type of object to be copied :param dest: an optional destination path :param force: force file creation even if the path exists :returns: An absolute destination path if the path should be copied now or `None` otherwise rzpath 'z' exists and is not a directorycttj|tj|tj|tj |gSr)anystatS_ISBLKS_ISCHRS_ISFIFOS_ISSOCKrs r is_specialz/FileCacheArchive.check_path..is_special7sD T" T" d# d#  rz path '%s' exists and is not a %sz regular filez symbolic linkz special file directoryN)r{P_DIRrgrCrrr ValueErrorrlstatP_FILErS_ISREGst_modeP_LINKS_ISLNKP_NODES_ISDIR) rr2 path_typer3r4dest_dirrrstve_msgs r check_pathzFileCacheArchive.check_paths>*t~~c*  Hww}}T*1-HK 77>>( #BGGMM(,CvhZ0))* *)&%/cRWW]]35G5JG  $ $W -  K 77>>$ $B7FF"4<< +C 4*@!@AAF"4<< +C 4*A!ABBF":bjj+A 4*@!@AAE!$,,rzz*B 4*=!=>> rc tj|}|jds|jdrDtj||tj ||j |jfntj||tj||j|jy#t$r"}|jd|d|dYd}~yd}~wwxYw)N/sys//proc/)nszcaught 'z' setting attributes of 'rf)rgrr~shutilcopymodeutime st_atime_ns st_mtime_nscopystatchownst_uidst_gid Exceptionr*)rr2r3res r_copy_attributesz!FileCacheArchive._copy_attributesSs K773G 77>>#&))#t4!23%8##'#5#5"6a 9:  : : : : : : :s$3C$BCC$C! C$$C-cJ|j5|j|t}|s dddytj|dd5}|j |ddd|j d|d|jddddy#1swY4xYw#1swYyxYw)Nwbrzadded binary content at 'z' to archive 'rf)r_rrrrrr*rq)rr8r3rs rr<zFileCacheArchive.add_binarys __ 6??40D 6 6 T4$7 !1  ! NN6tf=#112!5 6 6 6  ! !  6 6s(BBB *B B BB"c |jd|d|d|j5|j|t}|s dddytj j |s;t j|||jd|d|d|jdddd|jd|d|d tj j|}tj jtj j||}|j|}d }tj j|stj j|r|}tj j|}tj j|t j|}tj j!||}|||r|jd |d |d y|jd|d|d|j#||ytj j%|r'|jd|d|j'|ytj j)|r'|jd|d|j+|y|jd|d|yy#1swY9xYw)Nzadding symlink at 'rrfzadded symlink at 'z' to 'z' in archive 'zLink follow up: source=z link_name=z dest=ctjj|}tjj|s=tjj tjj ||}tjj |}||k(ry tj |y#t$r}|jdk(rYd}~yd}~wwxYw)zReturn ``True`` if the symbolic link ``link_name`` is part of a file system loop, or ``False`` otherwise. T(NF) rgrCdirnamerxrealpathrprrerrno)r?r>link_dirrs ris_loopz*FileCacheArchive.add_link..is_loopswwy1H77==())"'',,x*HI((3IF"  "   77b= s"B88 CCCCzLink 'z' - 'z' loops: skipping...z Adding link z -> z for link follow upz Adding dir z Adding file zNo link follow up: source=)r*r_rrrgrClexistsrrqrrrpr{rrrrir@rrDisfiler5) rr>r?r3 source_dirhost_path_namedest_path_namerrs rr@zFileCacheArchive.add_links} ,YKvfXQGH __ B??9f5D B B 77??4( 64(!3D6xH++/+=+=*>a AB B 0 I;v' (WW__Y/ ))"'',,z6*JK7 .ww~~n-ww~~n-* 77??95h N0KL:9f-NNVI;eF8D1$12i[VHE+ +, fi0~.VH4GHI ^,/fX5HIJ n-!;F8D,,5; 89/.W B BsKAKK#cr|j5|j|tdddy#1swYyxYw)zmCreate a directory in the archive. :param path: the path in the host file system to add N)r_rrrBs rrDzFileCacheArchive.add_dirs. __ ) OOD% ( ) ) )s-6ch|j|t}|sytjj |s+ tj ||||j||yy#t $rC}|jtjk(rd}|jd|d|dYd}~y|d}~wwxYw)NzOperation not permittedz add_node: z - mknod 'rf) rrrgrCrmknodrrEPERMr(r)rrCr9rFr3rrs rrGzFileCacheArchive.add_nodestV, ww~~d# tV,  ! !$ -$ 77ekk)3CMMJse:dV1"EF  sA%% B1.7B,*B,,B1cdtjvr3tjd}tj|j|Sy)N PC_NAME_MAX)rgpathconf_namespathconfrq)r pc_name_maxs rrLzFileCacheArchive.name_maxs: B-- -++M:K;;t11;? ?rc|jSrrqr-s rrIzFileCacheArchive.get_tmp_dir !!!rc|jSrrr-s rrOz!FileCacheArchive.get_archive_path rrctjtjj|j|||j d|d|jdy)zsCreate path, including leading components. Used by sos.sosreport to set up sos_* directories. rzcreated directory at 'z' in FileCacheArchive 'rfN)rgrrrCrprqr*)rrCr9s rrrzFileCacheArchive.makedirssR BGGLL!3!3T:F /v6--.a1 2rcV|j|}tj|dddS)Nrrr)rerrors)r{rrrBs r open_filezFileCacheArchive.open_files%~~d#{{4wxHHrctjj|jr t j |jyyr)rgrCrrqrrmtreer-s rrQzFileCacheArchive.cleanups/ 77==++ , MM$,, - -rctj}|jj}||z }|jj d||jj d||jj d||j |jj dtjjddy) zAdds component-agnostic data to the manifest so that individual SoSComponents do not need to redundantly add these manually end_timerun_time compression)indent sos_reportsz manifest.jsonN) rnowro start_time add_fieldr:get_jsonrgrCrp)rrTendstartrs radd_final_manifest_dataz(FileCacheArchive.add_final_manifest_data slln ((;  C0  H5  v6  ..a.8 ]OD Frct|j|j|_tjj |j |j}tj |j|||_tjj |j |j|_ y)zeRename the archive to an obfuscated version using an initialized SoSCleaner instance N) obfuscate_stringr,rgrCrprjrenamerqr. _archive_name)rcleaner _new_roots rrename_archive_rootz$FileCacheArchive.rename_archive_root-ss--djj9 GGLL ;  $$$i0&WW\\$--Erctjtjz}t|dr|j}|j |z}n|}|}d}|j |5}|j}dddt|ts|jdd}tj||||\} } | r|j| || Sd} | S#1swYaxYw)aApply a regexp substitution to a file in the archive. :param path: Path in the archive where the file can be found :type path: ``str`` :param regexp: A regex to match the contents of the file :type regexp: ``str`` or compiled ``re`` object :param subst: The substitution string to be used to replace matches within the file :type subst: ``str`` :returns: Number of replacements made :rtype: ``int`` patternrbNrr)flagsr) re IGNORECASE MULTILINEhasattrrrrrrstrrsubnr:) rrCregexpsubst common_flagsrrr8readableresult replacementss r do_file_subzFileCacheArchive.do_file_sub7s }}r||3 69 %nnGLL</EG E ^^D ! &XmmoG &'3'nnVX6G!wwww-2 4  OOFD )L & &s !CCc6|jd|jd|d |j|}|j |jd|jdtj|jjd|jdr |j|S|S#t$r.}|j d||j cYd}~Sd}~wwxYw#t$r$}d }|j |d ||cYd}~Sd}~wwxYw) Nzfinalizing archive 'z' using method 'rfz+An error occurred compressing the archive: zbuilt archive at 'z' (size=)encryptz)An error occurred encrypting the archive: ) r(rq_build_archiverr"r.rQrrgrst_sizerm_encrypt)rrTreserrrexp_msgs rrUzFileCacheArchive.finalize\s ,T-?-?,@A!(!% & %%f-C  *4+=+=*>?!wwt'9'9:BBC1F G == # }}S)) J!  NNHN O99;   E'!A3/0  s;B1C+1 C(:#C#C(#C(+ D4D DDc|jdd}|dz }d|d}d}|jdr|d|jddz }||z }|jd r3|jd jd d }d |i}|d z }d|d}||z }t|d|}|ddk(r|S|ddk(r)|jdr d}t|d}t|d|d}t|)aEncrypts the compressed archive using GPG. If encryption fails for any reason, it should be logged by sos but not cause execution to stop. The assumption is that the unencrypted archive would still be of use to the user, and/or that the end user has another means of securing the archive. Returns the name of the encrypted archive, or raises an exception to signal that encryption failed and the unencrypted archive name should be used. z sosreport-zsecured-sosreport-z.gpgzgpg --batch -o r&Nkeyz--trust-model always -e -r passwordz'"rbsos_gpgz-c --passphrase-fd 0 z/bin/bash -c "echo $sos_gpg | "r)timeoutenvstatuszSpecified key not in keyringzCould not read passphrasezgpg exited with code )replacermrr)rarchivearc_nameenc_cmdr3passwdrrs rr)zFileCacheArchive._encryptss5??<1EFF#H:Q/ ==  4T]]55I4J!L LG w G == $]]:.66ubAFf%C . .G7yCG w G "7A3 ? X;! O x[A }}U#4n 2 n*!H+7CnrcyrrNrSs rr'zFileCacheArchive._build_archives rr)rerVrW)rrYrZr[rjrqrrvr{rrrrr5r:r<r@rDrGrLrIrOrrrrQr rr"rUr)r'rNrrraras&HMM1$8 0[zIV K"6H:& 6E9N). ""2I. FF#J.)V rracXeZdZdZdZdZ d fd Zd dZdZdZ dZ fd Z d Z xZ S) TarFileArchivez: archive class using python TarFile to create tar archivesNFc t||||||||d|_tjj ||j |_y)Ntar)superrv_suffixrgrCrpr.r) rr.rsrtrurmrnro __class__s rrvzTarFileArchive.__init__sF vvw!7H 6 WW\\ DIIK rc |j|_|jd|jd<|jd|jd<|r||_n|j |_|j|_|j|_ y)Nz.9fatimectime) st_mtimemtimest_atime pax_headersst_ctimer9rruidrgid)rtar_infofstatr9s rset_tarinfo_from_statz$TarFileArchive.set_tarinfo_from_statsj+0>>#*>W%+0>>#*>W%  HM!MMHM|| || rc|jttjj |j dds |j gd}t fd|Dry tj}|jr"|j}|r||jd<|j|||S#t$r|cYSwxYw)N)z /version.txt$z/sos_logs(/.*)?z/sos_reports(/.*)?c3JK|]}tj|ywr)rmatch).0skip orig_paths r z9TarFileArchive.copy_permissions_filter..s;Trxxi(;s #zRHT.security.selinux) r.lenrgrCrrqrrr_with_selinux_contextget_selinux_contextrIrO)rtarinfoskipsrNcontextrVs @rcopy_permissions_filterz&TarFileArchive.copy_permissions_filtersLLRWW]]43E3E%Fr%J!K!LM **IJ ;U; ; GGI&E  % %..y9G>E##$:; ""7E2 N s,C CCcV tj|\}}|S#t$rYywxYwr)selinux getfileconr)rrCrccs rrZz"TarFileArchive.get_selinux_contexts2 ((.GRH  s  ((c8|jd|jS)N.)rqrAr-s rr.zTarFileArchive.names$$%Qt||n55rc t|Sr)r@rL)rrBs rrLzTarFileArchive.name_maxsw!!rc|dk(rtddnd}|jd}|jd||_|dk(rddi}nd d i}tj|jfd d |i|}d D]}t j jt j j|j|sK|jt j j|j||jd||j|j|j|j|j|xjd|z c_|jS)Nautolzmaxzgzipipre compresslevelpresetr9zw:)z version.txtrsos_logsrd)arcname)rrfilter)rstriprtarfilerrgrCrrprqaddr,r^closerAr.)rrT _comp_modekwargsr?_contents rr'zTarFileArchive._build_archivesU V &v.:TF\\$' $ 2 231ZLA V %q)F]Fll4--%b 4E%#%C H77>>"'',,t/A/A8"LM GG T//:::,az2    ""DJJ33  5  !J<(( yy{rr)rrYrZr[rTrYrvrOr^rZr.rLr' __classcell__)rBs@rr=r=s9D F!  $$6" rr=)rgrurr]rrrrr threadingrimportlib.utilr sos.utilitiesrr` ImportErrorrrrrobjectr rar=rNrrrs   $0     Z fZ zZ wZ zY%YM   sA((A0/A0