%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/sos/policies/distros/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/sos/policies/distros/__pycache__/__init__.cpython-312.pyc

�

i��d�z����ddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZmZmZmZ	ddlZdZd
ZdZGd�de�ZGd�de�Zy#e$rdZY�$wxYw)�N)�getpass)�_sos)�Policy)�
InitSystem)�SystemdInit)�CrioContainerRuntime)�PodmanContainerRuntime)�DockerContainerRuntime)�	shell_out�
is_executable�bold�sos_get_command_outputTF�	container�HOSTc���eZdZdZdZdZdZdZdZdZ	dZ
dZdZdZ
dZdZdZdZdZdZdZdZd	Zd
ZdZdZ		d0�fd�	Zed��Zd
�Zd�Zd�Zd�Z d�Z!d�Z"ed��Z#ed��Z$ed��Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d1d�Z/d �Z0d!�Z1d"�Z2d#�Z3d1d$�Z4d%�Z5d2d&�Z6d'�Z7d2d(�Z8d)�Z9d3d*�Z:d+�Z;d,�Z<d4d-�Z=d.�Z>d/�Z?�xZ@S)5�LinuxPolicyzfThis policy is meant to be an abc class that provides common
    implementations used in Linux distros�Linux�Nonez/bin:/sbin:/usr/bin:/usr/sbinN�/�dockerFz/usr/binzsos-collector-tmpc���tt|�|||��|r||_n|j	�xsd|_|j�|�||_nJtjjd�rt|j��|_nt�|_i|_|j�r't|��t|��t!|��g}|D]�}|j#�s�||j|j$<|j$|j&k(r&|j|j$|jd<|j|j$j)���|jr`d|jj+�vrCt-|jj+��}|j|d|jd<yyyy)N)�sysroot�
probe_runtime�remote_execrz/run/systemd/system/)�chroot)�policy�defaultr)�superr�__init__r�_container_init�init_kernel_modules�init_system�os�path�isdirrr�runtimesrr	r
r�check_is_active�name�default_container_runtime�load_container_info�keys�list)	�selfr�initrr�_crun�runtime�idx�	__class__s	        ��?/usr/lib/python3/dist-packages/sos/policies/distros/__init__.pyrzLinuxPolicy.__init__Is����
�k�4�)�'�8E�6A�	*�	C��"�D�L��/�/�1�8�S�D�L�� � �"���#�D��
�W�W�]�]�1�
2�*�$�,�,�?�D��)�|�D����
����&�d�3�&�d�3�$�D�1��E�
!�
F���*�*�,�29�D�M�M�'�,�,�/��|�|�t�'E�'E�E�37�=�=����3N��
�
�i�0��M�M�'�,�,�/�C�C�E�
F��}�}��$�-�-�2D�2D�2F�!F��4�=�=�-�-�/�0��+/�=�=��Q��+@��
�
�i�(�	"G�}��c�
�ddgS)Nz/etc/passwdz/etc/shadow�)�clss r3�set_forbidden_pathszLinuxPolicy.set_forbidden_pathsqs��
��
�	
r4c��|jS�N)�release�r-s r3�kernel_versionzLinuxPolicy.kernel_versionx����|�|�r4c��|jSr:)�hostnamer<s r3�	host_namezLinuxPolicy.host_name{s���}�}�r4c��|jSr:)�smpr<s r3�
is_kernel_smpzLinuxPolicy.is_kernel_smp~s���x�x�r4c��|jSr:)�machiner<s r3�get_archzLinuxPolicy.get_arch�r>r4c�"�|j�S)z)Returns the name usd in the pre_work step)rAr<s r3�get_local_namezLinuxPolicy.get_local_name�s���~�~��r4c�0�tjdd|�S)Nz[^-a-z,A-Z.0-9]�)�re�sub)r-r(s  r3�sanitize_filenamezLinuxPolicy.sanitize_filename�s���v�v�(�"�d�3�3r4c��|tk(r|j|�y|jd|jz�|j	|�y)Nz%s Distribution Policy)r�display_self_help�	set_title�distro�display_distro_help�r7�sections  r3�display_helpzLinuxPolicy.display_help�s>���+���!�!�'�*����6����C�D��#�#�G�,r4c�H�|jd�|jd�y)NzSoS Distribution Policiesz�Distributions supported by SoS will each have a specific policy defined for them, to ensure proper operation of SoS on those systems.)rQ�add_textrTs  r3rPzLinuxPolicy.display_self_help�s$�����5�6����
�	
r4c
��|jr8|jtjur|j|j�n|jd�|ddd�}|jd|jz�|jd|jzd��|jd|j
zd��|j
d�}|jD],}|jdjd	|d
|d�d���.|j
d�}|jtd
jd	ddd��d��|jD]i}|j|}d	j|jj��}|jd
jd	||j|�d���ky)Nz;
Detailed help information for this policy is not availableFzDefault --upload location: %szDefault container runtime: %s)�newlinez"$PATH used when running report: %szReference URLsz{:>8}{:<30}{:<40}� r�z#Presets Available With This Policy
z{:>8}{:<20}{:<45}{:<30}zPreset Name�DescriptionzEnabled Options)�__doc__rrX�_upload_urlr)�PATH�add_section�vendor_urls�formatr
�presets�join�opts�to_args�desc)	r7rU�_pol�refsec�url�presec�preset�_preset�_optss	         r3rSzLinuxPolicy.display_distro_help�s����;�;�3�;�;�k�.A�.A�A����S�[�[�)����N�
��4��u�%�����+�d�.>�.>�>�	
�	���+�d�.L�.L�L��	�	
�	���0�4�9�9�<��	�	
�
�$�$�%5�6���?�?�	�C��O�O�#�*�*�3��A���A��?��
�
�	��$�$�%K�L������)�0�0��m�1>�1B�D�
�
�
	�	
