o nnh@sdZddlmZddlmZddlmZddlmZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZmZddlmZdd lmZmZejrQdd lmZe jdd d kZeefd dierfddiniZdHddZddZ ddZ!eGddde"Z#eGddde#Z$eGddde#Z%eGddde#Z&eGddde#Z'eGd d!d!e#Z(eGd"d#d#e#Z)eGd$d%d%e#Z*eGd&d'd'e#Z+eGd(d)d)e#Z,eGd*d+d+e#Z-eGd,d-d-e#Z.eGd.d/d/e#Z/eGd0d1d1e#Z0eGd2d3d3e#Z1eGd4d5d5e#Z2eGd6d7d7e#Z3id8e$d9e%d:e&d;e'de*d?e+d@e,dAe-dBe.dCe/dDe0dEe1dFe2dGe3Z4dS)IzSignature verification helpers.) annotations) AnsibleError) user_agent)open_urlN) dataclassfields)partial) HTTPErrorURLError)Display) frozenTslotsc Cs|dur |d|z"t|tddd}|}WdW|S1s'wYW|SttfyG}z td|d||d}~ww)NzUsing signature at Tsafe) http_agentvalidate_certsfollow_redirectsz:Failed to get signature for collection verification from '': )vvvvrrreadr r r)sourcedisplayresp signatureerH/usr/local/lib/python3.10/dist-packages/ansible/galaxy/collection/gpg.pyget_signature_from_sources.    rc Cstt\}}tj| }dd|ddddd|d|g }d |}|d |d z;ztj|tjtjtj|fd d } Wnt tj fyX} z t d|d| | d} ~ ww| j |d\} } Wt |nt |w|rtt t|Wdn1swYt|!} | } |d| d| d| jd| | jfWdS1swYdS)Ngpgz --status-fd=z--verifyz--batchz--no-ttyz--no-default-keyringz --keyring=- zRunning command ''utf8)stdinstdoutstderrpass_fdsencodingz/Failed during GnuPG verification with command 'r)inputz stdout: z stderr: z (exit code ))ospipepathexistsjoinr subprocessPopenPIPEFileNotFoundErrorSubprocessErrorr communicateclose contextlibsuppressOSErrorremovefdopenr returncode) manifest_filerkeyringrstatus_fd_readstatus_fd_write remove_keyboxcmdcmd_strperrr&r'frrrrun_gpg_verify1sX      $rHc cs|D]M}|s qz |jdd\}}}Wnty(|jdd\}}d}Ynwzt|}Wn ty8Yqw|g}|rM||dtt|d||VqdS)Nr )maxsplit) splitlinessplit ValueError GPG_ERROR_MAPKeyErrorextendlen dc_fields) status_outline_dummystatus remainderclsrrrrparse_gpg_errorshs2     rYcs4eZdZUded<edddZfddZZS) GpgBaseErrorstrrVreturncCsd|jS)z%Return the current class description.r")r0__doc__rL)rXrrrget_gpg_error_descriptionsz&GpgBaseError.get_gpg_error_descriptioncs@tjt|ddD]\}}tt|||t||q dS)NT)eval_str)inspectget_annotationstypeitemssuperrZ __setattr__getattr)self field_name field_type __class__rr __post_init__szGpgBaseError.__post_init__)r\r[)__name__ __module__ __qualname____annotations__ classmethodr^rl __classcell__rrrjrrZs  rZc@"eZdZUdZded<ded<dS) GpgExpSigzCThe signature with the keyid is good, but the signature is expired.r[keyidusernameNrmrnror]rprrrrrt  rtc@rs) GpgExpKeySigzSThe signature with the keyid is good, but the signature was made by an expired key.r[rurvNrwrrrrryrxryc@rs) GpgRevKeySigzRThe signature with the keyid is good, but the signature was made by a revoked key.r[rurvNrwrrrrrzrxrzc@rs) GpgBadSigz8The signature with the keyid has not been verified okay.r[rurvNrwrrrrr{rxr{c@sJeZdZUdZded<ded<ded<ded<ded<ded <ded <d S) GpgErrSigz"It was not possible to check the signature. This may be caused by a missing public key or an unsupported algorithm. A RC of 4 indicates unknown algorithm, a 9 indicates a missing public key. r[ruintpkalgohashalgo sig_classtimercfprNrwrrrrr|s  r|c@eZdZUdZded<dS) GpgNoPubkeyz The public key is not available.r[ruNrwrrrrr  rc@eZdZdZdS)GpgMissingPassPhrasezNo passphrase was supplied.Nrmrnror]rrrrrrc@r)GpgBadPassphrasez/The supplied passphrase was wrong or not given.r[ruNrwrrrrrrrc@r) GpgNoDataNo data has been found. Codes for WHAT are: - 1 :: No armored data. - 2 :: Expected a packet but did not find one. - 3 :: Invalid packet found, this may indicate a non OpenPGP message. - 4 :: Signature expected but not found. r[whatNrwrrrrr  rc@r) GpgUnexpectedrr[rNrwrrrrrrrc@s.eZdZUdZded<ded<dZded<dS) GpgErrorz]This is a generic error status message, it might be followed by error location specific data.r[locationr}codemoreN)rmrnror]rprrrrrrs rc@s"eZdZUdZded<ded<dS) GpgFailurezJThis is the counterpart to SUCCESS and used to indicate a program failure.r[rr}rNrwrrrrrrxrc@r) GpgBadArmorzThe ASCII armor is corrupted.Nrrrrrrrrc@r) GpgKeyExpiredzThe key has expired.r} timestampNrwrrrrrrrc@r) GpgKeyRevokedz+The used key has been revoked by its owner.Nrrrrrrrrc@r) GpgNoSecKeyz The secret key is not available.r[ruNrwrrrrrrrEXPSIG EXPKEYSIG REVKEYSIGBADSIGERRSIG NO_PUBKEYMISSING_PASSPHRASEBAD_PASSPHRASENODATA UNEXPECTEDERRORFAILUREBADARMOR KEYEXPIRED KEYREVOKED NO_SECKEY)N)5r] __future__ransible.errorsransible.galaxy.user_agentransible.module_utils.urlsrr8r`r,r1systypingt dataclassesrrrR functoolsr urllib.errorr r TYPE_CHECKINGansible.utils.displayr version_info IS_PY310_PLUSfrozen_dataclassrrHrY ExceptionrZrtryrzr{r|rrrrrrrrrrrrNrrrrs        7