a )g@sXdZddlmZddlmZddlmZddlZddlZddl Z ddl Z ddl Z ddl mZmZddlmZddlmZmZe jrdd lmZe jdd d kZeefd d ierdd iniZd8ddZddZddZeGdddeZ eGddde Z!eGddde Z"eGddde Z#eGddde Z$eGdd 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,eGd/d0d0e Z-eGd1d2d2e Z.eGd3d4d4e Z/eGd5d6d6e Z0e!e"e#e$e%e&e'e(e)e*e+e,e-e.e/e0d7Z1dS)9zSignature verification helpers.) AnsibleError) user_agent)open_urlN) dataclassfields)partial) HTTPErrorURLError)Display) frozenTslotsc Cs|dur|d|z>t|tddd}|}Wdn1sJ0YWn>ttfy}z"td|d||WYd}~n d}~00|S)NzUsing signature at Tsafe)Z http_agentZvalidate_certsZfollow_redirectsz:Failed to get signature for collection verification from '': )vvvvrrreadrr r)sourcedisplayZresp signatureerA/usr/lib/python3.9/site-packages/ansible/galaxy/collection/gpg.pyget_signature_from_sources$*rc Cst\}}tj| }dd|ddddd|d|g }d |}|d |d zz"tj|tjtjtj|fd d } Wn@t tj fy} z"t d|d| | WYd} ~ nd} ~ 00| j |d\} } Wt |n t |0|r$ttt|Wdn1s0Yt|B} | } |d| d| d| jd| | jfWdS1sx0YdS)NZgpgz --status-fd=z--verifyz--batchz--no-ttyz--no-default-keyringz --keyring=- zRunning command ''utf8)stdinstdoutstderrZpass_fdsencodingz/Failed during GnuPG verification with command 'r)inputz stdout: z stderr: z (exit code ))ospipepathexistsjoinr subprocessPopenPIPEFileNotFoundErrorZSubprocessErrorrZ communicateclose contextlibsuppressOSErrorremovefdopenr returncode)Z manifest_filerZkeyringrZstatus_fd_readZstatus_fd_writeZ remove_keyboxcmdZcmd_strperrr r!frrrrun_gpg_verify/sP    * r9c cs|D]}|sqz|jdd\}}}Wn&tyN|jdd\}}d}Yn0z t|}WntyrYqYn0|g}|r||dtt|d||VqdS)Nr )maxsplit) splitlinessplit ValueError GPG_ERROR_MAPKeyErrorextendlen dc_fields)Z status_outlineZ_dummystatusZ remainderclsrrrrparse_gpg_errorsfs*      rGcs8eZdZUeed<eedddZfddZZS) GpgBaseErrorrE)returncCsd|jS)z%Return the current class description.r)r)__doc__r=)rFrrrget_gpg_error_descriptionsz&GpgBaseError.get_gpg_error_descriptionc s4t|D]&}tt||j|t||jqdS)N)rCsuperrH __setattr__nametypegetattr)selfZfield __class__rr __post_init__s zGpgBaseError.__post_init__) __name__ __module__ __qualname__str__annotations__ classmethodrKrT __classcell__rrrRrrHs rHc@s"eZdZUdZeed<eed<dS) GpgExpSigzCThe signature with the keyid is good, but the signature is expired.keyidusernameNrUrVrWrJrXrYrrrrr\s r\c@s"eZdZUdZeed<eed<dS) GpgExpKeySigzSThe signature with the keyid is good, but the signature was made by an expired key.r]r^Nr_rrrrr`s r`c@s"eZdZUdZeed<eed<dS) GpgRevKeySigzRThe signature with the keyid is good, but the signature was made by a revoked key.r]r^Nr_rrrrras rac@s"eZdZUdZeed<eed<dS) GpgBadSigz8The signature with the keyid has not been verified okay.r]r^Nr_rrrrrbs rbc@sJeZdZUdZeed<eed<eed<eed<eed<eed<eed<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]ZpkalgoZhashalgoZ sig_classtimercZfprNrUrVrWrJrXrYintrrrrrcs rcc@seZdZUdZeed<dS) GpgNoPubkeyz The public key is not available.r]Nr_rrrrrhs rhc@seZdZdZdS)GpgMissingPassPhrasezNo passphrase was supplied.NrUrVrWrJrrrrrisric@seZdZUdZeed<dS)GpgBadPassphrasez/The supplied passphrase was wrong or not given.r]Nr_rrrrrks rkc@seZdZUdZeed<dS) 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. whatNr_rrrrrls rlc@seZdZUdZeed<dS) GpgUnexpectedrmrnNr_rrrrros roc@s.eZdZUdZeed<eed<dZeed<dS)GpgErrorz]This is a generic error status message, it might be followed by error location specific data.locationcodemoreN)rUrVrWrJrXrYrgrtrrrrrps rpc@s"eZdZUdZeed<eed<dS) GpgFailurezJThis is the counterpart to SUCCESS and used to indicate a program failure.rqrrNrfrrrrrus ruc@seZdZdZdS) GpgBadArmorzThe ASCII armor is corrupted.Nrjrrrrrvsrvc@seZdZUdZeed<dS) GpgKeyExpiredzThe key has expired.Z timestampN)rUrVrWrJrgrYrrrrrws rwc@seZdZdZdS) GpgKeyRevokedz+The used key has been revoked by its owner.Nrjrrrrrxsrxc@seZdZUdZeed<dS) GpgNoSecKeyz The secret key is not available.r]Nr_rrrrrys ry)ZEXPSIGZ EXPKEYSIGZ REVKEYSIGZBADSIGZERRSIGZ NO_PUBKEYZMISSING_PASSPHRASEZBAD_PASSPHRASEZNODATAZ UNEXPECTEDZERRORFAILUREZBADARMORZ KEYEXPIREDZ KEYREVOKEDZ NO_SECKEY)N)2rJZansible.errorsrZansible.galaxy.user_agentrZansible.module_utils.urlsrr/r%r*systypingtZ dataclassesrrrC functoolsrZ urllib.errorrr TYPE_CHECKINGZansible.utils.displayr version_infoZ IS_PY310_PLUSZfrozen_dataclassrr9rG ExceptionrHr\r`rarbrcrhrirkrlrorprurvrwrxryr?rrrrs       7