��l�l�	�F��l�l�6�*�G��H�H�W�\�\�1�1�3�4�E��O�O�)�0�0������u���	
�
�	r4c��ttjvr�tjtdvr�d|_ttjvrutjtsytj
j
tjt|jz�|_tjtSy)z�Check if sos is running in a container and perform container
        specific initialisation based on ENV_HOST_SYSROOT.
        )r�oci�podmanTN)�
ENV_CONTAINERr#�environ�
_in_container�ENV_HOST_SYSROOTr$�abspath�_tmp_dirr<s r3r zLinuxPolicy._container_init�s����B�J�J�&��z�z�-�(�,G�G�%)��"�#�r�z�z�1��:�:�&6�7�#�$&�G�G�O�O��
�
�#3�4�t�}�}�D�%�D�M��:�:�&6�7�7�r4c��g|_tj�j}t	dd|j
��j
�}|jj|ddD�cgc]#}|j�dj���%c}�|jd|z�}	t|d�5}|D]C}|jd�d	jd
�d}|jj|��E	ddd�ddd
�}|jd|z�}g}		t|d�5}
|
D]*}d|vs�|	j|jd�d��,	ddd�|D]%}|||	vs�|jj|��'ycc}w#1swY��xYw#t$rY��wxYw#1swY�TxYw#t$rY�bwxYw)zxObtain a list of loaded kernel modules to reference later for plugin
        enablement and SoSPredicate checks
        �lsmodr)�timeoutrr\Nz#/usr/lib/modules/%s/modules.builtin�rr���z.ko�CONFIG_NET_DEVLINK�CONFIG_BLK_DEV_DM)�devlink�dm_modz/boot/config-%sz=y)�kernel_modsr#�unamer;rr�
