+
    iR  c                   s    ^ 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
 ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHt  ! R R4      t ! R R4      tR# )    N)fill)SUPPRESS)datetime)getpass)rmtree)Path)__version__)TarFileArchive)
SoSOptions)TempFileUtil	shell_outc                   s  a  ] tR t^t o RtRt/ tRtRtRt	Rt
RRRRRR	R
RRRRRRRRRR^RRRRR^ /t. R*OtR tR tR tR tR+R ltR tR t]R 4       tR tR tR tR  tR! tR,R" ltR# tR$ tR% tR& tR' t R( t!R)t"V t#R# )-SoSComponenta  Any sub-command that sos supports needs to subclass SoSComponent in
order to be properly supported by the sos binary.

This class contains the standardized entrypoint for subcommands, as well as
building out supported options from both globally shared option lists, and
options supported by that specific subcommand.

When sos initializes, it will load an unintialized instance of each class
found within one recursion of the module root directory that subclasses
SoSComponent.

If sos is able to match the user-specified subcommand to one that exists
locally, then that SoSComponent is initialized, logging is setup, and a
policy is loaded. From there, the component's execute() method takes over.

Added in 4.0
ZunsetTFbatchcompression_typeautoconfig_filez/etc/sos/sos.confZdebugencryptencrypt_keyNencrypt_passquietthreadstmp_dir sysroot	verbosityc                sd   Wn         W n        W0n        R V n        RV n        RV n        RV n        RV n         ^ RIpVP                  VP                  V P                  4       4       \        V P                   R7      V n        V P$                  '       d   V P'                  4        V P                   P)                  V P*                  4       V P-                  4       V n        V P.                  '       Ed   V P1                  4       p\3        4       V n        \4        P6                  P9                  V4      '       d,   \4        P:                  ! V\4        P<                  4      '       g@   RV R2pVR,          p\        P>                  P                  V4       V PA                  ^4       W`n!        \D        PF                  ! RV PB                  R	7      V n        \I        V P
                  4      V n        V PK                  4        V P                  Eer   V P                  PM                  R
\N        4       V P                  PM                  RRPQ                  V P                  4      4       V P                  PM                  R\R        PT                  ! 4       4       V P                  PM                  RR4       V P                  PM                  RR4       V P                  PM                  RR4       V P                  PM                  RV P
                  4       V P                  PM                  RV PV                  4       V P                  PM                  RV PX                  PZ                  4       V P                  P]                  R4       R# R#   \         d/   p\        P                  P                  RT R24        Rp?ELERp?ii ; i)FNz'Notice: Could not set SIGTERM handler: 
arg_defaultsztemporary directory Z z"does not exist or is not writable
zsos.)ZprefixZdirZversioncmdlineZ
start_timeZend_timer   Zrun_timeZcompressiontmpdirZtmpdir_fs_typepolicyZ
components)/parserargsr   exit_processarchiver   tempfile_utilmanifestsignalZSIGTERMget_exit_handler	Exceptionsysstdoutwriter	   _arg_defaultsoptsload_policyload_local_policyZupdater   load_optionsconfigure_loggingget_tmpdir_defaultSoSMetadataospathZisdirZaccessZW_OKstderr_exitsys_tmptempfileZmkdtempr
   _setup_logging	add_fieldr   joinr   Znow	tmpfstyper   Zos_release_nameadd_section)selfr    Zparsed_argsZcmdline_argsr&   errr   msgs   &&&&    2/usr/lib/python3.14/site-packages/sos/component.py__init__ZSoSComponent.__init__R   s   	#!!	PMM&..$*?*?*AB D,>,>?	""$ 	!!$"3"34%%'	!!!,,.F'MDM77==((99VRWW55,VHA6<<

  %

