JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr O6uflOddlZddlZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl m Z ddlmZddlmZdd lmZdd lmZmZGd d ZGd dZy)N)SUPPRESS)datetime)getpass)rmtree)Path) __version__)TarFileArchive) SoSOptions) TempFileUtil shell_outc eZdZdZdZiZdZdZdZdZ dddddddddd dd d Z gd Z d Z dZ dZdZd dZdZdZedZdZdZdZdZdZd!dZdZdZdZdZdZy)" SoSComponentaAny 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 unsetTFautoz/etc/sos/sos.confNr) batchcompression_type config_filedebugencrypt encrypt_key encrypt_passquietthreadstmp_dirsysroot verbosity)zsos_logs/sos.logzsos_reports/manifest.jsonzsos_commands/process/ps_*zsos_commands/selinux/ps_*z+sos_commands/systemd/systemctl_status_--allc ||_||_||_d|_d|_d|_d|_d|_ ddl}|j|j|jt|j |_|j$r|j'|j j)|j*|j-|_|j.r|j1}t3|_t4j6j9|r$t5j:|t4j<s;d|d}|dz }tj>j||jAd ||_!tEjFd |jB |_tI|j |_|jK|jo|jjMd tN|jjMd djQ|j|jjMdtSjT|jjMdd|jjMdd|jjMdd|jjMd|j |jjMd|jV|jjMd|jXjZ|jj]dyy#t$r.}tjjd|dYd}~ d}~wwxYw)NFrz'Notice: Could not set SIGTERM handler:   arg_defaultsztemporary directory  z"does not exist or is not writable zsos.)prefixdirversioncmdline start_timeend_timerrun_time compressiontmpdirtmpdir_fs_typepolicy components)/parserargsr( exit_processarchiver- tempfile_utilmanifestsignalSIGTERMget_exit_handler Exceptionsysstdoutwriter _arg_defaultsopts load_policyload_local_policyupdater" load_optionsconfigure_loggingget_tmpdir_default SoSMetadataospathisdiraccessW_OKstderr_exitsys_tmptempfilemkdtempr _setup_logging add_fieldrjoinrnow tmpfstyper/distro add_section)selfr1 parsed_args cmdline_argsr7errr-msgs //usr/lib/python3/dist-packages/sos/component.py__init__zSoSComponent.__init__Qs  # !  !  P  MM&..$*?*?*A BD,>,>?     " " $ !!$"3"34%%'  ! !,,.F'MDM77==(99VRWW5,VHA6<<   % 1 !DL"**&dllKDK!-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.@.@ A MM % %l 3 %= P JJ  Fse2N O O Ps.M N #NN cB ddl}|jj|jj|j |_|j j|_|j j|_ y#t$r|jdY//,KDK;;..DL ++- !  JJqM sABBBctN)NotImplementedErrorrXs r]executezSoSComponent.executes!!cfd}|S)Nc4d_jy)NT)r3rM)signumframerXs r] exit_handlerz3SoSComponent.get_exit_handler..exit_handlers $D  JJLrn)rXrss` r]r9zSoSComponent.get_exit_handlers rnc|r6|jjd|jj|t|)Nr)ui_logerror SystemExit)rXrwr\s r]rMzSoSComponent._exits4  KK  b ! KK  c "rncJ|jjr4tjj |jj}ntj ddxsd}tj ddrXtj ddrBtjj tj d|jd}td|j|_ |jdk(r td tjd |S) 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 TMPDIRNz/var/tmpHOST container/zstat --file-system --format=%T 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?rrGrHabspathgetenvrSlstripr striprUprinttimesleep)rXr-s r]rEzSoSComponent.get_tmpdir_defaults 99  WW__TYY%6%67FYYx.<*F 99VT "ryyd'CWW\\"))F"3V]]35GHF#-fX 6 %'  >>W $ > ? JJqM rnc |jjjDcgc]}|jds|}}|r-t |Dcgc]}t |j|c}Sycc}wcc}w)NlistF)r?dictkeys startswithanygetattr)rXor?opts r]check_listing_optionsz"SoSComponent.check_listing_optionssd99>>+002Kaall66JKK 4@C 3/@A AL@sA8A8A=cy)ziThis should be overridden by each subcommand to add its own unique options to the parser Nrt)clsr1s r]add_parser_optionszSoSComponent.add_parser_optionss rnc 8tj|jj|j|j d}|j d}|j D]\}}||jjvs|dgdfvr*|dvrTdD]O}t|tt||z}|s't||t||Dcgc]}||vr| c}Q||j|k7st||||Scc}w)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) preset_filterr!Nr)enable_plugins skip_plugins only_plugins) r from_argsr1 parse_argsr(ritemsr"rsetrsetattr) rXr?cmdoptscodictrvalooptcommonxs r]apply_options_from_cmdlinez'SoSComponent.apply_options_from_cmdlines%&,(( KK " "4<< 07) E2  (HC'..3355r29NHHN5D XGD$,?(@@Fdd8K-41#$F?./-45 5d'',,c3'! ($ -4s Dct|j}|jjD]}|jt k7sd|_|j |jj|jjd|jvsd|jvr&|j |jjdtjdk7rwtjjtj d}tjj#|r&|j ||jj|j%|}d|_t)|drx|j&|jdk7r|j*j-|j&|_|j&sSt.j0j3d |j&d |j*j5|_d |_|j&s|j*j5|_|j9|j&j:|j%|}t)|j&j:d rR|j&j:j<dkDr/|j?|j&j:j<|S) zxCompile arguments loaded from defaults, config files, and the command line into a usable set of options r!Nz--cleanz--maskcleanrz.config/sos/sos.confpresetzUnknown preset: 'z' Tr) r r>r1_actionsdefaultrupdate_from_confr2r componentr(rGgetuidrHrSrhomeexistsrrhasattrr/ find_presetr;rLr= probe_preset list_presetsmerger?rset_loggers_verbosity)rXr?optionuserconfs r]rCzSoSComponent.load_optionss t'9'9:kk** &F~~)!% & dii33TYY5H5HI  $DLL(@  ! !$))"7"7 A 99;! ww||DIIK1GHHww~~h'%%h 0C0CD..t4 4 "{{d00::"kk55dkkB {{JJ$$'8 S%IJ"&++":":">/ *$&JJNN?$CDII !?C ZZ^^, -%'ZZ^^4D%EDII "FC  rnc|jjsd}|dvrtdj}|dvr|dk(rt d|j_y|dk(rtd|j_y|dk(r|jyd|j_d|j_|jjd|jjd y|jy) N)PKENzLSpecify encryption method [P]assphrase, [K]ey, [E]nv vars, [N]o encryption: rzSpecify encryption passphrase: rzSpecify encryption key: rz@User specified --encrypt, but chose no encryption when prompted.zArchive will not be encrypted) r?rinputupperrrrrrrrvwarning)rX_encs r]_get_encryption_methodz#SoSComponent._get_encryption_methodHsyyD22.5722 s{)02@*A &(-.H(I %//1(, %)- &   "=> ##$CD  + + -rnc |jjr|j|jjs|jjrdnd|jj|jjd}|s|j j }tjj|j|}|jjdk(rj|j j}|||j|j |jj||j|j|_nRt#||j|j |jj||j|j|_|j j%|jj&dkDy)NTF)rkeypasswordrr)r?rrrrr/get_archive_namerGrHrSr-rget_preferred_archiverrr6r4r set_debugr)rXnameenc_opts archive_name auto_archives r] setup_archivezSoSComponent.setup_archive`sD 99    ' ' ) $ 6 6 $ 5 5L' dkk(, TYY5F5F(0$,,(, 7DL *, *.++tyy7H7H*2DLL*.--9DL tyy22Q67rnc |jj}|jD]e}t|j |D]F}t j j||}dD]}|jj||d!Hgy)N)z(--upload-pass[\s=]+)\S+z$(--upload-url[\s=]+\S+://.*:)([^@]*)z!(--upload-s3-secret-key[\s=]+)\S+z \1********) r4get_archive_pathfiles_with_upload_passwdrglobrGrHrelpath do_file_sub)rX _arc_pathrHfres r]_obfuscate_upload_passwordsz(SoSComponent._obfuscate_upload_passwords{sLL113 11 CD)_))$/ CGGOOAy1ACBLL,,QMBC C CrncXtjtj}|j tj d|j |jjdkDrtjntj|jj|y)N %(message)sr$) logging StreamHandlerr;r< setFormatter FormattersetLevelr?rDEBUGINFOrv addHandler)rX ui_consoles r]add_ui_log_to_stdoutz!SoSComponent.add_ui_log_to_stdoutso**3::6  1 1- @A!YY0014GMM',,  z*rnclt|ddr+|r)|jjtjt|ddro|rC|j j dkDr*|jjtjy|jjtjyy)Nflogconsoler$) rrrrrr?rrWARNING)rXrs r]rz"SoSComponent.set_loggers_verbositysw 4 &9 II  w}} - 4D )TYY0014 %%gmm4 %%goo6 *rnctjd|_|jjtjd|_|j s|j|_tj|j|_|j jtjd|j jtj|jj|j |jjstjt j"|_|j$jtjd|j'|jj(|jj|j$ntjt j*}|jtjd|jtj,|jj|tjd|_|j.j|jj(dkDrtjntj|j ss|j|_tj|j0}|jtjd|j.j||jjs|j3yy)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. rhNz&%(asctime)s %(levelname)s: %(message)srsos_uir$)r getLoggerrrrrr get_temp_file sos_log_filerrrrrr?rr;r<rrrrLERRORrvsos_ui_log_filer)rX console_err ui_fhandlers r]rQzSoSComponent._setup_loggings< ''.  W]]+ ))+ $ 2 2 4D --d.?.?@DI II " "7#4#48$: ; II  w|| , KK " "499 -yy"00
rr^rArmr9rMrEr classmethodrrrCrrrrrrrrQrrtrnr]rrs$ DLKJM"* M  64p."  :   -^1f $ .086C"+7,(\(rnrcFeZdZdZdZdZdZdZdZdZ gfdZ d d Z y ) rFa8This 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 ci|_yrj_valuesrls r]r^zSoSMetadata.__init__s  rnc#XK|jjD] }|d yw)Nr$)rrrXitems r]__iter__zSoSMetadata.__iter__s+LL&&( Dq'M s(*c |j|Srjrrs r] __getitem__zSoSMetadata.__getitem__s||D!!rncR |j|S#t$r t|wxYwrj)rr:AttributeError)rXattrs r] __getattr__zSoSMetadata.__getattr__s0 '<<% % ' & & 's&c"||j|<y)z@Add a key, value entry to the current metadata instance Nr)rX field_namecontents r]rRzSoSMetadata.add_fields$+ Z rncNt|j|<|j|S)zCAdds a new instance of SoSMetadata to the current instance )rFr)rX section_names r]rWzSoSMetadata.add_sections#&1] \"||L))rncXt|ts td||j|<y)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 zcontent added must be listN) isinstancer TypeErrorr)rX list_namers r]add_listzSoSMetadata.add_lists('4(89 9") YrnNc4tj|d|S)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.t|dt|S)Nr)rstr)rs r]z&SoSMetadata.get_json..sGAy#a&,Irn)rindent)jsondumps)rXrs r]get_jsonzSoSMetadata.get_jsons zz$"I!') )rnrj) rrrrr^r r rrRrWrr!rtrnr]rFrFs4"' + * +-*)rnrF)rrrGrOr;rargparserrrshutilrpathlibrrhr sos.archiver sos.optionsr sos.utilitiesr r rrFrtrnr]r(sK   &"1n(n(b 4)4)rn