404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.137.166.174: ~ $
3

�f6O�@s�ddlZddlZddlZddlZddlZddlZddlmZddlmZddl	m	Z	ddl
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZmZGdd�d�ZGd
d�d�ZdS)�N)�SUPPRESS)�datetime)�getpass)�rmtree)�Path)�__version__)�TarFileArchive)�
SoSOptions)�TempFileUtil�	shell_outc
@s�eZdZdZdZiZdZdZdZdZ	dddddddddd	dd
d�Z
dd
dddgZdd�Zdd�Z
dd�Zdd�Zd7dd�Zdd�Zdd�Zedd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd8d+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�ZdS)9�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
    ZunsetTF�autoz/etc/sos/sos.confN��r)�batch�compression_type�config_file�debug�encrypt�encrypt_key�encrypt_pass�quiet�threads�tmp_dir�sysroot�	verbosityzsos_logs/sos.logzsos_reports/manifest.jsonzsos_commands/process/ps_*zsos_commands/selinux/ps_*z+sos_commands/systemd/systemctl_status_--allcCs�||_||_||_d|_d|_d|_d|_d|_yddl}|j|j	|j
��Wntk
rbYnXt|j
d�|_|jr�|j�|j
j|j�|j�|_|j�r |j�}t�|_tjj|�s�tj|tj�r�d|}|d7}tjj|�|jd�||_ t!j"d|j d�|_t#|j�|_|j$�|jdk	�r�|jj%d	t&�|jj%d
dj'|j��|jj%dt(j)��|jj%d
d�|jj%dd�|jj%dd�|jj%d|j�|jj%d|j*�|jj%d|j+j,�|jj-d�dS)NFr)�arg_defaultsztemporary directory %s z"does not exist or is not writable
�zsos.)�prefix�dir�version�cmdline� Z
start_timeZend_timerZrun_timeZcompression�tmpdirZtmpdir_fs_type�policyZ
components).�parser�argsr!�exit_process�archiver#�
tempfile_util�manifest�signal�SIGTERM�get_exit_handler�	Exceptionr	�
_arg_defaults�opts�load_policy�load_local_policy�updater�load_options�configure_logging�get_tmpdir_default�SoSMetadata�os�path�isdir�access�W_OK�sys�stderr�write�_exitZsys_tmp�tempfileZmkdtempr
�_setup_logging�	add_fieldr�joinrZnow�	tmpfstyper$Zdistro�add_section)�selfr%Zparsed_argsZcmdline_argsr+r#�msg�rI�/usr/lib/python3.6/component.py�__init__QsT

zSoSComponent.__init__cCs^y.ddl}|jj|jj|jd�|_|jj|_Wntk
rL|jd�YnX|jj	�|_
dS)Nr)rZ
probe_runtime)Zsos.policiesZpolicies�loadr0r�
load_prober$�KeyboardInterruptr@Zis_rootZ_is_root)rG�sosrIrIrJr2�szSoSComponent.load_local_policycCst�dS)N)�NotImplementedError)rGrIrIrJ�execute�szSoSComponent.executecs�fdd�}|S)Ncsd�_�j�dS)NT)r'r@)Zsignum�frame)rGrIrJ�exit_handler�sz3SoSComponent.get_exit_handler.<locals>.exit_handlerrI)rGrSrI)rGrJr-�szSoSComponent.get_exit_handlercCs(|r|jjd�|jj|�t|��dS)Nr)�ui_log�error�
SystemExit)rGrUrHrIrIrJr@�szSoSComponent._exitcCs�|jjrtjj|jj�}ntjdd�p(d}tjdd�r\tjdd�r\tjjtjd�|jd��}tdd|f�j	�|_
|j
d	kr�td
�tj
d�|S)z�If --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
        ZTMPDIRNz/var/tmpZHOSTZ	container�/z!stat --file-system --format=%s %sz%TZtmpfsz�WARNING: 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.�)r0rr8r9�abspath�getenvrD�lstripr�striprE�print�timeZsleep)rGr#rIrIrJr6�s

zSoSComponent.get_tmpdir_defaultcs6dd��jj�j�D�}|r2t�fdd�|D��SdS)NcSsg|]}|jd�r|�qS)�list)�
startswith)�.0�orIrIrJ�
<listcomp>�sz6SoSComponent.check_listing_options.<locals>.<listcomp>csg|]}t�j|��qSrI)�getattrr0)ra�opt)rGrIrJrc�sF)r0�dict�keys�any)rGr0rI)rGrJ�check_listing_options�sz"SoSComponent.check_listing_optionscCsdS)ziThis should be overridden by each subcommand to add its own unique
        options to the parser
        NrI)�clsr%rIrIrJ�add_parser_options�szSoSComponent.add_parser_optionsc	s�t�j|jj|j�|jdd�d�}|jdd�}x�|j�D]�\}}||jj�ks8|dgdgkr^q8|dkr�xFdD]>}t	|�t	t