1!L"**&dllKDK!-dkk!:D!==$MM##I{;MM##Isxx/EFMM##L(,,.AMM##J3MM##J3MM##M26MM##Hdkk:MM##$4dnnEMM##Hdkk.I.IJMM%%l3 %=  	PJJFse2NOO	Ps   .M6 6N/#N**N/c                sH    ^ RI pVP                  P                  V P                  P                  V P
                  R7      V n        V P                  P                  V n        V P                  P                  4       V n
        R#   \         d    T P                  ^ 4        L?i ; i)r    N)r   Zprobe_runtime)Zsos.policiesZpoliciesZloadr-   r   
load_prober   ZKeyboardInterruptr7   Zis_root_is_root)r?   sos   & rB   r/   ZSoSComponent.load_local_policy   s|    	,,++DII4E4E:>// , KDK;;..DL ++- ! 	JJqM	s   AB B! B!c                    \         hNZNotImplementedErrorr?      &rB   executeZSoSComponent.execute   s    !!    c                s   a  V 3R  lpV# )c                 s6   < R Sn         SP                  4        R# )TN)r"   r7   )ZsignumZframer?   s   &&rB   exit_handlerZ3SoSComponent.get_exit_handler.<locals>.exit_handler   s     $DJJLrN    )r?   rO   s   f rB   r'   ZSoSComponent.get_exit_handler   s    	 rN   c                s    V'       d7   V P                   P                  R 4       V P                   P                  V4       \        V4      hr   )ui_logerrorZ
SystemExit)r?   rS   rA      &&&rB   r7   ZSoSComponent._exit   s4    KKb!KKc"rN   c                s   V P                   P                  '       d5   \        P                  P	                  V P                   P                  4      pM:\        P
                  ! RR4      ;'       g    V P                  P                  R4      p\        RV 24      P                  4       V n
        V P                  R8X  d"   \        R4       \        P                  ! ^4       V# )zIf --tmp-dir is not specified, provide a default location.
Normally this is /var/tmp, but if we detect we are in a container, then
use a standardized env var to redirect to the host's filesystem instead
ZTMPDIRNzstat --file-system --format=%T ZtmpfszWARNING: tmp-dir is set to a tmpfs filesystem. This may increase memory pressure and cause instability on low memory systems, or when using --all-logs.)r-   r   r4   r5   ZabspathZgetenvr   Zget_tmp_dirr   Zstripr=   printtimeZsleep)r?   r   rG   rB   r2   ZSoSComponent.get_tmpdir_default   s    
 99WW__TYY%6%67FYYx.OO$++2I2I$2OF #-fX6

%' 	 >>W$  > ? JJqMrN   c                s4  a  S P                   P                  4       P                  4        Uu. uF  qP                  R 4      '       g   K  VNK  	  ppV'       d;   \        ;QJ d    V 3R lV 4       F  '       g   K   R# 	  R# ! V 3R lV 4       4      # R# u upi )listc              3   sP   <"   T F  p\        SP                  V4      x  K  	  R # 5irI   )getattrr-   )Z.0optr?   s   & rB   Z	<genexpr>Z5SoSComponent.check_listing_options.<locals>.<genexpr>   s     ?$3wtyy#..$s   #&TF)r-   dictkeys
startswithZany)r?   or-   s   f  rB   check_listing_optionsZ"SoSComponent.check_listing_options   sm    99>>+002K2all66J2K3?$?33?3?3?$??? Ls   B	Bc                rH   )zYThis should be overridden by each subcommand to add its own unique
options to the parser
rJ   )Zclsr       &&rB   add_parser_optionsZSoSComponent.add_parser_options   s
    
 "!rN   c                sZ   \        4       P                  V P                  P                  V P                  4      VP                  RR7      R7      pVP                  RR7      pVP                  4        EF  w  rEWBP                  P                  4       9  g   VR. R39   d   K0  VR9   de   R F^  p\        V4      \        \        W4      4      ,          pV'       g   K1  \        Y\        W4       Uu. uF  pW9  g   K  VNK  	  up4       K`  	  VR8X  d   \        W4      p	V U
