JFIF$        dd7 

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

a

}|�g8�@sTdZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZddlZdd
l
mZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZe�e�ZGdd�dej ej!ej"d�Z#Gdd�d�Z$e%dd�dd�Z&e%dd�dd�Z'e%ee%d�dd �Z(dS)!z*Common code for DNS Authenticator Plugins.�N)�sleep)�Callable)�Iterable)�List)�Mapping)�Optional)�Type)�
challenges)�achallenges)�
configuration)�errors)�
interfaces)�
filesystem)�os)�ops)�util)�commoncs�eZdZdZejedd��fdd�Zed2e	de
dd�d	d
��Zee
jed�dd
�Zeeeejd�dd�Zdd�dd�Zed�dd�Zee
jeejd�dd�Zee
jdd�dd�Zejdd�dd��Zejeeedd�dd��Zejeeedd�d d!��Zeedd"�d#d$�Zd3eee e	egdfdd%�d&d'�Z!d4eee e"eefe e	d(gdfd(d)�d*d+�Z#e$eed,�d-d.��Z%e$d5ee e	egdfed/�d0d1��Z&�Z'S)6�DNSAuthenticatorz!Base class for DNS AuthenticatorsN)�config�name�returncst��||�d|_dS)NF)�super�__init__�_attempt_cleanup)�selfrr��	__class__��>/usr/lib/python3.9/site-packages/certbot/plugins/dns_common.pyr#szDNSAuthenticator.__init__�
).N)�add�default_propagation_secondsrcCs|d|tdd�dS)N�propagation-secondszjThe number of seconds to wait for DNS to propagate before asking the ACME server to verify the DNS record.)�default�type�help)�int)�clsr r!rrr�add_parser_arguments(s
�z%DNSAuthenticator.add_parser_arguments)�failed_achallsrcCs(|�d�}dj|j||dkr dndd�S)z,See certbot.plugins.common.Plugin.auth_hint.r"z�The Certificate Authority failed to verify the DNS TXT records created by --{name}. Ensure the above domains are hosted by this DNS provider, or try increasing --{name}-propagation-seconds (currently {secs} second{suffix}).��s�)rZsecs�suffix)�conf�formatr)rr)Zdelayrrr�	auth_hint1s

��zDNSAuthenticator.auth_hint)�
unused_domainrcCstjgS�N)r	ZDNS01)rr1rrr�get_chall_pref;szDNSAuthenticator.get_chall_pref)rcCsdSr2r�rrrr�prepare>szDNSAuthenticator.preparecCs
t��dSr2��NotImplementedErrorr4rrr�	more_infoAszDNSAuthenticator.more_info)�achallsrcCs~|��d|_g}|D]@}|j}|�|�}|�|j�}|�|||�|�|�|j��qt	�
d|�d��t|�d��|S)NTz/Waiting %d seconds for DNS changes to propagater")
�_setup_credentialsr�domain�validation_domain_name�
validation�account_key�_perform�append�response�display_util�notifyr.r)rr9Z	responses�achallr;r<r=rrr�performDs
�zDNSAuthenticator.performcCs>|jr:|D].}|j}|�|�}|�|j�}|�|||�q
dSr2)rr;r<r=r>�_cleanup)rr9rDr;r<r=rrr�cleanup\s
zDNSAuthenticator.cleanupcCs
t��dS)z@
        Establish credentials, prompting if necessary.
        Nr6r4rrrr:esz#DNSAuthenticator._setup_credentials)r;�validation_namer=rcCs
t��dS)aX
        Performs a dns-01 challenge by creating a DNS TXT record.

        :param str domain: The domain being validated.
        :param str validation_domain_name: The validation record domain name.
        :param str validation: The validation record content.
        :raises errors.PluginError: If the challenge cannot be performed
        Nr6�rr;rHr=rrrr?lszDNSAuthenticator._performcCs