||��@��rlt||�fd	d
�t
||�D��qlW||j|kr8t|||�q8W|S)
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_filter)rNr�enable_plugins�skip_plugins�only_pluginscsg|]}|�kr|�qSrIrI)ra�x)�commonrIrJrc�sz;SoSComponent.apply_options_from_cmdline.<locals>.<listcomp>)rlrmrn)rlrmrn)r	Z	from_argsr%�
parse_argsr!rf�itemsrrg�setrd�setattr)rGr0ZcmdoptsZcodictre�valZooptrI)rprJ�apply_options_from_cmdline�s
$z'SoSComponent.apply_options_from_cmdlinecCsjt|jd�}x |jjD]}|jtkrd|_qW|j|jj|jj	�d|j
ksVd|j
krf|j|jjd�tj�dkr�tj
jtj�d�}tj
j|�r�|j||jj	�|j|�}d|_t|d��rf|j|jdk�r
|jj|j�|_|j�s
tjjd	|j�|jj�|_d
|_|j�s|jj�|_|j|jj�|j|�}t|jjd��rf|jjjdk�rf|j|jjj�|S)zxCompile arguments loaded from defaults, config files, and the
        command line into a usable set of options
        )rNz--cleanz--mask�cleanrz.config/sos/sos.conf�presetzUnknown preset: '%s'
Tr) r	r/r%Z_actions�defaultrZupdate_from_confr&rZ	componentr!r8�getuidr9rDr�home�existsrvrx�hasattrr$Zfind_presetr=r>r?Zprobe_presetZlist_presets�merger0r�set_loggers_verbosity)rGr0ZoptionZuserconfrIrIrJr4�s8



zSoSComponent.load_optionscCsny4|jr|jj�|jr"|jj�|jr2t|j�Wn4tk
rh}ztd||jf�WYdd}~XnXdS)Nz6Failed to finish cleanup: %s
Contents may remain in %s)r(�cleanupr)rwr#rr.r])rG�errrIrIrJr�.s

zSoSComponent.cleanupcCsbd}tjjd�r&tjjd�|j_d}n tjjd�rFtjjd�|j_d}|jj|�|jj|�dS)NzFNo encryption environment variables set, archive will not be encryptedZ
SOSENCRYPTKEYz+Encryption key set via environment variableZSOSENCRYPTPASSz2Encryption passphrase set via environment variable)	r8�environ�getr0rr�soslog�inforT)rGrHrIrIrJ�_set_encrypt_from_env_vars<sz'SoSComponent._set_encrypt_from_env_varscCs�|jjs�d}x|d
kr$td�j�}qW|dkr<td�|j_q�|dkrRtd�|j_q�|dkrd|j�q�d|j_d|j_|jj	d�|j
jd	�n|j�dS)N�P�K�E�NzLSpecify encryption method [P]assphrase, [K]ey, [E]nv vars, [N]o encryption: zSpecify encryption passphrase: zSpecify encryption key: z@User specified --encrypt, but chose no encryption when prompted.zArchive will not be encrypted)r�r�r�r�)r0r�input�upperrrrr�r�r�rTZwarning)rGZ_encrIrIrJ�_get_encryption_methodHs 