u. uF  qP                  R4      ^ ,          NK  	  pp
V	 U
u. uF  qP                  R4      ^ ,          NK  	  pp
\        V4      \        V4      ,           F2  pV R2pV	 Uu. uF  pVP                  V4      '       d   K  VNK   	  p	pK4  	  \        W\        \        V4      \        V	4      ,          4      4       EK{  WQP                  V,          8w  g   EK  \        WV4       EK  	  V# u upi u up
i u up
i u upi )	a  (Re-)apply options specified via the cmdline to an options instance

There are several cases where we may need to re-apply the options from
the cmdline over previously loaded options - for instance when an
option is specified in both a config file and cmdline, or a preset and
the cmdline, or all three.

Use this to re-apply cmdline option overrides to anything that may
change the default values of options

Positional arguments:

    :param opts:        SoSOptions object to update

F)Zpreset_filterr   Nr   ZplugoptsZ=)Zenable_pluginsZskip_pluginsZonly_plugins)r	   Z	from_argsr    Z
parse_argsr   rZ   itemsr   r[   ZsetrX   ZsetattrZsplitr\   rW   )r?   r-   ZcmdoptsZcodictrY   ZvalZooptZcommonZxZ	oplugoptsZvZvalnamesZ	ovalnamesZcstrings   &&            rB   apply_options_from_cmdlineZ'SoSComponent.apply_options_from_cmdline   s   & ,((KK""4<<07 ) 
 E2HC..3355r29N HHND XGD,?(@@F v8K -48K1#$? ./Q8K -4 5 O j #D.	589SGGCLOOS96?@iWWS\!__i	@!(mc)n<<F!'lG2; !B)$(,(@ "&)I !BI = 4C3y>(A#BC))#..3'; '> '-4 :@!Bs$   .H;H" H H#H(/H(c                sX   \        V P                  R7      pV P                  P                   F!  pVP                  \
        8w  g   K  RVn        K#  	  VP                  V P                  P                  V P                  P                  4       RV P                  9   g   RV P                  9   d'   VP                  V P                  P                  R4       \        P                  ! 4       ^ 8w  d~   \        P                  P                  \        P                   ! 4       R4      p\        P                  P#                  V4      '       d&   VP                  W0P                  P                  4       V P%                  V4      pRV n        \)        VR4      '       Ed   VP&                  V P                  R,          8w  d   V P*                  P-                  VP&                  4      V n        V P&                  '       gT   \.        P0                  P3                  RVP&                   R	24       V P*                  P5                  4       V n        R
Vn        V P&                  '       g    V P*                  P5                  4       V n        VP9                  V P&                  P:                  R
R7       V P%                  V4      p\)        V P&                  P:                  R4      '       dU   V P&                  P:                  P<                  ^ 8  d0   V P?                  V P&                  P:                  P<                  4       V# )zhCompile arguments loaded from defaults, config files, and the
command line into a usable set of options
r   Nz--cleanz--maskcleanz.config/sos/sos.confpresetzUnknown preset: 'z'
T)Z
prefer_newr   ) r	   r,   r    Z_actionsdefaultr   Zupdate_from_confr!   r   Z	componentr   r4   Zgetuidr5   r<   r   ZhomeZexistsrb   rd   Zhasattrr   Zfind_presetr)   r6   r+   Zprobe_presetZlist_presetsZmerger-   r   set_loggers_verbosity)r?   r-   ZoptionZuserconfs   &   rB   r0   ZSoSComponent.load_options  s   
 t'9'9:kk**F~~)!% + 	dii33TYY5H5HI $DLL(@!!$))"7"7A99;!ww||DIIK1GHHww~~h''%%h		0C0CD..t4 4""{{d00::"kk55dkkB{{{JJ$$'8S%IJ"&++":":"<DK(,D% ;;;"kk668JJt{{''DJ92248Dt{{''55KK$$..2**4;;+;+;+E+EFrN   c                sr    V P                   '       d   V P                   P                  4        V P                  '       d   V P                  P                  4        V P                  '       d   \        V P                  4       R# R#   \         d'   p\        R T RT P                   24        Rp?R# Rp?ii ; i)zFailed to finish cleanup: z
Contents may remain in N)r#   cleanupr$   rc   r   r   r(   rU   )r?   r@   rG   rB   rg   ZSoSComponent.cleanup9  s    		$|||$$&!!!""((*{{{t{{#  	$.se3L[[M# $ $	$s(   B +B  +B ,B B6B11B6c                s   R p\         P                  P                  R4      '       d2   \         P                  P                  R4      V P                  n        RpMU\         P                  P                  R4      '       d1   \         P                  P                  R4      V P                  n        RpV P                  P                  V4       V P                  P                  V4       R# )zFNo encryption environment variables set, archive will not be encryptedZSOSENCRYPTKEYz+Encryption key set via environment variableZSOSENCRYPTPASSz2Encryption passphrase set via environment variableN)	r4   ZenvironZgetr-   r   r   sosloginforR   )r?   rA   rG   rB   _set_encrypt_from_env_varsZ'SoSComponent._set_encrypt_from_env_varsG  s    ::>>/**$&JJNN?$CDII!?CZZ^^,--%'ZZ^^4D%EDII"FCrN   c                s   V P                   P                  '       g   R pVR	9  d   \        R4      P                  4       pK"  VR8X  d   \	        R4      V P                   n        R # VR8X  d   \        R4      V P                   n        R # VR8X  d   V P                  4        R # R V P                   n        R V P                   n        V P                  P                  R4       V P                  P                  R4       R # V P                  4        R # )
NPKEzLSpecify encryption method [P]assphrase, [K]ey, [E]nv vars, [N]o encryption: zSpecify encryption passphrase: zSpecify encryption key: z@User specified --encrypt, but chose no encryption when prompted.zArchive will not be encrypted)rk   rl   rm   ZN)r-   r   ZinputZupperr   r   r   rj   rh   ri   rR   Zwarning)r?   Z_encrG   rB   _get_encryption_methodZ#SoSComponent._get_encryption_methodS  s    yyD22. 57  s{)0 2@ *A		&(-.H(I		%//1(,		%)-		&   "= >##$CD++-rN   c           	     s   V P                   P                  '       d   V P                  4        R V P                   P                  ;'       g    V P                   P                  RV P                   P                  RV P                   P                  /pV'       g   V P
                  P                  4       p\        P                  P                  V P                  V4      pV P                   P                  R8X  di   V P
                  P                  4       pV! W0P                  V P
                  V P                   P                  W P                  V P                  4      V n        MP\#        W0P                  V P
                  V P                   P                  W P                  V P                  4      V n        V P                   P%                  V P                   P&                  ^8  4       R# )r   ZkeyZpasswordr   N)r-   r   rn   r   r   r   Zget_archive_namer4   r5   r<   r   r   Zget_preferred_archiver   r   r%   r#   r   Z	set_debugr   )r?   ZnameZenc_optsZarchive_nameZauto_archive   &&   rB   setup_archiveZSoSComponent.setup_archivek  sB   99'')tyy--FF1F1F499((		..

 ;;//1Dww||DKK699%%/;;<<>L'kk(,TYY5F5F(0,,(,7DL *,*.++tyy7H7H*2LL*.--9DL
 	tyy22Q67rN   c                s*   V P                   P                  4       pV P                   Fh  p\        V4      P	                  V4       FG  p\
        P                  P                  W14      pR F  pV P                   P                  W4R4       K!  	  KI  	  Kj  	  R# )(--upload-pass[\s=]+)\S+z
\1********N)rq   z$(--upload-url[\s=]+\S+://.*:)([^@]*)z!(--upload-s3-secret-key[\s=]+)\S+)	r#   Zget_archive_pathfiles_with_upload_passwdr   Zglobr4   r5   ZrelpathZdo_file_sub)r?   Z	_arc_pathr5   ZfZres   &    rB   _obfuscate_upload_passwordsZ(SoSComponent._obfuscate_upload_passwords  su     LL113	11D)_))$/GGOOA1AB LL,,QMBA 0 2rN   c                sb   \         P                  ! \        P                  4      pVP	                  \         P
                  ! R 4      4       TP                  V P                  P                  ^8  d   \         P                  M\         P                  4       V P                  P                  V4       R# )%(message)sN)loggingStreamHandlerr)   r*   setFormatter	FormattersetLevelr-   r   DEBUGINFOrR   
addHandler)r?   Z
ui_consolerG   rB   add_ui_log_to_stdoutZ!SoSComponent.add_ui_log_to_stdout  so    **3::6
 1 1- @A!YY0014GMM',,	
 	z*rN   c                s   \        V R R4      '       d2   V'       d*   V P                  P                  \        P                  4       \        V RR4      '       dz   V'       dG   V P
                  P                  ^8  d,   V P                  P                  \        P                  4       R# V P                  P                  \        P                  4       R# R# )flogNconsole)	rX   r~   ry   ru   rz   r-   r   r   ZWARNING)r?   r   r_   rB   rf   Z"SoSComponent.set_loggers_verbosity  s}    4&&9IIw}}-4D))TYY0014%%gmm4%%goo6	 *rN   c                s
   \         P                  ! R4      V n        V P                  P                  \         P                  4       RV n        V P                  4       '       g   V P                  4       V n        \         P                  ! V P                  4      V n        V P
                  P                  \         P                  ! R4      4       V P
                  P                  \         P                  4       V P                  P                  V P
                  4       V P                  P                  '       g   \         P                  ! \         P"                  4      V n        V P$                  P                  \         P                  ! R4      4       V P'                  V P                  P(                  4       V P                  P                  V P$                  4       M\         P                  ! \         P*                  4      pVP                  \         P                  ! R4      4       VP                  \         P,                  4       V P                  P                  V4       \         P                  ! R4      V n        V P.                  P                  V P                  P(                  ^8  d   \         P                  M\         P                  4       V P                  4       '       gv   V P                  4       V n        \         P                  ! V P0                  4      pVP                  \         P                  ! R4      4       V P.                  P                  V4       V P                  P                  '       g   V P3                  4        R# R# )zCreates the log handler that shall be used by all components and any
and all related bits to those components that need to log either to the
console or to the log file for that run of sos.
rF   Nz&%(asctime)s %(levelname)s: %(message)srt   Zsos_ui)ru   Z	getLoggerrh   ry   rz   r~   r^   get_temp_filesos_log_filerv   rw   rx   r{   r|   r-   r   r)   r*   r   rf   r   r6   ZERRORrR   sos_ui_log_filer}   )r?   Zconsole_errZui_fhandlers   &  rB   r:   ZSoSComponent._setup_logging  sF    ''.W]]+	))++ $ 2 2 4D--d.?.?@DIII""7#4#48$: ;IIw||,KK""499-yy"00<DLLL%%g&7&7&FG&&tyy':':;KK""4<<0 "//

