JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/certbot/plugins/__pycache__/common.cpython-39.opt-1.pyc

a

}|�g�C�@s:dZddlmZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"ddl#m$Z%ddl#m&Z'ddl(m)Z)e�*e+�Z,e-e-d�dd�Z.e-e-d�dd�Z/e�0d �Z1e�0d!ej2�Z3Gd"d#�d#e'ed$�Z&Gd%d&�d&e%e&ed$�Z$Gd'd(�d(e$ej4ed$�Z5ed)d*d+�Z6Gd,d*�d*�Z7Gd-d.�d.�Z8e-e-e-ee-dd/�d0d1�Z9e-e-ee-e-e-fd2�d3d4�Z:dS)5zPlugin common functions.�)�ABCMeta)�abstractmethodN)�Any)�Callable)�Iterable)�List)�Optional)�Set)�Tuple)�Type)�TypeVar)�
challenges)�achallenges)�
configuration)�crypto_util)�errors)�
interfaces)�reverter)�	constants)�
filesystem)�os)�	Installer)�Plugin)�
PluginStorage��name�returncCs|dS)�9ArgumentParser options namespace (prefix of all options).�-��rrr�:/usr/lib/python3.9/site-packages/certbot/plugins/common.py�option_namespace%sr"cCs|�dd�dS)�;ArgumentParser dest namespace (prefix of all destinations).r�_)�replacer rrr!�dest_namespace*sr&zX(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)z3^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*[a-z]+$cs�eZdZdZejedd��fdd�Zee	e
ddd�dd	���Zeej
edd
�dd��Zeed
�dd��Zeed�dd�Zeed
�dd��Zeed�dd�Zeed�dd�Zeejed�dd�Z�ZS)rzGeneric plugin.N)�configrrcst��||�||_||_dS�N)�super�__init__r'r)�selfr'r��	__class__rr!r*9szPlugin.__init__).N)�addrcCsdS)z�Add plugin arguments to the CLI argument parser.

        :param callable add: Function that proxies calls to
            `argparse.ArgumentParser.add_argument` prepending options
            with unique plugin name prefix.

        Nr)�clsr.rrr!�add_parser_arguments>szPlugin.add_parser_arguments)�parserrrcs$tttdd���fdd�}|�|�S)zkInject parser options.

        See `~.certbot.interfaces.Plugin.inject_parser_options` for docs.

        N)�arg_name_no_prefix�args�kwargsrcs(�jd�t��|�g|�Ri|��dS)Nz--{0}{1})�add_argument�formatr")r2r3r4�rr1rr!r.Qs���z)Plugin.inject_parser_options.<locals>.add)�strrr0)r/r1rr.rr7r!�inject_parser_optionsIszPlugin.inject_parser_options�rcCs
t|j�S)r)r"r�r+rrr!r"WszPlugin.option_namespacercCs
|j|S)z'Option name (include plugin namespace).)r")r+rrrr!�option_name\szPlugin.option_namecCs
t|j�S)r#)r&rr;rrr!r&`szPlugin.dest_namespace)�varrcCs|j|�dd�S)z.Find a destination for given variable ``var``.rr$)r&r%�r+r=rrr!�desteszPlugin.destcCst|j|�|��S)z0Find a configuration value for variable ``var``.)�getattrr'r?r>rrr!�confkszPlugin.conf)�failed_achallsrcCs(d�tdd�|D���}dj|j|d�S)a9Human-readable string to help the user troubleshoot the authenticator.

        Shown to the user if one or more of the attempted challenges were not a success.

        Should describe, in simple language, what the authenticator tried to do, what went
        wrong and what the user should try as their "next steps".

        TODO: auth_hint belongs in Authenticator but can't be added until the next major
        version of Certbot. For now, it lives in .Plugin and auth_handler will only call it
        on authenticators that subclass .Plugin. For now, inherit from `.Plugin` to implement
        and/or override the method.

        :param list failed_achalls: List of one or more failed challenges
                                    (:class:`achallenges.AnnotatedChallenge` subclasses).

        :rtype str:
        z and cSsh|]
}|j�qSr)�typ)�.0�achallrrr!�	<setcomp>��z#Plugin.auth_hint.<locals>.<setcomp>z�The Certificate Authority couldn't externally verify that the {name} plugin completed the required {challs} challenges. Ensure the plugin is configured correctly and that the changes it makes are accessible from the internet.)r�challs)�join�sortedr6r)r+rBrHrrr!�	auth_hintos�zPlugin.auth_hint)�__name__�
__module__�__qualname__�__doc__rZNamespaceConfigr8r*�classmethodrrr0�argparse�ArgumentParserr9�propertyr"r<r&r?rrArrZAnnotatedChallengerK�
__classcell__rrr,r!r6s	
r)�	metaclasscs�eZdZdZeedd��fdd�Zdeeeedd�dd	�Z	edd
�dd�Z
dd
�dd�Zdd
�dd�Zde
dd�dd�Zeed
�dd��Zeed
�dd��Zdd
�dd�Z�ZS)rz�An installer base class with reverter and ssl_dhparam methods defined.

    Installer plugins do not have to inherit from this class.

    N)r3r4rcs4t�j|i|��t|j|j�|_t�|j�|_dSr()r)r*rr'rZstoragerZReverter)r+r3r4r,rr!r*�szInstaller.__init__F)�
save_files�
save_notes�	temporaryrc
Cs^|r|jj}n|jj}z|||�Wn4tjyX}zt�t|���WYd}~n
d}~00dS)a�Add files to a checkpoint.

        :param set save_files: set of filepaths to save
        :param str save_notes: notes about changes during the save
        :param bool temporary: True if the files should be added to a
            temporary checkpoint rather than a permanent one. This is
            usually used for changes that will soon be reverted.

        :raises .errors.PluginError: when unable to add to checkpoint

        N)rZadd_to_temp_checkpoint�add_to_checkpointr�
ReverterError�PluginErrorr8)r+rVrWrXZcheckpoint_func�errrrr!rY�s

zInstaller.add_to_checkpoint)�titlerc
CsJz|j�|�Wn4tjyD}zt�t|���WYd}~n
d}~00dS)z�Timestamp and save changes made through the reverter.

        :param str title: Title describing checkpoint

        :raises .errors.PluginError: when an error occurs

        N)r�finalize_checkpointrrZr[r8)r+r]r\rrr!r^�szInstaller.finalize_checkpointr:c
CsHz|j��Wn4tjyB}zt�t|���WYd}~n
d}~00dS)z�Revert all previously modified files.

        Reverts all modified files that have not been saved as a checkpoint

        :raises .errors.PluginError: If unable to recover the configuration

        N)r�recovery_routinerrZr[r8�r+r\rrr!r_�szInstaller.recovery_routinec
CsHz|j��Wn4tjyB}zt�t|���WYd}~n
d}~00dS)zkRollback temporary checkpoint.

        :raises .errors.PluginError: when unable to revert config

        N)r�revert_temporary_configrrZr[r8r`rrr!ra�sz!Installer.revert_temporary_config�)�rollbackrc
CsJz|j�|�Wn4tjyD}zt�t|���WYd}~n
d}~00dS)z�Rollback saved checkpoints.

        :param int rollback: Number of checkpoints to revert

        :raises .errors.PluginError: If there is a problem with the input or
            the function is unable to correctly revert the configuration

        N)r�rollback_checkpointsrrZr[r8)r+rcr\rrr!rd�s	zInstaller.rollback_checkpointscCstj�|jjtj�S)z(Full absolute path to ssl_dhparams file.)r�pathrIr'�
config_dirrZSSL_DHPARAMS_DESTr;rrr!�ssl_dhparams�szInstaller.ssl_dhparamscCstj�|jjtj�S)z:Full absolute path to digest of updated ssl_dhparams file.)rrerIr'rfrZUPDATED_SSL_DHPARAMS_DIGESTr;rrr!�updated_ssl_dhparams_digest�sz%Installer.updated_ssl_dhparams_digestcCst|j|jtjtj�dS)zJCopy Certbot's ssl_dhparams file into the system's config dir if required.N)�install_version_controlled_filergrhrZSSL_DHPARAMS_SRCZALL_SSL_DHPARAMS_HASHESr;rrr!�install_ssl_dhparams�s�zInstaller.install_ssl_dhparams)F)rb)rLrMrNrOrr*r	r8�boolrYr^r_ra�intrdrSrgrhrjrTrrr,r!r�s�
�

rc@seZdZdZdS)�Configuratorzt
    A plugin that extends certbot.plugins.common.Installer
    and implements certbot.interfaces.Authenticator
    N)rLrMrNrOrrrr!rm�srm�GenericAddr�Addr)�boundc@s�eZdZdZd"eeefed�dd�Zee	e
eee
d�dd��Zed	�d
d�Z
eeefd	�dd
�Zeed�dd�Zed	�dd�Zed	�dd�Zed	�dd�Ze
ee
d�dd�Zeeed�dd�Zed	�dd�Zeeed�dd �Zd!S)#roz�Represents an virtual host address.

    :param str addr: addr part of vhost address
    :param str port: port number or \*, or ""

    F��tup�ipv6cCs||_||_dSr(rq)r+rrrsrrr!r*sz
Addr.__init__)r/�str_addrrcCs�|�d�rh|�d�}|d|d�}d}t|�|dkrX||ddkrX||dd�}|||fdd	�S|�d�}||d
|df�SdS)zInitialize Addr from string.�[�]Nrb���:T)rsr)�
startswith�rfind�len�	partition)r/rtZendIndex�host�portrrrrr!�
fromstrings

 
zAddr.fromstringr:cCs|jdrd|jS|jdS)Nrbz%s:%sr�rrr;rrr!�__str__s

zAddr.__str__cCs|jr|��|jdfS|jS)z5Normalized representation of addr/port tuple
        rb)rs�get_ipv6_explodedrrr;rrr!�normalized_tupleszAddr.normalized_tuple)�otherrcCs t||j�r|��|��kSdS)NF)�
isinstancer-r�)r+r�rrr!�__eq__"szAddr.__eq__cCs
t|j�Sr()�hashrrr;rrr!�__hash__*sz
Addr.__hash__cCs
|jdS)z Return addr part of Addr object.rr�r;rrr!�get_addr-sz
Addr.get_addrcCs
|jdS)zReturn port.rbr�r;rrr!�get_port1sz
Addr.get_port)r+rrcCs|�|jd|f|j�S)z6Return new address object with same addr and new port.r)r-rrrs)r+rrrr!�get_addr_obj5szAddr.get_addr_obj)�addrrcCs|�d�}|�d�}|�|�S)z7Return IPv6 address in normalized form, helper functionrurv)�lstrip�rstrip�
_explode_ipv6)r+r�rrr!�_normalize_ipv69s

zAddr._normalize_ipv6cCs |jrd�|�|jd��SdS)zReturn IPv6 in normalized formryrrw)rsrIr�rrr;rrr!r�?szAddr.get_ipv6_explodedcCs�gd�}|�d�}t|�t|�kr2|dt|��}d}t|�D]N\}}|sPd}q>t|�dkrf|�d�}|sxt|�||<q>t|�||t|�<q>|S)z#Explode IPv6 address for comparison)�0r�r�r�r�r�r�r�ryrFTrbr�)�splitr|�	enumerater�r8)r+r��resultZ	addr_listZ
append_to_end�i�blockrrr!r�Es

zAddr._explode_ipv6N)F)rLrMrNrOr
r8rkr*rPrrnrr�r�r�rr�rlr�r�r�r�rr�r�r�rrrr!ro�sc@sLeZdZdZed�dd�Zdejee	dd�dd�Z
eej
d	�d
d�ZdS)
�ChallengePerformeravAbstract base for challenge performers.

    :ivar configurator: Authenticator and installer plugin
    :ivar achalls: Annotated challenges
    :vartype achalls: `list` of `.KeyAuthorizationAnnotatedChallenge`
    :ivar indices: Holds the indices of challenges from a larger array
        so the user of the class doesn't have to.
    :vartype indices: `list` of `int`

    )�configuratorcCs||_g|_g|_dSr()r��achalls�indices)r+r�rrr!r*jszChallengePerformer.__init__N)rE�idxrcCs$|j�|�|dur |j�|�dS)z�Store challenge to be performed when perform() is called.

        :param .KeyAuthorizationAnnotatedChallenge achall: Annotated
            challenge.
        :param int idx: index to challenge in a larger array

        N)r��appendr�)r+rEr�rrr!�	add_challos	zChallengePerformer.add_challr:cCs
t��dS)z�Perform all added challenges.

        :returns: challenge responses
        :rtype: `list` of `acme.challenges.KeyAuthorizationChallengeResponse`


        N)�NotImplementedErrorr;rrr!�perform|szChallengePerformer.perform)N)rLrMrNrOrmr*rZ"KeyAuthorizationAnnotatedChallengerrlr�rr
Z!KeyAuthorizationChallengeResponser�rrrr!r�^s��
r�)�	dest_path�digest_path�src_path�
all_hashesrcs�t����dd���fdd��dd����fdd�}tj���sJ|�dSt���}|�kr`dS||vrp|�n`tj���r�t�d��}|��}Wd�n1s�0Y|�kr�dS��t�d����dS)	a�Copy a file into an active location (likely the system's config dir) if required.

       :param str dest_path: destination path for version controlled file
       :param str digest_path: path to save a digest of the file in
       :param str src_path: path to version controlled file found in distribution
       :param list all_hashes: hashes of every released version of the file
    Nr:cs8t�d��}|���Wd�n1s*0YdS)N�w)�open�write)Zfile_h)�current_hashr�rr!�_write_current_hash�sz<install_version_controlled_file.<locals>._write_current_hashcst������dSr()�shutil�copyfiler)r�r�r�rr!�_install_current_file�sz>install_version_controlled_file.<locals>._install_current_file�rzh%s has been manually modified; updated file saved to %s. We recommend updating %s for security purposes.)	rZ	sha256sumrre�isfiler��read�loggerZwarning)r�r�r�r�r�Zactive_file_digest�fZsaved_digestr)r�r�r�r�r�r!ri�s(	

&�ri)�test_dir�pkgrcCs�ttd�dd�}|d�}|d�}|d�}t�|tj�t�|tj�t�|tj�tj�|��d��|�}tj�	|��*}t
j|tj
�||�dd	�Wd
�n1s�0Y|||fS)z5Setup the directories necessary for the configurator.)�prefixrcSst�t�|��S)a�Return the real path of a temp directory with the specified prefix

        Some plugins rely on real paths of symlinks for working correctly. For
        example, certbot-apache uses real paths of configuration files to tell
        a virtual host from another. On systems where TMP itself is a symbolic
        link, (ex: OS X) such plugins will be confused. This function prevents
        such a case.
        )r�realpath�tempfileZmkdtemp)r�rrr!�expanded_tempdir�s	z#dir_setup.<locals>.expanded_tempdirZtempr'ZworkZtestdataT)�symlinksN)r8r�chmodrZCONFIG_DIRS_MODE�	importlibZ	resources�files�joinpathZas_filer��copytreerrerI)r�r�r�Ztemp_dirrfZwork_dirZtest_dir_refrerrr!�	dir_setup�s�$r�);rO�abcrrrQZimportlib.resourcesr�Zlogging�rer�r��typingrrrrrr	r
rrZacmer
ZcertbotrrrrrrZcertbot._internalrZcertbot.compatrrZcertbot.interfacesrZAbstractInstallerrZAbstractPluginZcertbot.plugins.storagerZ	getLoggerrLr�r8r"r&�compileZprivate_ips_regex�
IGNORECASEZhostname_regexZ
Authenticatorrmrnror�rir�rrrr!�<module>sb
��Thb)�3
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬~TX G[`le69CR(!S2!P <0x<!1AQ "Raq02Br#SCTb ?Ζ"]mH5WR7k.ۛ!}Q~+yԏz|@T20S~Kek *zFf^2X*(@8r?CIuI|֓>^ExLgNUY+{.RѪ τV׸YTD I62'8Y27'\TP.6d&˦@Vqi|8-OΕ]ʔ U=TL8=;6c| !qfF3aů&~$l}'NWUs$Uk^SV:U# 6w++s&r+nڐ{@29 gL u"TÙM=6(^"7r}=6YݾlCuhquympǦ GjhsǜNlɻ}o7#S6aw4!OSrD57%|?x>L |/nD6?/8w#[)L7+6〼T ATg!%5MmZ/c-{1_Je"|^$'O&ޱմTrb$w)R$& N1EtdU3Uȉ1pM"N*(DNyd96.(jQ)X 5cQɎMyW?Q*!R>6=7)Xj5`J]e8%t!+'!1Q5 !1 AQaqё#2"0BRb?Gt^## .llQT $v,,m㵜5ubV =sY+@d{N! dnO<.-B;_wJt6;QJd.Qc%p{ 1,sNDdFHI0ГoXшe黅XۢF:)[FGXƹ/w_cMeD,ʡcc.WDtA$j@:) -# u c1<@ۗ9F)KJ-hpP]_x[qBlbpʖw q"LFGdƶ*s+ډ_Zc"?%t[IP 6J]#=ɺVvvCGsGh1 >)6|ey?Lӣm,4GWUi`]uJVoVDG< SB6ϏQ@ TiUlyOU0kfV~~}SZ@*WUUi##; s/[=!7}"WN]'(L! ~y5g9T̅JkbM' +s:S +B)v@Mj e Cf jE 0Y\QnzG1д~Wo{T9?`Rmyhsy3!HAD]mc1~2LSu7xT;j$`}4->L#vzŏILS ֭T{rjGKC;bpU=-`BsK.SFw4Mq]ZdHS0)tLg