z#SoSComponent._get_encryption_methodcCs�|jjr|j�|jjs |jjr$dnd|jj|jjd�}|sF|jj�}tjj	|j
|�}|jjdkr�|jj�}|||j
|j|jj
||j|j�|_n"t||j
|j|jj
||j|j�|_|jj|jjdk�dS)NTF)r�keyZpasswordr
rX)r0rr�rrr$Zget_archive_namer8r9rDr#rZget_preferred_archiverrr*r(rZ	set_debugr)rG�nameZenc_optsZarchive_nameZauto_archiverIrIrJ�
setup_archive`s(




zSoSComponent.setup_archivecCsb|jj�}xR|jD]H}xBt|�j|�D]0}tjj||�}xdD]}|jj||d�q>Wq&WqWdS)N�(--upload-pass[\s=]+)\S+�$(--upload-url[\s=]+\S+://.*:)([^@]*)�!(--upload-s3-secret-key[\s=]+)\S+z
\1********)r�r�r�)	r(Zget_archive_path�files_with_upload_passwdrZglobr8r9�relpathZdo_file_sub)rGZ	_arc_pathr9�f�rerIrIrJ�_obfuscate_upload_passwords{s
z(SoSComponent._obfuscate_upload_passwordscCsJtjtj�}|jtjd��|j|jjdkr2tj	ntj
�|jj|�dS)Nz%(message)sr)
�logging�
StreamHandlerr=�stdout�setFormatter�	Formatter�setLevelr0r�DEBUG�INFOrT�
addHandler)rGZ
ui_consolerIrIrJ�add_ui_log_to_stdout�s
z!SoSComponent.add_ui_log_to_stdoutcCs\t|dd�r|r|jjtj�t|dd�rX|rJ|jjdkrJ|jjtj�n|jjtj�dS)N�flog�consoler)	rdr�r�r�r�r0rr�ZWARNING)rGrrIrIrJr�sz"SoSComponent.set_loggers_verbositycCshtjd�|_|jjtj�d|_|j�sn|j�|_tj	|j�|_|jj
tjd��|jjtj�|jj
|j�|jjs�tj	tj�|_|jj
tjd��|j|jj�|jj
|j�n4tj	tj�}|j
tjd��|jtj�|jj
|�tjd�|_|jj|jjdk�rtjntj�|j��sR|j�|_tj	|j�}|j
tjd��|jj
|�|jj�sd|j�dS)z�Creates 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.
        rONz&%(asctime)s %(levelname)s: %(message)sz%(message)sZsos_uir)r�Z	getLoggerr�r�r�r�ri�
get_temp_fileZsos_log_filer�r�r�r�r�r0rr=r�r�rrr>ZERRORrTZsos_ui_log_filer�)rGZconsole_errZui_fhandlerrIrIrJrB�s<




zSoSComponent._setup_loggingcCs
|jj�S)N)r)�new)rGrIrIrJr��szSoSComponent.get_temp_file)rN)r) �__name__�
__module__�__qualname__�__doc__Zdescrr5r1rMZ
root_requiredr/r�rKr2rQr-r@r6ri�classmethodrkrvr4r�r�r�r�r�r�rrBr�rIrIrIrJrsV8

/3
	.rc@sVeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	gfdd�Z
ddd�ZdS)r7a8This 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
    cCs
i|_dS)N)�_values)rGrIrIrJrK�szSoSMetadata.__init__ccs"x|jj�D]}|dVqWdS)Nr)r�rr)rG�itemrIrIrJ�__iter__�szSoSMetadata.__iter__cCs
|j|S)N)r�)rGr�rIrIrJ�__getitem__�szSoSMetadata.__getitem__cCs,y
|j|Stk
r&t|��YnXdS)N)r�r.�AttributeError)rG�attrrIrIrJ�__getattr__�s
zSoSMetadata.__getattr__cCs||j|<dS)z@Add a key, value entry to the current metadata instance
        N)r�)rGZ
field_name�contentrIrIrJrC�szSoSMetadata.add_fieldcCst�|j|<|j|S)zCAdds a new instance of SoSMetadata to the current instance
        )r7r�)rGZsection_namerIrIrJrF�szSoSMetadata.add_sectioncCs t|t�std��||j|<dS)z�Add 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�)rGZ	list_namer�rIrIrJ�add_list�s
zSoSMetadata.add_listNcCstj|dd�|d�S)z�Convert 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.
        cSst|dt|��S)Nr�)rd�str)rbrIrIrJ�<lambda>sz&SoSMetadata.get_json.<locals>.<lambda>)ry�indent)�json�dumps)rGr�rIrIrJ�get_json�szSoSMetadata.get_json)N)r�r�r�r�rKr�r�r�rCrFr�r�rIrIrIrJr7�sr7)r�r�r8rAr=r^�argparserrrZshutilrZpathlibrrOrZsos.archiverZsos.optionsr	Z
sos.utilitiesr
rrr7rIrIrIrJ�<module>s&4

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 5.04 KB 0644
__init__.cpython-36.pyc File 5.04 KB 0644
archive.cpython-36.opt-1.pyc File 22.42 KB 0644
archive.cpython-36.pyc File 22.42 KB 0644
component.cpython-36.opt-1.pyc File 14.84 KB 0644
component.cpython-36.pyc File 14.84 KB 0644
missing.cpython-36.opt-1.pyc File 2.68 KB 0644
missing.cpython-36.pyc File 2.68 KB 0644
options.cpython-36.opt-1.pyc File 11.79 KB 0644
options.cpython-36.pyc File 11.79 KB 0644
utilities.cpython-36.opt-1.pyc File 18.3 KB 0644
utilities.cpython-36.pyc File 18.3 KB 0644