splitlines�extend�split�strip�join_sysroot�open�append�IOError)r-r;�lines�line�builtins�mfile�kmod�config_strings�
booted_config�kconfigs�kfile�builtins            r3r!zLinuxPolicy.init_kernel_modules�s�������(�(�*�$�$���'�1�T�\�\�B�M�M�O�������05�a�b�	�!
�(,�D�J�J�L��O�!�!�#�!
�	�
�$�$�1�G�;�
��	��h��$�
2��!�2�D��:�:�c�?�2�.�4�4�U�;�A�>�D��$�$�+�+�D�1�2�
2�,�)�
��
�)�)�*;�g�*E�F�
���	��m�S�)�
=�U�!�=�D��t�|� ����
�
�4�(8��(;�<�=�
=�&�	1�G��g�&�(�2�� � �'�'��0�	1��E!
�
2�
2���	��	��
=�
=���	��	�sa�((F�,F'�8A	F�F'�&G�2
F6�=%F6�#G�F$� F'�'	F3�2F3�6F?�;G�	G�
Gc��|jrH|jdk7r9tjj|j|j	d��}|S)Nr)rr#r$re�lstrip)r-r$s  r3r�zLinuxPolicy.join_sysroots:���<�<�D�L�L�C�/��7�7�<�<����d�k�k�#�.>�?�D��r4c�*�|jd}|jr|jnd}|jr|j�|j|_|j
|_|j|_|j|_d|_	|jsM|jsA	|r||jd_n)ttd�|z�|jd_|jr|j|_|jse|jsY	|jr0|j!�r |j#�|j%�|j&j)d�yy#t$r�wxYw#t$r�wxYw)N�cmdlineoptsrKzSOptionally, please enter the case id that you are generating this report for [%s]: )�commons�case_id�low_priority�_configure_low_priority�
upload_url�upload_user�upload_directory�upload_pass�upload_password�upload_archive_name�batch�quiet�input�_�KeyboardInterrupt�upload�get_upload_url�prompt_for_upload_user�prompt_for_upload_password�ui_log�info)r-�cmdline_opts�caseids   r3�pre_workzLinuxPolicy.pre_worksq���|�|�M�2��)5�)=�)=��%�%�2���$�$��(�(�*�
'�1�1���'�3�3��� ,� =� =���+�7�7���#%�� ��!�!��"�"�	
��:@�D�L�L��/�7�:?��>�?�AG�H�;�D�L�L��/�7����'�/�/�D�L��!�!��"�"�
��&�&�4�+>�+>�+@��/�/�1��3�3�5���� � ��$�	��%%�
��
��%�
��
�s�*AE9� AF�9F�Fc��tj�}td�r_td|��d��}|ddk(r|jjd�nFd|d	�d
|d�d�}|jj
|�n|jjd�	tjd
�|jjd�y#t$r(}|jj
d|���Yd}~yd}~wwxYw)ayUsed to constrain sos to a 'low priority' execution, potentially
        letting individual policies set their own definition of what that is.

        By default, this will attempt to assign sos to an idle io class via
        ionice if available. We will also renice our own pid to 19 in order to
        not cause competition with other host processes for CPU time.
        �ionicezionice -c3 -p ��r{�statusrzSet IO class to idlez Error setting IO class to idle: �outputz (exit code �)zNWarning: unable to constrain report to idle IO class: ionice is not available.�zSet niceness of report to 19z%Error setting report niceness to 19: N)r#�getpidrr�soslogr��errorr��warning�nice�	Exception)r-�_pid�ret�msg�errs     r3r�z#LinuxPolicy._configure_low_priorityDs����y�y�{����"�(� ���'���C��8�}��!���� � �!7�8�9�#�h�-��I%�%(��]�O�1�6�����!�!�#�&��K�K���+�
�
	M��G�G�B�K��K�K���;�<���	M��K�K��� E�c�U�K�L�L��	M�s�0C�	C=�C8�8C=c�~�|j�s-d|j�z}tt|��|_yy)zdShould be overridden by policies to determine if a user needs to
        be provided or not
        z#Please provide upload user for %s: N)�get_upload_userr�r�r�r��r-r�s  r3r�z"LinuxPolicy.prompt_for_upload_usercs8���#�#�%�7�$�:M�:M�:O�O�C�$�Q�s�V�}�D��&r4c��|j�sB|j�|jk7r$d|j�z}t|�|_yyy)zsShould be overridden by policies to determine if a password needs to
        be provided for upload or not
        z+Please provide the upload password for %s: N)�get_upload_passwordr��_upload_userrr�r�s  r3r�z&LinuxPolicy.prompt_for_upload_passwordksU���'�'�)�t�/C�/C�/E�/3�/@�/@�0A�@��)�)�+�,�C�#*�3�<�D� �	0A�)r4c��||_|js|j�|_|jstd��|j	�}|j