;K$$W%6%6}%EF  /KK"";/ ''1!YY0014GMM',,	
 ))++#'#5#5#7D !//0D0DEK$$W%6%68&: ; KK"";/yy%%' rN   c                s6    V P                   P                  4       # rI   )r$   ZnewrK   rL   rB   r   ZSoSComponent.get_temp_file  s    !!%%''rN   c                sr    ^PpRpVP                  4        F  pV\        WBRR7      ,           R,           pK   	  V# )iP   r   F)Zreplace_whitespacer   )Z
splitlinesr   )r?   rA   ZwidthZ_fmtZlinero   rB   _fmt_msgZSoSComponent._fmt_msg  s8    NN$D$tuEELD %rN   )rE   r#   r!   r   r   r"   r~   r%   r-   r    r   rd   r   r   rh   r8   r   r$   r   r=   rR   )zsos_logs/sos.logzsos_reports/manifest.jsonzsos_commands/process/ps_*zsos_commands/selinux/ps_*z+sos_commands/systemd/systemctl_status_--all)r    NrQ   )$__name__
__module____qualname____firstlineno____doc__Zdescr   r1   r.   rD   Zroot_requiredr,   rr   rC   r/   rM   r'   r7   r2   r^   Zclassmethodr`   rb   r0   rg   rj   rn   rp   rs   r}   rf   r:   r   r   __static_attributes____classdictcell__Z__classdict__   @rB   r   r      s     $ DLKJM 	F*5t124QM  64p." 4 " ":x1f$
.084C"+7,(\( rN   r   c                   s^   a  ] tR tRt o RtR tR tR tR tR t	R t
. 3R	 ltRR ltRtV tR
# )r3   i  a$  This class is used to record metadata from a sos execution that will
then be stored as a JSON-formatted manifest within the final tarball.