t��dS)aX
        Deletes the DNS TXT record which would have been created by `_perform_achall`.

        Fails gracefully if no such record exists.

        :param str domain: The domain being validated.
        :param str validation_domain_name: The validation record domain name.
        :param str validation: The validation record content.
        Nr6rIrrrrFyszDNSAuthenticator._cleanup)�key�labelrcCs0|�|�}|s,|�|�}t|j|�|�|�dS)a
        Ensure that a configuration value is available.

        If necessary, prompts the user and stores the result.

        :param str key: The configuration key.
        :param str label: The user-friendly label for this piece of information.
        N)r.�_prompt_for_data�setattrr�dest)rrJrK�configured_value�	new_valuerrr�
_configure�s


zDNSAuthenticator._configure)rJrK�	validatorrcCsB|�|�}|s>|�||�}t|j|�|�tj�tj�|���dS)a
        Ensure that a configuration value is available for a path.

        If necessary, prompts the user and stores the result.

        :param str key: The configuration key.
        :param str label: The user-friendly label for this piece of information.
        N)	r.�_prompt_for_filerMrrNr�path�abspath�
expanduser)rrJrKrRrOrPrrr�_configure_file�s
z DNSAuthenticator._configure_file�CredentialsConfiguration)rJrK�required_variablesrRrcsVtdd����fdd�}��|||�t��|��j�}�rF|����rR�|�|S)a�
        As `_configure_file`, but for a credential configuration file.

        If necessary, prompts the user and stores the result.

        Always stores absolute paths to avoid issues during renewal.

        :param str key: The configuration key.
        :param str label: The user-friendly label for this piece of information.
        :param dict required_variables: Map of variable which must be present to error to display.
        :param callable validator: A method which will be called to validate the
            `CredentialsConfiguration` resulting from the supplied input after it has been validated
            to contain the `required_variables`. Should throw a `~certbot.errors.PluginError` to
            indicate any issue.
        N��filenamercs*t|�j�}�r|����r&�|�dSr2)rXrN�require)r[Zapplied_configuration�rYrrRrr�__validator�s

z<DNSAuthenticator._configure_credentials.<locals>.__validator)�strrWrXr.rNr\)rrJrKrYrR�_DNSAuthenticator__validatorZcredentials_configurationrr]r�_configure_credentials�s	
z'DNSAuthenticator._configure_credentials)rKrcsPtdd��fdd�}tj|d���dd�\}}|tjkr<|St�d�����dS)	z�
        Prompt the user for a piece of information.

        :param str label: The user-friendly label for this piece of information.
        :returns: The user's response (guaranteed non-empty).
        :rtype: str
        N)�ircs|st�d�����dS)NzPlease enter your {0}.)r�PluginErrorr/)rb�rKrrr^�sz6DNSAuthenticator._prompt_for_data.<locals>.__validatorzInput your {0}T�Zforce_interactive�{0} required to proceed.)r_rZvalidated_inputr/rB�OKrrc)rKr`�coderArrdrrL�s
�

z!DNSAuthenticator._prompt_for_data)rKrRrcsRtdd���fdd�}tj|d���dd�\}}|tjkr>|St�d�����dS)	a�
        Prompt the user for a path.

        :param str label: The user-friendly label for the file.
        :param callable validator: A method which will be called to validate the supplied input
            after it has been validated to be a non-empty path to an existing file. Should throw a
            `~certbot.errors.PluginError` to indicate any issue.
        :returns: The user's response (guaranteed to exist).
        :rtype: str
        NrZcs8|st�d�����tj�|�}t|��r4�|�dS)Nz&Please enter a valid path to your {0}.)rrcr/rrTrV�
validate_file�r[�rKrRrrr^�sz6DNSAuthenticator._prompt_for_file.<locals>.__validatorzInput the path to your {0}Trerf)r_rZvalidated_directoryr/rBrgrrc)rKrRr`rhrArrkrrS�s
�

z!DNSAuthenticator._prompt_for_file)r)N)NN)N)(�__name__�
__module__�__qualname__�__doc__rZNamespaceConfigr_r�classmethodrr&r(rr
ZAnnotatedChallenger0rrr	Z	Challenger3r5r8ZChallengeResponserErG�abc�abstractmethodr:r?rFrQrrWrra�staticmethodrLrS�
__classcell__rrrrr sR��
�	��
����(r)�	metaclassc@s�eZdZdZdd�feeegefdd�dd�Zeeefdd�d	d
�Zee	ed�dd
�Z
eed�dd�Zee	ed�dd�Z
dS)rXz>Represents a user-supplied filed which stores API credentials.cCs|Sr2r)�xrrr�<lambda>�z!CredentialsConfiguration.<lambda>N)r[�mapperrc
Csnt|�zt�|�|_WnJtjyb}z0tjd||dd�t�d�	||���WYd}~n
d}~00||_
dS)z�
        :param str filename: A path to the configuration file.
        :param callable mapper: A transformation to apply to configuration key names
        :raises errors.PluginError: If the file does not exist or is not a valid format.
        z0Error parsing credentials configuration '%s': %sT)�exc_infoz0Error parsing credentials configuration '{}': {}N)�validate_file_permissions�	configobjZ	ConfigObj�confobjZConfigObjError�logger�debugrrcr/ry)rr[ry�errrrs"���z!CredentialsConfiguration.__init__)rYrc	Cs�g}|D]R}|�|�s4|�d�|�|�||��q|�|�s|�d�|�|�||��q|r�t�d�t|�dkrxdnd|jj	d�
|����dS)	z�Ensures that the supplied set of variables are all present in the file.

        :param dict required_variables: Map of variable which must be present to error to display.
        :raises errors.PluginError: If one or more are missing.
        z)Property "{0}" not found (should be {1}).z'Property "{0}" not set (should be {1}).z9Missing {0} in credentials configuration file {1}:
 * {2}r*�propertyZ
propertiesz
 * N)�_hasr@r/ry�_getrrc�lenr}r[�join)rrY�messages�varrrrr\&s$
�
���z CredentialsConfiguration.require)r�rcCs
|�|�S)z�Find a configuration value for variable `var`, as transformed by `mapper`.

        :param str var: The variable to get.
        :returns: The value of the variable, if it exists.
        :rtype: str or None
        )r��rr�rrrr.?szCredentialsConfiguration.confcCs|�|�|jvSr2)ryr}r�rrrr�IszCredentialsConfiguration._hascCs|j�|�|��Sr2)r}�getryr�rrrr�LszCredentialsConfiguration._get)rlrmrnror_rrrr\rr.�boolr�r�rrrrrX	s$
rXrZcCs<tj�|�st�d�|���tj�|�r8t�d�|���dS)z&Ensure that the specified file exists.zFile not found: {0}zPath is a directory: {0}N)rrT�existsrrcr/�isdirrjrrrriPsricCs"t|�t�|�rt�d|�dS)zHEnsure that the specified file exists and warn about unsafe permissions.z8Unsafe permissions on credentials configuration file: %sN)rirZhas_world_permissionsr~Zwarningrjrrrr{Zs
r{)r;rcs&|�d���fdd�tdt���D�S)a�Return a list of progressively less-specific domain names.

    One of these will probably be the domain name known to the DNS provider.

    :Example:

    >>> base_domain_name_guesses('foo.bar.baz.example.com')
    ['foo.bar.baz.example.com', 'bar.baz.example.com', 'baz.example.com', 'example.com', 'com']

    :param str domain: The domain for which to return guesses.
    :returns: The a list of less specific domain names.
    :rtype: list
    �.csg|]}d��|d���qS)r�N)r�)�.0rb�Z	fragmentsrr�
<listcomp>srxz,base_domain_name_guesses.<locals>.<listcomp>r)�split�ranger�)r;rr�r�base_domain_name_guessescs
r�))rorqZlogging�timer�typingrrrrrrr|Zacmer	Zcertbotr
rrr
Zcertbot.compatrrZcertbot.displayrrrBZcertbot.pluginsrZ	getLoggerrlr~ZPluginZ
Authenticator�ABCMetarrXr_rir{r�rrrr�<module>s6
jG
	
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](*`wq1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