j
td|j�����|�S)a

        Entry point for sos attempts to upload the generated archive to a
        policy or user specified location.

        Curerntly there is support for HTTPS, SFTP, and FTP. HTTPS uploads are
        preferred for policy-defined defaults.

        Policies that need to override uploading methods should override the
        respective upload_https(), upload_sftp(), and/or upload_ftp() methods
        and should NOT override this method.

        :param archive: The archive filepath to use for upload
        :type archive: ``str``

        In order to enable this for a policy, that policy needs to implement
        the following:

        Required Class Attrs

        :_upload_url:     The default location to use. Note these MUST include
                          protocol header
        :_upload_user:    Default username, if any else None
        :_upload_password: Default password, if any else None

        The following Class Attrs may optionally be overidden by the Policy

        :_upload_directory:     Default FTP server directory, if any


        The following methods may be overridden by ``Policy`` as needed

        `prompt_for_upload_user()`
            Determines if sos should prompt for a username or not.

        `get_upload_user()`
            Determines if the default or a different username should be used

        `get_upload_https_auth()`
            Format authentication data for HTTPS uploads

        `get_upload_url_string()`
            Print a more human-friendly string than vendor URLs
        z;No upload destination provided by policy or by --upload-urlzAttempting upload to )	r�r�r�r��_determine_upload_typer�r�r��get_upload_url_string)r-�archive�upload_funcs   r3�upload_archivezLinuxPolicy.upload_archiveus���X$+�� ����"�1�1�3�D�O�����+�,�
,��1�1�3�������
�%�d�&@�&@�&B�%C�D�E�	
��}�r4c��|j|j|jd�}|jdj|j�vr||jdjSd|jvrtd��|jjd�\}}||j�vrtd|z��||S)aBased on the url provided, determine what type of upload to attempt.

        Note that this requires users to provide a FQDN address, such as
        https://myvendor.com/api or ftp://myvendor.com instead of
        myvendor.com/api or myvendor.com
        )�ftp�sftp�httpsr�z://z#Must provide protocol in upload URLz(Unsupported or unrecognized protocol: %s)	�
upload_ftp�upload_sftp�upload_httpsr��upload_protocolr+r�r�r�)r-�prots�protrks    r3r�z"LinuxPolicy._determine_upload_type�s����?�?��$�$��&�&�
��
�<�<�
�&�6�6�%�*�*�,�F�����m�4�D�D�E�E�
�$�/�/�
)��A�B�B��O�O�)�)�%�0�	��c��u�z�z�|�#��F��M�N�N��T�{�r4c��|s|j�}|s|j�}tjj	||�S)agFormats the user/password credentials using basic auth

        :param user: The username for upload
        :type user: ``str``

        :param password: Password for `user` to use for upload
        :type password: ``str``

        :returns: The user/password auth suitable for use in reqests calls
        :rtype: ``requests.auth.HTTPBasicAuth()``
        )r�r��requests�auth�
HTTPBasicAuth)r-�user�passwords   r3�get_upload_https_authz!LinuxPolicy.get_upload_https_auth�s=����'�'�)�D���/�/�1�H��}�}�*�*�4��:�:r4c�6�|jxs|jS)z�Helper function to determine if we should use the policy default
        upload url or one provided by the user

        :returns: The URL to use for upload
        :rtype: ``str``
        )r�r_r<s r3r�zLinuxPolicy.get_upload_url�s�����2�$�"2�"2�2r4c�"�|j�S)z�Used by distro policies to potentially change the string used to
        report upload location from the URL to a more human-friendly string
        )r�r<s r3r�z!LinuxPolicy.get_upload_url_string�s���"�"�$�$r4c�f�tjdd�xs|jxs|jS)z�Helper function to determine if we should use the policy default
        upload user or one provided by the user

        :returns: The username to use for upload
        :rtype: ``str``
        �
SOSUPLOADUSERN)r#�getenvr�r�r<s r3r�zLinuxPolicy.get_upload_user�s3���	�	�/�4�0�"�� � �"��!�!�	#r4c�f�tjdd�xs|jxs|jS)a_Helper function to determine if we should use the policy default
        upload password or one provided by the user

        A user provided password, either via option or the 'SOSUPLOADPASSWORD'
        environment variable will have precendent over any policy value

        :returns: The password to use for upload
        :rtype: ``str``
        �SOSUPLOADPASSWORDN)r#r�r��_upload_passwordr<s r3r�zLinuxPolicy.get_upload_password�s4���	�	�-�t�4�&��$�$�&��%�%�	'r4c�,�td�std��	ddl}d}|s|j	�}|s|j�}|j
