MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //etc/leapp/repos.d/system_upgrade/common/libraries/gpg.pyo
�
��ic@s�ddlZddlmZddlmZmZddlmZmZddl	m
Z
dZd�Zd�Z
d	�Zd
�Zd�Zd�ZdS(
i����N(tconfig(tget_source_major_versiontget_target_major_version(tapitrun(tGpgKeysrpm-gpgcCs;g|jD]-}|jdkr
td|jdt�^q
S(s�
    Return the list of fingerprints of GPG keys in RPM DB

    This function returns short 8 characters fingerprints of trusted GPG keys
    "installed" in the source OS RPM database. These look like normal packages
    named "gpg-pubkey" and the fingerprint is present in the version field.

    :param installed_rpms: List of installed RPMs
    :type installed_rpms: list(leapp.models.RPM)
    :return: list of GPG keys from RPM DB
    :rtype: list(leapp.models.GpgKey)
    s
gpg-pubkeytfingerprinttrpmdb(titemstnameRtversiontTrue(tinstalled_rpmstpkg((sO/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/gpg.pytget_pubkeys_from_rpmss
cCs�y_dg}t�dkr+|jd�n
|jd�|d|g7}t|dtdt�SWn?tk
r�}dj|t|��}tj	�j
|�iSXd	S(
s
    Show keys in given file in version-agnostic manner

    This runs gpg --show-keys (EL8) or gpg --with-fingerprints (EL7)
    to verify the given file exists, is readable and contains valid
    OpenPGP key data, which is printed in parsable format (--with-colons).
    tgpg2t7s--with-fingerprints--show-keyss
--with-colonstsplittcheckeds.Failed to read fingerprint from GPG key {}: {}N(RtappendRRtFalsetOSErrortformattstrRtcurrent_loggerterror(tkey_pathtcmdterrR((sO/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/gpg.pyt_gpg_show_keyss	
cCs�|s|drgSg}x�|dD]�}|s&|jd�rIq&n|jd�}t|�dkr�t|d�dkr�|j|ddj��q&tj�jdj|��q&W|S(	sL
    Parse the output of gpg --show-keys --with-colons.

    Return list of 8 characters fingerprints per each gpgkey for the given
    output from stdlib.run() or None if some error occurred. Either the
    command return non-zero exit code, the file does not exists, its not
    readable or does not contain any openpgp data.
    t	exit_codetstdoutspub:t:iiis(Cannot parse the gpg2 output. Line: "{}"(	t
startswithRtlenRtlowerRRtwarningR(toutputtgpg_fpstlinetparts((sO/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/gpg.pyt_parse_fp_from_gpg5s		(cCsNt|�}t|�}|sJdj||d�}tj�j|�n|S(sZ
    Return the list of public key fingerprints from the given file

    Log warning in case no OpenPGP data found in the given file or it is not
    readable for some reason.

    :param key_path: Path to the file with GPG key(s)
    :type key_path: str
    :return: List of public key fingerprints from the given file
    :rtype: list(str)
    s'Unable to read OpenPGP keys from {}: {}tstderr(RR)RRRR$(Rtrestfpt	error_msg((sO/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/gpg.pytget_gpg_fp_from_fileXscCs^t�}tjd�}|}|dkr<dj|�}ndtjjtjt	�|�gS(sB
    Get path to the directory with trusted target gpg keys in the common leapp repository.

    GPG keys stored under this directory are considered as trusted and are
    installed during the upgrade process.

    :return: Path to the directory with GPG keys stored under the common leapp repository.
    :rtype: str
    ttargettbetas{}betas#/etc/leapp/files/vendors.d/rpm-gpg/(
RRtget_product_typeRtostpathtjoinRtget_common_folder_pathtGPG_CERTS_FOLDER(ttarget_major_versionttarget_product_typet	certs_dir((sO/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/gpg.pytget_path_to_gpg_certsls
	cCstjdt�dkS(s�
    Return True if the GPG check should be skipped.

    The GPG check is skipped if leapp is executed with LEAPP_NOGPGCHECK=1
    or with the --nogpgcheck CLI option. In both cases, actors will see
    LEAPP_NOGPGCHECK is '1'.

    :rtype: bool
    tLEAPP_NOGPGCHECKt1(Rtget_envR(((sO/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/gpg.pytis_nogpgcheck_set�s
(R2tleapp.libraries.commonRt%leapp.libraries.common.config.versionRRtleapp.libraries.stdlibRRtleapp.modelsRR6RRR)R.R:R>(((sO/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/gpg.pyt<module>s			#