It can be extended by adding further instances of SoSMetadata to represent
dict-like structures throughout the various sos bits that record to
metadata
c                s    / V n         R # rI   _valuesrK   rL   rB   rC   ZSoSMetadata.__init__  s	    rN   c              #  sf   "   V P                   P                  4        F  pV^,          x  K  	  R# 5i)i   N)r   ra   r?   ZitemrG   rB   __iter__ZSoSMetadata.__iter__  s%     LL&&(Dq'M )s   /1c                (    V P                   V,          # rI   r   r   r_   rB   __getitem__ZSoSMetadata.__getitem__      ||D!!rN   c                r   rI   r   )r?   Zattrr_   rB   __getattr__ZSoSMetadata.__getattr__  r   rN   c                s"    W P                   V&   R# )z@Add a key, value entry to the current metadata instance
        Nr   )r?   Z
field_namecontentrT   rB   r;   ZSoSMetadata.add_field  s     $+Z rN   c                sV    \        4       V P                  V&   V P                  V,          # )zCAdds a new instance of SoSMetadata to the current instance
        )r3   r   )r?   Zsection_namer_   rB   r>   ZSoSMetadata.add_section  s#     &1]\"||L))rN   c                sd    \        V\        4      '       g   \        R4      hW P                  V&   R# )zAdd a named list element to the current instance. If content is not