�jdd�}d	|�d
|��}|j|d��}d
dd|j|jg}|j|d��}	|	dk(rd}n�|	dk(ro|j|�d
d|j|jg}
|j|
d��dk(}|s�|j�td|j�z��|	dk(rtd|j�z��|	dk(rtd|j�z��|	dk(rtd|jz��|s,|j�td|j�z��d|j �d|j#���}|j|�d |j|jd!g}|j|d"��}
|
dk(r|jd#�y|
dk(rtd$��|
dk(rtd%|jz��|
dk(rtd&��td'|jz��#t$rtd��wxYw)(a�Attempts to upload the archive to an SFTP location.

        Due to the lack of well maintained, secure, and generally widespread
        python libraries for SFTP, sos will shell-out to the system's local ssh
        installation in order to handle these uploads.

        Do not override this method with one that uses python-paramiko, as the
        upstream sos team will reject any PR that includes that dependency.
        r�zSFTP is not locally supportedrNzFSFTP upload requires python3-pexpect, which is not currently installedFzsftp://rKz sftp -oStrictHostKeyChecking=no �@zutf-8)�encodingzsftp>z	password:zConnection refused�r�Tr\zPermission denied�
z%Incorrect username or password for %s�z)Connection refused by %s. Incorrect port?�z#Timeout hit trying to connect to %s�z.Unexpected error trying to connect to sftp: %sz Unable to connect via SFTP to %szput r[z100%zNo such file or directory��byezTimeout expired while uploadingzUnknown error during upload: %sz&Unable to write archive to destinationz#Unexpected response from server: %s)rr��pexpect�ImportErrorr�r�r��replace�spawn�TIMEOUT�EOF�expect�sendline�closer��beforer��_get_sftp_upload_name)r-r�r�r��sftp_connected�sftp_url�sftp_cmdr��sftp_expectsr1�pass_expects�put_cmd�put_expects�put_successs              r3r�zLinuxPolicy.upload_sftp�s����V�$��;�<�<�
	7��
����'�'�)�D���/�/�1�H��&�&�(�0�0��B�?��>B�H�M���m�m�H�w�m�7��
��!��O�O��K�K�
���j�j��r�j�2���!�8�!�N�
�A�X��L�L��"��$�������	�L�!�Z�Z��b�Z�A�Q�F�N�!��	�	��� G�"&�"<�"<�">�!?�@�@�
�A�X��G�"�8�8�:�;�<�
<�
�A�X��A�"�8�8�:�;�<�
<�
�A�X��L�!�j�j�)�*�
*���I�I�K��>�"�8�8�:�;�<�
<��
"&�!9�!9�!%�!;�!;�!=�?�����W��
��O�O��K�K�(�	
���j�j��c�j�:���!���L�L����
�A�
��=�>�>�
�A�
��=��
�
�J�K�K�
�A�
��D�E�E��A�C�J�J�N�O�O��_�	7��6�7�
7�	7�s�I>�>Jc��|jjd�d}|jr*tjj|j|�}|S)aIf a specific file name pattern is required by the SFTP server,
        override this method in the relevant Policy. Otherwise the archive's
        name on disk will be used

        :returns:       Filename as it will exist on the SFTP server
        :rtype:         ``str``
        rr})r�r�r�r#r$re)r-�fnames  r3r�z!LinuxPolicy._get_sftp_upload_nameasG���(�(�.�.�s�3�B�7��� � ��G�G�L�L��!6�!6��>�E��r4c�l�tj|j�||j�|��S)z�If upload_https() needs to use requests.put(), use this method.

        Policies should override this method instead of the base upload_https()

        :param archive:     The open archive file object
        )�datar��verify)r��putr�r�)r-r�r
s   r3�_upload_https_putzLinuxPolicy._upload_https_putns1���|�|�D�/�/�1��!%�!;�!;�!=�#)�+�	+r4c��iS)zJDefine any needed headers to be passed with the POST request here
        r6r<s r3�_get_upload_headerszLinuxPolicy._get_upload_headersys	���	r4c���d|jjd�d||j�fi}tj|j�||j
