
    ~ gr                         S SK r S SKrS SKrS SKrS SK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rSrSrSrS	r " S
 S5      r " S S\5      r " S S\5      rg! \ a     N1f = f)    N)datetime)Lock)	find_spec)sos_get_command_outputfilelinknodedirc                       \ rS rSrSr\S 5       r\R                  " S5      r	Sr
Sr\" 5       rS rS rS	 rS
 rS rS rS rSS jrSS jrS rS rS rS rS rS rS rS rS rSr g)Archive(   z!Abstract base class for archives.c                     U R                   $ )z6Returns the archive class's name as a string.
        )__name__)clss    -/usr/lib/python3/dist-packages/sos/archive.pyarchive_typeArchive.archive_type+   s     ||    sosunsetFc                 .    SU R                  5        SU 3$ )Nz	[archive:z] )r   selfmsgs     r   _format_msgArchive._format_msg8   s    4,,./r#77r   c                     Xl         g N_debug)r   debugs     r   	set_debugArchive.set_debug;   s    r   c                 X    U R                   R                  U R                  U5      5        g r   )logerrorr   r   s     r   	log_errorArchive.log_error>   s    t'',-r   c                 X    U R                   R                  U R                  U5      5        g r   )r%   warningr   r   s     r   log_warnArchive.log_warnA   s    ))#./r   c                 X    U R                   R                  U R                  U5      5        g r   )r%   infor   r   s     r   log_infoArchive.log_infoD   s    d&&s+,r   c                 |    U R                   (       d  g U R                  R                  U R                  U5      5        g r   )r    r%   r!   r   r   s     r   	log_debugArchive.log_debugG   s'    {{t'',-r   c                     U R                   $ r   )_namer   s    r   nameArchive.nameL   s    zzr   Nc                     [         er   NotImplementedError)r   srcdestforces       r   add_fileArchive.add_fileR       !!r   c                     [         er   r:   )r   contentr=   modes       r   