supplied, then add an empty list that can alter be appended to
zcontent added must be listN)Z
isinstancerW   Z	TypeErrorr   )r?   Z	list_namer   rT   rB   add_listZSoSMetadata.add_list  s)     '4((899")YrN   Nc                s6    \         P                  ! V R VR7      # )zConvert contents of this SoSMetdata instance, and all other nested
instances (sections), into a json-formatted output.

Used to write manifest.json to the final archives.
c                 s.    \        V R \        V 4      4      # r   )rX   Zstr)r]   rL   rB   Z<lambda>Z&SoSMetadata.get_json.<locals>.<lambda>  s    GAy#a&,IrN   )re   indent)jsonZdumps)r?   r   r_   rB   get_jsonZSoSMetadata.get_json	  s     zz$"I!') 	)rN   r   rI   )r   r   r   r   r   rC   r   r   r   r;   r>   r   r   r   r   r   r   rB   r3   r3     s<     ""+
* +- *) )rN   r3   )r   ru   r4   r9   r)   rV   Ztextwrapr   Zargparser   r   r   Zshutilr   Zpathlibr   rF   r   Zsos.archiver   Zsos.optionsr	   Zsos.utilitiesr
   r   r   r3   rP   rN   rB   <module>r      sN      	  
         & " 1~ ~B1) 1)rN   