�|��S)z�If upload_https() needs to use requests.post(), use this method.

        Policies should override this method instead of the base upload_https()

        :param archive:     The open archive file object
        �filerr})�filesr�r
)r(r�rr��postr�r�)r-r�r
rs    r3�_upload_https_postzLinuxPolicy._upload_https_post~sf��
�W�\�\�'�'��,�R�0�'��-�-�/�1�
���}�}�T�0�0�2�%�"&�"<�"<�">�$*�,�	,r4c�F�tstd��t|jd�5}|jdj
dk(r
|j}n|jdj
}|jdjdu}|dk(r|j||�}n|j||�}|jdk7rN|jdk7r?|jd	k(rtd
��td|j�d|j����	d
d
d
�y#1swYy
xYw)z�Attempts to upload the archive to an HTTPS location.

        :returns: ``True`` if upload is successful
        :rtype: ``bool``

        :raises: ``Exception`` if upload was unsuccessful
        z7Unable to upload due to missing python requests library�rbr��autoFr����i�z/Authentication failed: invalid user credentialszPOST request returned z: NT)�REQUESTS_LOADEDr�r�r�r��
upload_method�_upload_method�upload_no_ssl_verifyrr�status_code�reason)r-�arc�methodr
r|s     r3r�zLinuxPolicy.upload_https�s����&�'�
'��$�*�*�D�
1�	�S��|�|�M�*�8�8�F�B��,�,�����m�4�B�B���\�\�-�0�E�E��N�F�����*�*�3��7���+�+�C��8���}�}��#��
�
��(<��=�=�C�'�#�I��� �#$�=�=�!�(�(�!<�=�=��#	�	�	�s�C&D�D c��	ddl}ddl}|s|j	�}|�td��|jdd�}|s|j
�}|s|j�}|s|jxs|j}	|j|||d��}|std	��|j|�	t#|j$d�5}
|j'd|j$j!d�dz|
�ddd�|j)�y#t$rtd��wxYw#|j$rtd
|z��|j$rtd|z��|j$rq}t|�j!�d}	|	dk(rtd
|z��|	dk(rtd|z��|	dk(rtd|z��tdt|�z��d}~wwxYw#1swY��xYw#t*$rtd��wxYw)aTAttempts to upload the archive to either the policy defined or user
        provided FTP location.

        :param url: The URL to upload to
        :type url: ``str``

        :param directory: The directory on the FTP server to write to
        :type directory: ``str`` or ``None``

        :param user: The user to authenticate with
        :type user: ``str``

        :param password: The password to use for `user`
        :type password: ``str``

        :returns: ``True`` if upload is successful
        :rtype: ``bool``

        :raises: ``Exception`` if upload in unsuccessful
        rNzmissing python ftplib libraryzIno FTP server specified by policy, use --upload-url to specify a locationzftp://rKr�r�z3connection failed, did you set a user and password?z"timeout hit while connecting to %szunable to connect to %s�503zcould not login as '%s'�530zinvalid password for user '%s'�550z$could not set upload directory to %sz%error trying to establish session: %srzSTOR %srr}Tzcould not open archive file)�ftplib�socketr�r�r�r�r�r�r��_upload_directory�FTP�cwdr{�gaierror�
error_perm�strr�r�r��
storbinary�quitr�)r-rk�	directoryr�r�r%r&�sessionr��errno�_arcfiles           r3r�zLinuxPolicy.upload_ftp�s7��*	=�����%�%�'�C��;��8�9�
9��k�k�(�B�'����'�'�)�D���/�/�1�H���-�-�G��1G�1G�I�	(��j�j��d�H�b�j�A�G���!,�-�-��K�K�	�"�"		;��d�.�.��5�
���"�"��� 8� 8� >� >�s� C�B� G�G���
�

�L�L�N���g�	=��;�<�<�	=��8�~�~�	H��@�3�F�G�G����	=��5��;�<�<�� � �
	(���H�N�N�$�Q�'�E���~�� 9�D� @�A�A���~�� @�4� G�H�H���~�� F�"+�!,�-�-��C�!�#�h�'�(�
(��
	(��
�
���	;��9�:�:�	;�sI�D�<3D)�0G0�2G$�8G0�D&�)AG!�0A,G�G!�$G-�)G0�0Hc��y)z�If sosreport commands need to always be prefixed with something,
        for example running in a specific container image, then it should be
        defined here.

        If no prefix should be set, return an empty string instead of None.
        rKr6r<s r3�set_sos_prefixzLinuxPolicy.set_sos_prefix�s��r4c��y)zcIf a host requires additional cleanup, the command should be set and
        returned here
        rKr6r<s r3�set_cleanup_cmdzLinuxPolicy.set_cleanup_cmds��r4c��y)aIReturns the command that will create the container that will be
        used for running commands inside a container on hosts that require it.

        This will use the container runtime defined for the host type to
        launch a container. From there, we use the defined runtime to exec into
        the container's namespace.

        :param image:   The name of the image if not using the policy default
        :type image:    ``str`` or ``None``

        :param auth:    The auth string required by the runtime to pull an
                        image from the registry
        :type auth:     ``str`` or ``None``

        :param force_pull:  Should the runtime forcibly pull the image
        :type force_pull:   ``bool``

        :returns:   The command to execute to launch the temp container
        :rtype:     ``str``
        rKr6)r-�imager��
force_pulls    r3�create_sos_containerz LinuxPolicy.create_sos_container
s��*r4c�8�|j�d|j��S)a�Restarts the container created for sos collect if it has stopped.

        This is called immediately after create_sos_container() as the command
        to create the container will exit and the container will stop. For
        current container runtimes, subsequently starting the container will
        default to opening a bash shell in the container to keep it running,
        thus allowing us to exec into it again.
        z start ��container_runtime�sos_container_namer<s r3�restart_sos_containerz!LinuxPolicy.restart_sos_container!s ��!%� 6� 6� $� 7� 7�9�	9r4c�Z�|jr|j�d|j�d|��S|S)aReturns the command that allows us to exec into the created
        container for sos collect.

        :param cmd: The command to run in the sos container
        :type cmd: ``str``

        :returns: The command to execute to run `cmd` in the container
        :rtype: ``str``
        z exec r[r<)r-�cmds  r3�format_container_commandz$LinuxPolicy.format_container_command-s3���!�!�&*�&<�&<�&*�&=�&=�&)�+�
+��Jr4)NNTN)NN)T)NNNN)NNF)A�__name__�
__module__�__qualname__r^rR�vendorr`r.r_r'r�r�rr)�_preferred_hash_namer�r�r��
containerized�container_image�sos_path_strip�sos_pkg_name�sos_bin_pathr>�container_version_command�container_authfiler�classmethodr8r=rArDrGrIrNrVrPrSr r!r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�r�r4r6r:r?rB�
__classcell__)r2s@r3rr's����-��F�
�F�*�D��D��K����L����N� (�����J��K��O��M��O��N��L��L�,�� $����>B�!�&A�P�
��
����� �4��-��-��
��
��/��/�b�"-1�^�
/�bM�>-�0�6�p�*;�&3�%�	#�'�bP�H�	+��

,��>M;�^���.
9�r4rc��eZdZdZdgZdZdZy)�GenericLinuxPolicyz�This Policy will be returned if no other policy can be loaded. This
    should allow for IndependentPlugins to be executed on any system)zUpstream Projectz https://github.com/sosreport/sos�SoSaSoS was unable to determine that the distribution of this system is supported, and has loaded a generic configuration. This may not provide desired behavior, and users are encouraged to request a new distribution-specifc policy at the GitHub project above.
N)rCrDrEr^rbrF�vendor_textr6r4r3rRrR?s��H�L�L�K�
�F�<�Kr4rR)r#rLr�sosrr��sos.policiesr�sos.policies.init_systemsr�!sos.policies.init_systems.systemdr�sos.policies.runtimes.crior�sos.policies.runtimes.podmanr	�sos.policies.runtimes.dockerr
�
sos.utilitiesrrr
rr�rr�rsrvrrRr6r4r3�<module>r]s{��
�	����0�9�;�?�?�3�3����O�
�
���U�&�U�p
=��
=��A���O��s�A'�'A1�0A1

Zerion Mini Shell 1.0