Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/sos/policies/distros/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/sos/policies/distros/__pycache__/redhat.cpython-310.pyc
o

i��d�_�@sDddlZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZmZddlmZmZddlmZddlmZddlmZzddlZdZWney[d	ZYnwd
ZdZdZ Gd
d�de�Z!dZ"dZ#dZ$Gdd�de!�Z%Gdd�de%�Z&Gdd�de%�Z'Gdd�de%�Z(Gdd�de'�Z)Gdd�de!�Z*dS)�N)�RedHatPlugin)
�RHEL_PRESETS�ATOMIC_PRESETS�RHV�RHEL�CB�RHOSP�RHOCP�RH_CFME�RH_SATELLITE�ATOMIC)�LinuxPolicy�ENV_HOST_SYSROOT)�RpmPackageManager)�bold)�_sosTFz/etc/os-releasezRed Hat Enterprise Linux�Atomiccs�eZdZdZdZddgZdZdZdZdZ	dZ
dZd	Zd
Z
dZ		d�fd
d�	Zeddd��Ze�fdd��Zdd�Zdd�Zdd�Z�ZS)�RedHatPolicy�Red Hat)zDistribution Websitezhttps://www.redhat.com/)zCommercial Supportzhttps://access.redhat.com/z/var/tmpFz/opt/rh�friendlyN�podman�sosz	/usr/sbinTcs�tt|�j||||d�d|_t|j|d�|_|jtg7_|jj	|_
|j
s2tj�
d�t�d�|�|j
�|_|jr@d|_nd|_|jtjd7_|jtjd	7_|js^|��|��dS)
N��sysroot�init�
probe_runtime�remote_execF)�chrootrz'Could not obtain installed package list�z/usr/sbin:/usr/bin:/root/binz'/sbin:/bin:/usr/sbin:/usr/bin:/root/binz/usr/local/binz/usr/local/sbin)�superr�__init__�usrmoverr�package_manager�valid_subclassesr�packages�pkgs�sys�stderr�write�exit�
check_usrmove�PATH�os�pathsepr�
set_exec_path�load_presets��selfrrrr��	__class__��=/usr/lib/python3/dist-packages/sos/policies/distros/redhat.pyr 5s,��

zRedHatPolicy.__init__�cC�dS)a�This method checks to see if we are running on Red Hat. It must be
        overriden by concrete subclasses to return True when running on a
        Fedora, RHEL or other Red Hat distribution or False otherwise.

        If `remote` is provided, it should be the contents of a remote host's
        os-release, or comparable, file to be used in place of the locally
        available one.
        Fr4��cls�remoter4r4r5�checkTs