add_stringArchive.add_stringU   rA   r   c                     [         er   r:   )r   rC   r=   s      r   
add_binaryArchive.add_binaryX   rA   r   c                     [         er   r:   )r   source	link_names      r   add_linkArchive.add_link[   rA   r   c                     [         er   r:   r   paths     r   add_dirArchive.add_dir^   rA   r   c                     [         er   r:   )r   rQ   rD   devices       r   add_nodeArchive.add_nodea   rA   r   c                     [         e)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.r:   r6   s    r   get_tmp_dirArchive.get_tmp_dird   
     "!r   c                     [         e)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.r:   r6   s    r   name_maxArchive.name_maxj   r[   r   c                     [         e)a,  Return 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
locatedr:   r6   s    r   get_archive_pathArchive.get_archive_pathp   s
     "!r   c                     [         e)z:Clean up any temporary resources used by an Archive class.r:   r6   s    r   cleanupArchive.cleanupy   s    !!r   c                     [         e)zFinalize 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, gzipr:   r   methods     r   finalizeArchive.finalize}   s
    
 "!r   r   NFw)!r   
__module____qualname____firstlineno____doc__classmethodr   logging	getLoggerr%   r5   r    r   
_path_lockr   r"   r'   r+   r/   r2   r7   r?   rE   rH   rM   rR   rV   rY   r]   r`   rc   rh   __static_attributes__ r   r   r   r   (   s    + 
 

E
"CEFJ8.0-.
"""""""""""r   r   c                       \ rS rSrSrSrSrSr SS jrS r	S r
SS jrS S	 jrS
 rS S jrS!S jrS rS rS rS rS rS rS rSS jrS rS rS rS rS rS rS rS rSr g)"FileCacheArchive   z_Abstract superclass for archive types that use a temporary cache
directory in the file system.  Nc                 &   Xl         [        R                  R                  U R                   U/5      U:X  a$  [        R                  R	                  X5      U l         X l        X0l        X@l        XPl        U=(       d    SU l	        Xpl
        [        R                  R                  X!5      U l        U R                     [        R                  " U R                  S5        S S S 5        U R                  SU R                   S35        g ! , (       d  f       N.= f)N/  z'initialised empty FileCacheArchive at '')r5   osrQ   commonprefixrelpath_tmp_dir_policy_threadsenc_optssysrootmanifestjoin_archive_rootrt   makedirsr/   )r   r7   tmpdirpolicythreadsr   r   r   s           r   __init__FileCacheArchive.__init__   s    
77V 45?6DJ ~# WW\\&7__KK**E2  ,,-Q0 	1 _s   8"D
Dc                     [         R                  R                  U5      (       a  UR                  [         R                  5      n[         R                  R                  U R                  U5      $ r   )r   rQ   isabslstripsepr   r   )r   r7   s     r   	dest_pathFileCacheArchive.dest_path   sB    77==;;rvv&Dww||D..55r   c                     U R                   (       a   UR                  U R                   5      (       a  U$ US   [        R                  :X  a  USS  n[        R                  R                  U R                   U5      $ )Nr      )r   
startswithr   r   rQ   r   rP   s     r   join_sysrootFileCacheArchive.join_sysroot   sT    ||tt||<<K7bff8Dww||DLL$//r   c                   ^ U R                  SU 35        U R                  mUnU4S jnUR                  S5      (       d  UnOW[        R                  R                  U R                  U5      5      (       a  UO![        R                  R                  U5      S   nUn/ nUS;  a<  [        R                  R                  U5      u  pUR                  U	5        UnUS;  a  M<  UR                  5         Tn
SnU GH  n[        R                  R                  X5      n
U" U
5      (       d  M2  [        R                  R                  X5      n[        R                  R                  U
5      (       a  Mw  U R                  SU
 35        [        R                  R                  U5      (       Ga  [        R                  R                  U5      (       a  [        R                  " U5      n[        R                  R                  U5      S   n[        R                  R                  X5      nU R                  XS9n[        R                  R                  U5      n[        R                  R!                  U5      (       a  [        R                  R#                  X5      nU R                  SU
 S	U S
35        [        R$                  " X5        GM  U R                  SU
 35        [        R&                  " X5        UnGM     U$ )a(  Create 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.
zMaking leading paths for c                 b   > U R                  [        R                  R                  TS5      5      $ )z>Test whether path ``path`` is inside the archive.
            rz   )r   r   rQ   r   )rQ   roots    r   
in_archive8FileCacheArchive._make_leading_paths.<locals>.in_archive   s#     ??277<<b#9::r   r|   r   )r|   rz   zMaking path rD   zMaking symlink '' -> 'r~   zMaking directory )r2   r   r   r   rQ   isdirr   splitappendreverser   existsislinkreadlink_make_leading_pathsnormpathr   r   symlinkmkdir)r   r<   rD   r=   r   src_dirrQ   
path_compsheadtailabs_pathsrc_pathcomptarget
target_dir
target_srcr   s                   @r   r   $FileCacheArchive._make_leading_paths   sR   , 	23%89!!	;
 ~~c""G !ggmmD,=,=c,BCCsGGMM#.q1  
)#t,JDd#D )# 	 Dww||H3H h''ww||H3H77>>(++hZ8977>>(++h0G0G[[2F "$x!8!;J "$j!AJ  33J3JD77++D1D ww}}V,,!#!DNN%5hZ @''-ha$1 2JJv0NN%6xj#ABHHX,#DK N r   c                    U=(       d    U R                  U5      nU[        :X  a  UnO"[        R                  R	                  U5      S   nU(       d  U$ [        R                  R                  U5      (       a3  [        R                  R                  U5      (       d  [        SU S35      e[        R                  R                  U5      (       d?  U[        :X  a  UO![        R                  R	                  U5      S   nU R                  U5        S nU(       a  U$ [        R                  R                  U5      (       Ga  [        R                  " U5      nSn	U[        :X  a4  [        R                  " UR                  5      (       d  [        XS4-  5      eU[        :X  a4  [        R                  " UR                  5      (       d  [        XS4-  5      eU[         :X  a&  U" UR                  5      (       d  [        XS4-  5      eU[        :X  a4  [        R"                  " UR                  5      (       d  [        XS	4-  5      eg
U$ )a  Check 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
r   zpath 'z' exists and is not a directoryc                     [        [        R                  " U 5      [        R                  " U 5      [        R                  " U 5      [        R
                  " U 5      /5      $ r   )anystatS_ISBLKS_ISCHRS_ISFIFOS_ISSOCKr   s    r   
is_special/FileCacheArchive.check_path.<locals>.is_special7  sD    T"T"d#d#	  r   z path '%s' exists and is not a %szregular filezsymbolic linkzspecial file	directoryN)r   P_DIRr   rQ   r   r   r   
ValueErrorr   lstatP_FILEr   S_ISREGst_modeP_LINKS_ISLNKP_NODES_ISDIR)
r   r<   	path_typer=   r>   dest_dirr   r   stve_msgs
             r   
check_pathFileCacheArchive.check_path  s   > *t~~c*Hww}}T*1-HK 77>>(##BGGMM(,C,CvhZ 0) ) * *ww~~h''&%/cRWW]]35G5JG$$W-	 K 77>>$$B7FF"4<<

+C+C *@!@AAF"4<<

+C+C *A!ABBF":bjj+A+A *@!@AAE!$,,rzz*B*B *=!=>>r   c                     [         R                  " U5      nUR                  S5      (       d  UR                  S5      (       aA  [        R                  " X5        [         R
                  " X#R                  UR                  4S9  O[        R                  " X5        [         R                  " X#R                  UR                  5        g ! [         a"  nU R                  SU SU S35         S nAg S nAff = f)N/sys//proc/)nszcaught 'z' setting attributes of 'r~   )r   r   r   shutilcopymodeutimest_atime_nsst_mtime_nscopystatchownst_uidst_gid	Exceptionr2   )r   r<   r=   _states        r   _copy_attributes!FileCacheArchive._copy_attributesS  s    		KGGCLE~~g&&#..*B*B*#4#4e6G6G"HI*HHT<<6 	KNNXaS(A$qIJJ	Ks   CC 
C3C..C3c           	         U R                      U(       d  UnU R                  U[        US9nU(       d
   S S S 5        g [        USS 5      (       d/   [        R
                  " X5        U R                  X5        SU S3nOAUR                  S5        [        US	S
S9 nU H  nUR                  U5        M     S S S 5        SnU R                  SU SU R                   S35        S S S 5        g ! [         aS  nUR                  S5      (       d  UR                  S5      (       a   S nANU R                  SU SU S35         S nANS nAff = f! , (       d  f       N= f! , (       d  f       g = f)Nr>   readr   r   zFile z not collected: 'r~   r   rl   utf-8encodingz	open filezadded z to FileCacheArchive ')rt   r   r   getattrr   copyOSErrorr   r/   r   seekopenwriter2   r   )r   r<   r=   r>   r   	file_nameflines           r   r?   FileCacheArchive.add_file`  sD   __??4u?=D _ 3--JKK* %%c0uAJ	 $g6! # !$ 7 (	NNVI; /#112!5 6A _  J~~g..#..2J2JcU2CA3a&HIIJ 767 _s^   'EEC*&4EE
5,E*
E4,E E%E=EEE

E	E
E)c           	         U R                      UnU R                  U[        SS9n[        R                  " X#SS9 n[        U[        5      (       a  UR                  SS5      nUR                  U5        [        R                  R                  U5      (       a  U R                  XB5        U R                  SU SU R                   S	35        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)
NTr   r   r   utf8ignorezadded string at 'z' to FileCacheArchive 'r~   )rt   r   r   codecsr   
isinstancebytesdecoder   r   rQ   r   r   r2   r   )r   rC   r=   rD   r<   r   s         r   rE   FileCacheArchive.add_string  s    __C ??4t?<DT':agu--%nnVX>G 77>>#&&))#4!23% 8##'#5#5"6a 9 : ; _ ;: _s#   -C,BC
C,
C)	%C,,
C:c                 d   U R                      U R                  U[        5      nU(       d
   S S S 5        g [        R                  " USS S9 nUR                  U5        S S S 5        U R                  SU SU R                   S35        S S S 5        g ! , (       d  f       N9= f! , (       d  f       g = f)Nwbr   zadded binary content at 'z' to archive 'r~   )rt   r   r   r   r   r   r2   r   )r   rC   r=   r   s       r   rH   FileCacheArchive.add_binary  s    __??40D _
 T4$71  8NN6tf =#112!5 6 _
 87 _s(   B!B!B*B!
B	B!!
B/c           
         U R                  SU SU S35        U R                     U R                  U[        5      nU(       d
   S S S 5        g [        R
                  R                  U5      (       d;  [        R                  " X5        U R                  SU SU SU R                   S35        S S S 5        U R                  SU SU S	W 35        [        R
                  R                  U5      n[        R
                  R                  [        R
                  R                  XA5      5      nU R                  U5      nS
 n[        R
                  R                  U5      (       Gd  [        R
                  R                  U5      (       a  Un[        R
                  R                  U5      n[        R
                  R                  U[        R                  " U5      5      n[        R
                  R!                  X5      nU" X!5      (       a  U R                  SU SU S35        g U R                  SU SU S35        U R#                  X5        g [        R
                  R%                  U5      (       a'  U R                  SU S35        U R'                  U5        g [        R
                  R)                  U5      (       a'  U R                  SU S35        U R+                  U5        g U R                  SU SU 35        g g ! , (       d  f       GNT= f)Nzadding symlink at 'r   r~   zadded symlink at 'z' to 'z' in archive 'zLink follow up: source=z link_name=z dest=c                    [         R                  R                  U 5      n[         R                  R                  U5      (       d<  [         R                  R	                  [         R                  R                  X!5      5      n[         R                  R	                  U 5      n X:X  a  g [         R                  " U 5        g! [         a  nUR                  S:X  a   SnAge SnAff = f)zjReturn ``True`` if the symbolic link ``link_name`` is part
of a file system loop, or ``False`` otherwise.
Tr   NF)	r   rQ   dirnamer   realpathr   r   r   errno)rL   rK   link_dirr   s       r   is_loop*FileCacheArchive.add_link.<locals>.is_loop  s     wwy1H77==(())"'',,x*HI((3I "	"
 	  77b=s   &B= =
C"CCC"zLink 'z' - 'z' loops: skipping...zAdding link z -> z for link follow upzAdding dir zAdding file zNo link follow up: source=)r2   rt   r   r   r   rQ   lexistsr   r   r  r  r   r   r   r   r   r   rM   r   rR   isfiler?   )	r   rK   rL   r=   
source_dirhost_path_namedest_path_namer  r   s	            r   rM   FileCacheArchive.add_link  st   ,YKvfXQGH__??9f5D _
 77??4((

6(!3D6x H++/+=+=*>a A B  	0I;v' 	( WW__Y/
))"'',,z*JK7	. ww~~n--ww~~n--*	77??95hN0KL:9--NNVI;eF8 D1 $1 2i[VH E+  + ,f0~..VH4GHI^,//fX5HIJn-!;F8 D,,5; 8 9/ .W _s   K9AK99
Lc                 |    U R                      U R                  U[        5        SSS5        g! , (       d  f       g= f)zYCreate a directory in the archive.

:param path: the path in the host file system to add
N)rt   r   r   rP   s     r   rR   FileCacheArchive.add_dir  s#     __OOD%( __s   -
;c                 ~   U R                  U[        5      nU(       d  g [        R                  R	                  U5      (       d*   [        R
                  " XBU5        U R                  X5        g g ! [         aD  nUR                  [        R                  :X  a  SnU R                  SU SU S35         S nAg UeS nAff = f)NzOperation not permittedz
add_node: z
 - mknod 'r~   )r   r   r   rQ   r   mknodr   r  EPERMr/   r   )r   rQ   rD   rU   r=   r   r   s          r   rV   FileCacheArchive.add_node  s    tV,ww~~d##V, !!$- $  77ekk)3CMMJse:dV1"EFs   A. .
B<88B75B77B<c                     S[         R                  ;   a4  [         R                  S   n[         R                  " U R                  U5      $ g)NPC_NAME_MAX   )r   pathconf_namespathconfr   )r   pc_name_maxs     r   r]   FileCacheArchive.name_max  s:    B---++M:K;;t11;??r   c                     U R                   $ r   r   r6   s    r   rY   FileCacheArchive.get_tmp_dir	      !!!r   c                     U R                   $ r   r  r6   s    r   r`   !FileCacheArchive.get_archive_path  r  r   c                     [         R                  " [         R                  R                  U R                  U5      US9  U R                  SU SU R                   S35        g)z_Create path, including leading components.

Used by sos.sosreport to set up sos_* directories.
r   zcreated directory at 'z' in FileCacheArchive 'r~   N)r   r   rQ   r   r   r2   )r   rQ   rD   s      r   r   FileCacheArchive.makedirs  sR    
 	BGGLL!3!3T:F/v 6--.a1 	2r   c                 R    U R                  U5      n[        R                  " USSSS9$ )Nrr   r   )r   errors)r   r   r   rP   s     r   	open_fileFileCacheArchive.open_file  s%    ~~d#{{4wxHHr   c                     [         R                  R                  U R                  5      (       a!  [        R
                  " U R                  5        g g r   )r   rQ   r   r   r   rmtreer6   s    r   rc   FileCacheArchive.cleanup  s2    77==++,,MM$,,- -r   c                    [         R                  " 5       nU R                  R                  nX#-
  nU R                  R	                  SU5        U R                  R	                  SU5        U R                  R	                  SU5        U R                  U R                  R                  SS9[        R                  R                  SS5      5        g)	z|Adds component-agnostic data to the manifest so that individual
SoSComponents do not need to redundantly add these manually
end_timerun_timecompression   )indentsos_reportszmanifest.jsonN)
r   nowr   
start_time	add_fieldrE   get_jsonr   rQ   r   )r   rg   endstartr-  s        r   add_final_manifest_data(FileCacheArchive.add_final_manifest_data   s     lln((;
C0
H5v6..a.8]OD	Fr   c                 t   UR                  U R                  5      U l        [        R                  R	                  U R
                  U R                  5      n[        R                  " U R                  U5        X l        [        R                  R	                  U R
                  U R                  5       5      U l	        g)zURename the archive to an obfuscated version using an initialized
SoSCleaner instance
N)
obfuscate_stringr5   r   rQ   r   r   renamer   r7   _archive_name)r   cleaner	_new_roots      r   rename_archive_root$FileCacheArchive.rename_archive_root-  sq     --djj9
GGLL

;	
		$$$i0&WW\\$--Er   c                    [         R                  [         R                  -  n[        US5      (       a  UR                  nUR
                  U-  nOUnUnSnU R                  U5       nUR                  5       nSSS5        [        U[        5      (       d  UR                  SS5      n[         R                  " XSUUS9u  pU
(       a  U R                  X5        U
$ Sn
U
$ ! , (       d  f       Nk= f)a  Apply 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``
patternrz   Nr   r   )flagsr   )re
IGNORECASE	MULTILINEhasattrrC  rD  r&  r   r   strr   subnrE   )r   rQ   regexpsubstcommon_flagsrC  rD  rC   readableresultreplacementss              r   do_file_subFileCacheArchive.do_file_sub7  s      }}r||369%%nnGLL</EG E^^D!XmmoG "'3''nnVX6G!wwww-2 4OOF)  L "!s   &C
C*c                 F   U R                  SU R                   SU S35         U R                  U5      nU R                  5         U R                  SU R                   S[        R                  " U R                  5      R                   S35        U R                  S   (       a   U R                  U5      $ U$ ! [         a.  nU R	                  SU 35        U R                  5       s S nA$ S nAff = f! [         a$  nS	nU R	                  U S
U 35        Us S nA$ S nAff = f)Nzfinalizing archive 'z' using method 'r~   z+An error occurred compressing the archive: zbuilt archive at 'z' (size=)encryptz)An error occurred encrypting the archive: )r/   r   _build_archiver   r'   r7   rc   r=  r   r   st_sizer   _encrypt)r   rg   reserrr   exp_msgs         r   rh   FileCacheArchive.finalize\  s   ,T-?-?,@ A!(!% 	&	%%f-C
 	*4+=+=*> ?!wwt'9'9:BBC1F 	G ==#}}S)) J!  	NNHNO99;	  E'!A3/0
s;   B7 $C2 7
C/#C*$C/*C/2
D <DD D c                    UR                  SS5      nUS-  nSU S3nSnU R                  S   (       a  USU R                  S    S3-  nX1-  nU R                  S	   (       a2  U R                  S	   R                  S
S5      nSU0nUS-  nSU S3nX1-  n[        USUS9nUS   S:X  a  U$ US   S:X  a  U R                  S   (       a  SnOSnOSUS    3n[        U5      e)a  Encrypts 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-zsecured-sosreport-z.gpgzgpg --batch -o rV  Nkeyz--trust-model always -e -r passwordz'"rz   sos_gpgz-c --passphrase-fd 0 z/bin/bash -c "echo $sos_gpg | "r   )timeoutenvstatus   zSpecified key not in keyringzCould not read passphrasezgpg exited with code )replacer   r   r   )r   archivearc_nameenc_cmdrd  passwdr$  r   s           r   rY  FileCacheArchive._encrypts  s    ??<1EFF#H:Q/== 4T]]55I4J!LLGG==$ ]]:.66ubAFf%C..G7yCGG"7A3?X;!OX;!}}U#41 *!H+7Cnr   c                 "    U R                  5       $ r   )r7   rf   s     r   rW  FileCacheArchive._build_archive  s    yy{r   )	r=  r   r5   r   r   r   r   r   r   r   )r}   rj   rk   )!r   rm   rn   ro   rp   r   r   r=  r   r   r   r   r   r   r?   rE   rH   rM   rR   rV   r]   rY   r`   r   r&  rc   r8  r@  rQ  rh   rY  rW  ru   rv   r   r   rx   rx      s    & HMM 1$6
0[zIVK"6H:&	6E9N). ""2I.FF#J.)Vr   rx   c                   \   ^  \ rS rSrSrSrSr SU 4S jjrSS jrS r	S r
S	 rS
 rSrU =r$ )TarFileArchivei  z9archive class using python TarFile to create tar archivesNFc           	         > [         TU ]  XX4XVU5        SU l        [        R                  R                  X R                  5       5      U l        g )Ntar)superr   _suffixr   rQ   r   r7   r=  )	r   r7   r   r   r   r   r   r   	__class__s	           r   r   TarFileArchive.__init__  s>    v!H	6WW\\IIK
r   c                    UR                   Ul        UR                  S UR                  S'   UR                  S UR                  S'   U(       a  X1l        OUR                  Ul        UR                  Ul        UR                  Ul
        g )Nz.9fatimectime)st_mtimemtimest_atimepax_headersst_ctimerD   r   r   uidr   gid)r   tar_infofstatrD   s       r   set_tarinfo_from_stat$TarFileArchive.set_tarinfo_from_stat  sh    +0>>#*>W%+0>>#*>W% M!MMHM||||r   c                   ^ UR                   [        [        R                  R	                  U R
                  5      S   5      S  mT(       d  U R
                  m/ SQn[        U4S jU 5       5      (       a  g  [        R                  " T5      nU R                  (       a&  U R                  T5      nU(       a  XAR                  S'   U R                  X5        U$ ! [         a    Us $ f = f)N)z/version.txt$z/sos_logs(/.*)?z/sos_reports(/.*)?c              3   R   >#    U  H  n[         R                  " UT5      v   M     g 7fr   )rE  match).0skip	orig_paths     r   	<genexpr>9TarFileArchive.copy_permissions_filter.<locals>.<genexpr>  s     ;UTrxxi((Us   $'zRHT.security.selinux)r7   lenr   rQ   r   r   r   r   r   _with_selinux_contextget_selinux_contextr}  r  )r   tarinfoskipsr  contextr  s        @r   copy_permissions_filter&TarFileArchive.copy_permissions_filter  s    LLRWW]]43E3E%Fr%J!K!LM	**IJ;U;;;	GGI&E %%..y9G>E##$:;""72  	N	s   7C C&%C&c                 X     [         R                  " U5      u  p#U$ ! [         a     g f = fr   )selinux
getfileconr   )r   rQ   _cs       r   r  "TarFileArchive.get_selinux_context  s0    	''-FQH 		s    
))c                 8    U R                    SU R                   3$ )N.)r   rt  r6   s    r   r7   TarFileArchive.name  s    $$%Qt||n55r   c                    US:X  a  [        S5      b  SOSnUR                  S5      nU R                   SU 3U l        US:X  a  SS0nOS	S
0n[        R                  " U R                  4SSU 30UD6 nS H  n[
        R                  R                  [
        R                  R                  U R                  U5      5      (       d  MQ  UR                  [
        R                  R                  U R                  U5      U R                   SU 3S9  M     UR                  U R                  U R                  U R                  S9  S S S 5        U =R                  SU 3-  sl        U R                  5       $ ! , (       d  f       N6= f)Nautolzmaxzgzipipr  compresslevel   preset   rD   zw:)zversion.txtr1  sos_logsr|   )arcname)r  filter)r   stripr=  tarfiler   r   rQ   r   r   r   addr5   r  rt  r7   )r   rg   
_comp_modekwargsrr  _contents         r   rW  TarFileArchive._build_archive  s[   V&v.:TF\\$'
 $ 2 231ZLA V%q)F]F\\$,, $R
|3D $"$'* G77>>"'',,t/A/A8"LMMGGT%7%7B#'::,az :   G GGD&&

77  9$ 	!J<((yy{!$ $s   3AE1A:E11
E?)r=  rt  r   )r   rm   rn   ro   rp   rg   r  r   r  r  r  r7   rW  ru   __classcell__)ru  s   @r   rp  rp    s9    DF! 
	$$6 r   rp  )r   r  r   rr   r   r  r   rE  r   	threadingr   importlib.utilr   sos.utilitiesr   r  ImportErrorr   r   r   r   r   rx   rp  rv   r   r   <module>r     s    
       	   $ 0	 
		Z" Z"zZw ZzS% SM  	 			s   A' 'A0/A0