zRedHatPolicy.checkcsl|turtt|��|�dS|�d�ttttd�}|D]}td|�}|jd�	d|||j
�dd�qdS)Nz�This policy is a building block for all other Red Hat family distributions. You are likely looking for one of the distributions listed below.
)�centos�rhel�redhatcoreos�fedorazpolicies.%sz{:>8}{:<35}{:<30}� F)�newline)rr�display_distro_help�add_text�CentOsPolicy�
RHELPolicy�RedHatCoreOSPolicy�FedoraPolicyr�format�distro)r9�section�subs�subc�sublnr2r4r5rB`s$����z RedHatPolicy.display_distro_helpcCs@d|vrtj�d�otj�d�S|dd}|ddkrdSdS)	aqTest whether the running system implements UsrMove.

            If the 'filesystem' package is present, it will check that the
            version is greater than 3. If the package is not present the
            '/bin' and '/sbin' paths are checked and UsrMove is assumed
            if both are symbolic links.

            :param pkgs: a packages dictionary
        �
filesystemz/binz/sbin�versionr�3TF)r,�path�islink)r1r%�filesys_versionr4r4r5r*ys
zRedHatPolicy.check_usrmovecCs2g}dd�}|jr|D]	}|�||��q|S|S)a2Mangle paths for post-UsrMove systems.

            If the system implements UsrMove, all files will be in
            '/usr/[s]bin'. This method substitutes all the /[s]bin
            references in the 'files' list with '/usr/[s]bin'.

            :param files: the list of package managed files
        cSs:ddg}||vr|tj�d|dd��fSt�dd|�fS)Nz/bin/rpmz
/bin/mailxz/usrrz(^)(/s?bin)z\1/usr\2)r,rQ�join�re�sub)rQ�
skip_pathsr4r4r5�transform_path�sz8RedHatPolicy.mangle_package_path.<locals>.transform_path)r!�extend)r1�files�pathsrX�fr4r4r5�mangle_package_path�s	z RedHatPolicy.mangle_package_pathcCs|s|jS|S�N)�_tmp_dir)r1�opt_tmp_dirr4r4r5�get_tmp_dir�szRedHatPolicy.get_tmp_dir�NNTN�r6)�__name__�
__module__�__qualname__rI�vendor�vendor_urlsr_�
_in_container�default_scl_prefix�name_pattern�
upload_url�upload_user�default_container_runtime�sos_pkg_name�sos_bin_pathr �classmethodr;rBr*r]ra�
__classcell__r4r4r2r5r$s2��ra[
Any information provided to %(vendor)s will be treated in accordance with the published support policies at:

  %(vendor_urls)s

The generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party.

No changes will be made to system configuration.
zhttps://api.access.redhat.comzsftp://sftp.access.redhat.comcs�eZdZdZeZdZeded�Z	e
ZdZ		d�fdd	�	Z
ed dd��Z�fd
d�Zdd�Zdd�Zdd�Zdd�Z�fdd�Z�fdd�Zdd�Zdd�Z�ZS)!rEat
    The RHEL policy is used specifically for Red Hat Enterprise Linux, of
    any release, and not forks or derivative distributions. For example, this
    policy will be loaded for any RHEL 8 installation, but will not be loaded
    for CentOS Stream 8 or Red Hat CoreOS, for which there are separate
    policies.

    Plugins activated by installed packages will only be activated if those
    packages are installed via RPM (dnf/yum inclusive). Packages installed by
    other means are not considered by this policy.

    By default, --upload will be directed to using the SFTP location provided
    by Red Hat for technical support cases. Users who provide login credentials
    for their Red Hat Customer Portal account will have their archives uploaded
    to a user-specific directory.

    If users provide those credentials as well as a case number, --upload will
    instead attempt to directly upload archives to the referenced case, thus
    streamlining the process of providing data to technical support engineers.

    If either or both of the credentials or case number are omitted or are
    incorrect, then a temporary anonymous user will be used for upload to the
    SFTP server, and users will need to provide that information to their
    technical support engineer. This information will be printed at the end of
    the upload process for any sos report execution.
    raThis command will collect diagnostic and configuration information from this %(distro)s system and installed applications.

An archive containing the collected information will be generated in %(tmpdir)s and may be provided to a %(vendor)s support representative.
�%(vendor_text)s
�postNTc�&tt|�j||||d�|�t�dS�Nr)rrEr �register_presetsrr0r2r4r5r ��
�zRHELPolicy.__init__r6cCs�|r|j|vStj�t�sdSttd��.}|D]"}|�d�r9|�d�\}}|�d�}|�|j�r9Wd�dSqWd�dS1sEwYdS)a�Test to see if the running host is a RHEL installation.

            Checks for the presence of the "Red Hat Enterprise Linux"
            release string at the beginning of the NAME field in the
            `/etc/os-release` file and returns ``True`` if it is
            found, and ``False`` otherwise.

            :returns: ``True`` if the host is running RHEL or ``False``
                      otherwise.
        F�r�NAME�=z"'NT)	rIr,rQ�exists�
OS_RELEASE�open�
startswith�split�strip)r9r:r\�line�name�valuer4r4r5r;�s$


��
��zRHELPolicy.checkcsv|jdjrdS|jdjrtt|���dS|��s9|jr'tt	d��|_dSt
|_|j�d�tt	d��|_dSdS)N�cmdlineoptszVEnter your Red Hat Customer Portal username for uploading [empty for anonymous SFTP]: z&No case id provided, uploading to SFTPzYEnter your Red Hat Customer Portal username for uploading to SFTP [empty for anonymous]: )
�commonsrmrlrrE�prompt_for_upload_user�get_upload_user�case_id�input�_�RH_SFTP_HOST�ui_log�info�r1r2r4r5r�s ���z!RHELPolicy.prompt_for_upload_usercCsJ|jr|jS|jdjr|jdjS|jdjdkrtSd}t||jS)Nr��sftpz /support/v1/cases/%s/attachments)rlr��upload_protocolr��RH_API_HOSTr�)r1�rh_case_apir4r4r5�get_upload_urlszRHELPolicy.get_upload_urlcCs|���t�rddd�SiS)N�falsezno-cache)�	isPrivatez
cache-control)r�rr�r�r4r4r5�_get_upload_headers&s
zRHELPolicy._get_upload_headerscCs*|���t�r	dS|���t�rdS|jS)NzRed Hat Customer PortalzRed Hat Secure FTP)r�rr�r�rlr�r4r4r5�get_upload_url_string+s
z RHELPolicy.get_upload_url_stringcCs>|j�d�d}|jrd|j|f}|jrtj�|j|�}|S)z�The RH SFTP server will only automatically connect file uploads to
        cases if the filename _starts_ with the case number
        �/���z%s_%s)�upload_archive_namer�r��upload_directoryr,rQrT)r1�fnamer4r4r5�_get_sftp_upload_name2sz RHELPolicy._get_sftp_upload_namec	sZt�d�d|��vrtt|���Ststd��d}d}td}|�	�r[|�
�r[|��}tj
||dd�}|jdkrF|�	�}t�|j�d	}n|j�d
|j�d|�����|j�d�|s�d
di}tj
|t�|�dd�}|jdkr�t�|j�}|d}|d	}|j�td|�d���n|j�d|j�d|�����|r�|r�tt|�j||d�Std��)z�Override the base upload_sftp to allow for setting an on-demand
        generated anonymous login for the RH SFTP server if a username and
        password are not given
        z//rzPpython3-requests is not installed and is required for obtaining SFTP auth token.Nz/support/v2/sftp/token�
)�auth�timeout���tokenz$DEBUG: auth attempt failed (status: z): zUUnable to retrieve Red Hat auth token using provided credentials. Will try anonymous.�isAnonymousT)�datar��usernamezUser z^ used for anonymous upload. Please inform your support engineer so they may retrieve the data.z)DEBUG: anonymous request failed (status: )�user�passwordz1Could not retrieve valid or anonymous credentials)r�r�r�rrE�upload_sftp�REQUESTS_LOADED�	Exceptionr�r��get_upload_password�get_upload_https_auth�requestsrt�status_code�json�loads�textr��debug�error�dumpsr�r�)	r1�_token�_user�urlr��ret�adata�anon�respr2r4r5r�=sV

���
�����zRHELPolicy.upload_sftpcs�z|jr|j�t�r|��r|��st|_tt|��|�}W|St	yHd}|j�t�s/�|j
�tdt����t|_tt|��|�}Y|Sw)zOverride the base upload_archive to provide for automatic failover
        from RHCP failures to the public RH dropbox
        Fz1Upload to Red Hat Customer Portal failed. Trying )
rlrr�r�r�r�rrE�upload_archiver�r�r�r�)r1�archive�uploadedr2r4r5r�ts,������zRHELPolicy.upload_archivecCsBz|j�d�}|j|dd}t|d�WSty YdSw)Nzredhat-release*rrOF)r"�all_pkgs_by_name_regexr%�intr�)r1�rr�pkgnamer4r4r5�dist_version�s�zRHELPolicy.dist_versioncCs�dD]}|j�d|d�r|�t�Sq|�d�dur!|�t�S|�d�dur-|�t�S|�d�dur9|�t�S|�d�dusG|�d�durL|�t�S|�t	�S)	N)�rescue�	emergencyz	%s.targetFzsatellite-commonz
rhosp-release�cfmezovirt-engine�vdsm)
�init_system�
is_running�find_presetr�pkg_by_namerrr
rr)r1�targetr4r4r5�probe_preset�s�




zRHELPolicy.probe_presetrbrc)rdrerf�__doc__�RHEL_RELEASE_STRrIrgr��disclaimer_text�msgr��_upload_url�_upload_methodr rqr;r�r�r�r�r�r�r�r�r�rrr4r4r2r5rE�s2��	�7rEc@seZdZdZdZdgZdS)rD�CentOS��Community Websitezhttps://www.centos.org/N�rdrerfrIrgrhr4r4r4r5rD��
rDcsreZdZdZeded�ZdZdZdZ	dZ
dZ			d�fd
d�	Ze
dd
d��Zdd�Zddd�Zdd�Z�ZS)�RedHatAtomicPolicyzRed Hat Atomic Host��This command will collect diagnostic and configuration information from this %(distro)s system.

An archive containing the collected information will be generated in %(tmpdir)s and may be provided to a %(vendor)s support representative.
rsT�dockerz.registry.access.redhat.com/rhel7/support-tools�/host�
rpm -q sosNcrurv)rr�r rwrr0r2r4r5r �rxzRedHatAtomicPolicy.__init__r6cCs~|r|j|vSd}ttjvr|Stjtt}tj�|�sdSzt|d����	�D]}|t
|vO}q)W|Sty>Y|Sw)NFry)rIrr,�environr}rQr|r~�read�
splitlines�ATOMIC_RELEASE_STR�IOError)r9r:�atomic�host_releaser�r4r4r5r;�s"

���zRedHatAtomicPolicy.checkcCs|�d�r
|�t�S|�t�S)Nzatomic-openshift)r�r�r	rr�r4r4r5r��s


zRedHatAtomicPolicy.probe_presetFcC�6d}|p|j}|rdnd}|j|j|j|||pdd�S�Na{runtime} run -di --name {name} --privileged --ipc=host --net=host --pid=host -e HOST=/host -e NAME={name} -e IMAGE={image} {pull} -v /run:/run -v /var/log:/var/log -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -v /:/host {auth} {image}z
--pull=alwaysr6)�runtimer��image�pullr���container_imagerH�container_runtime�sos_container_name�r1r�r��
force_pull�_cmd�_image�_pullr4r4r5�create_sos_container��
�z'RedHatAtomicPolicy.create_sos_containercCr7)Nz#docker rm --force sos-collector-tmpr4r�r4r4r5�set_cleanup_cmd�sz"RedHatAtomicPolicy.set_cleanup_cmdrbrc�NNF)rdrerfrIr�r�r��containerzedr�r��sos_path_strip�container_version_commandr rqr;r�r�r�rrr4r4r2r5r��s(��	�
r�cszeZdZdZdZeded�ZdZdZ	dZ
dZd	Zd
Z
		d�fdd
�	Zeddd��Zdd�Zddd�Zdd�Z�ZS)rFaB
    Red Hat CoreOS is a containerized host built upon Red Hat Enterprise Linux
    and as such this policy is built on top of the RHEL policy. For users, this
    should be entirely transparent as any behavior exhibited or influenced on
    RHEL systems by that policy will be seen on RHCOS systems as well.

    The one change is that this policy ensures that sos collect will deploy a
    container on RHCOS systems in order to facilitate sos report collection,
    as RHCOS discourages non-default package installation via rpm-ostree which
    is used to maintain atomicity for RHCOS nodes. The default container image
    used by this policy is the support-tools image maintained by Red Hat on
    registry.redhat.io.

    Note that this policy is only loaded when sos is directly run on an RHCOS
    node - if sos collect uses the `oc` transport (the default transport that
    will be attempted by the ocp cluster profile), then the policy loaded
    inside the launched pod will be RHEL. Again, this is expected and will not
    impact how sos report collections are performed.
    zRed Hat CoreOSr�rsTrz&registry.redhat.io/rhel8/support-toolsr�r�z/var/lib/kubelet/config.jsonNc�tt|�j||||d�dSrv)rrFr r0r2r4r5r �
�zRedHatCoreOSPolicy.__init__r6cCsl|rd|vSd}ttjvr|Stjtt}zt|d�����D]}|d|vO}q W|Sty5Y|Sw)N�CoreOSFryzRed Hat Enterprise Linux CoreOS)rr,r�r}r~r�r�r�)r9r:�coreosr�r�r4r4r5r;s
���zRedHatCoreOSPolicy.checkcCs
|�t�Sr^)r�r	r�r4r4r5r�0s
zRedHatCoreOSPolicy.probe_presetFcCr�r�r�r�r4r4r5r�5r�z'RedHatCoreOSPolicy.create_sos_containercCs
d|jS)Nzpodman rm --force %s)r�r�r4r4r5r�Cs
z"RedHatCoreOSPolicy.set_cleanup_cmdrbrcr�)rdrerfr�rIr�r�r��
containerizedr�r�r�r��container_authfiler rqr;r�r�r�rrr4r4r2r5rF�s,��	�
rFc@seZdZdZdZdgZdS)�CentOsAtomicPolicyzCentOS Atomic Hostr�r�Nr�r4r4r4r5rGr�rcsLeZdZdZdZdZddgZ		d�fdd	�	Zeddd��Z	d
d�Z
�ZS)rGaj
    The policy for Fedora based systems, regardless of spin/edition. This
    policy is based on the parent Red Hat policy, and thus will only check for
    RPM packages when considering packaged-based plugin enablement. Packages
    installed by other sources are not considered.

    There is no default --upload location for this policy. If users need to
    upload an sos report archive from a Fedora system, they will need to
    provide the location via --upload-url, and optionally login credentials
    for that location via --upload-user and --upload-pass (or the appropriate
    environment variables).
    �Fedorazthe Fedora Project)r�zhttps://fedoraproject.org/)zCommunity Forumsz%https://discussion.fedoraproject.org/NTcr�rv)rrGr r0r2r4r5r br�zFedoraPolicy.__init__r6cCs|r|j|vStj�d�S)zXThis method checks to see if we are running on Fedora. It returns
        True or False.z/etc/fedora-release)rIr,rQ�isfiler8r4r4r5r;hs
zFedoraPolicy.checkcCs$|�d�p|�d�d}t|d�S)Nzfedora-releasezfedora-release-.*r�rO)r�r�r�)r1�pkgr4r4r5�fedora_versionrs
�zFedoraPolicy.fedora_versionrbrc)rdrerfr�rIrgrhr rqr;rrrr4r4r2r5rGMs
��	rG)+r�r,r&rU�sos.report.pluginsr�sos.presets.redhatrrrrrrr	r
rr�sos.policies.distrosr
r�!sos.policies.package_managers.rpmr�
sos.utilitiesrrrr�r�r��ImportErrorr}r�r�rr�r�r�rErDr�rFrrGr4r4r4r5�<module>s>
0�qCT

Spamworldpro Mini