%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/certbot/plugins/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/certbot/plugins/__pycache__/dns_common.cpython-312.pyc

�

M/�e�6���dZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZddlZdd
l
mZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZej:e�ZGd�dej@ejBejD��Z#Gd�d�Z$de%ddfd�Z&de%ddfd�Z'de%dee%fd�Z(y)z*Common code for DNS Authenticator Plugins.�N)�sleep)�Callable)�Iterable)�List)�Mapping)�Optional)�Type)�
challenges)�achallenges)�
configuration)�errors)�
interfaces)�
filesystem)�os)�ops)�util)�commonc���eZdZdZdej
deddf�fd�Ze	d$de	dd	e
ddfd
��Zdee
jdefd�Zd
edeeej&fd�Zd%d�Zdefd�Zdee
jdeej.fd�Zdee
jddfd�Zej6d%d��Zej6dedededdfd��Zej6dedededdfd��Zdededdfd�Z	d&dedede e	egdfddfd�Z!		d'dedede e"eefde e	d gdfdd f
d!�Z#e$dedefd"��Z%e$d&dede e	egdfdefd#��Z&�xZ'S)(�DNSAuthenticatorz!Base class for DNS Authenticators�config�name�returnNc�4��t�|�||�d|_y)NF)�super�__init__�_attempt_cleanup)�selfrr�	__class__s   ��</usr/lib/python3/dist-packages/certbot/plugins/dns_common.pyrzDNSAuthenticator.__init__s���
�����&� %����add).N�default_propagation_secondsc�$�|d|td��y)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"s   r�add_parser_argumentsz%DNSAuthenticator.add_parser_arguments$s��	�!�/��-�	.r �failed_achallsc�x�|jd�}dj|j||dk7rd��Sd��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�)r�secs�suffix)�conf�formatr)rr+�delays   r�	auth_hintzDNSAuthenticator.auth_hint-sI���	�	�/�0��
N��V�����e�q�j�s�V�
Q�		
�OQ�V�
Q�		
r �
unused_domainc�$�tjgS�N)r
�DNS01)rr6s  r�get_chall_prefzDNSAuthenticator.get_chall_pref7s��� � �!�!r c��yr8��rs r�preparezDNSAuthenticator.prepare:s��r c��t��r8��NotImplementedErrorr=s r�	more_infozDNSAuthenticator.more_info=s��!�#�#r �achallsc��|j�d|_g}|D]w}|j}|j|�}|j	|j
�}|j
|||�|j|j|j
���ytjd|jd�z�t|jd��|S)NTz/Waiting %d seconds for DNS changes to propagater$)
�_setup_credentialsr�domain�validation_domain_name�
validation�account_key�_perform�append�response�display_util�notifyr2r)rrC�	responses�achallrFrGrHs       r�performzDNSAuthenticator.perform@s������!� $����	��	B�F��]�]�F�%+�%B�%B�6�%J�"��*�*�6�+=�+=�>�J��M�M�&�"8�*�E����V�_�_�V�-?�-?�@�A�
	B�	���M��I�I�3�4�5�	6�
�d�i�i�-�.�/��r c���|jrS|D]M}|j}|j|�}|j|j�}|j|||��Oyyr8)rrFrGrHrI�_cleanup)rrCrPrFrGrHs      r�cleanupzDNSAuthenticator.cleanupXsb��� � �!�
J������)/�)F�)F�v�)N�&�#�.�.�v�/A�/A�B�
��
�
�f�&<�j�I�
J�!r c��t��)z@
        Establish credentials, prompting if necessary.
        r@r=s rrEz#DNSAuthenticator._setup_credentialsas
��
"�#�#r rF�validation_namerHc��t��)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
        r@�rrFrVrHs    rrJzDNSAuthenticator._performhs
��"�#�#r c��t��)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.
        r@rXs    rrSzDNSAuthenticator._cleanupus
��"�#�#r �key�labelc��|j|�}|s8|j|�}t|j|j	|�|�yy)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)r2�_prompt_for_data�setattrr�dest)rrZr[�configured_value�	new_values     r�
_configurezDNSAuthenticator._configure�sB�� �9�9�S�>����-�-�e�4�I��D�K�K����3���;� r �	validatorc	��|j|�}|ss|j||�}t|j|j	|�t
jjt
jj|���yy)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)	r2�_prompt_for_filer^rr_r�path�abspath�
expanduser)rrZr[rcr`ras      r�_configure_filez DNSAuthenticator._configure_file�sa�� �9�9�S�>����-�-�e�Y�?�I��D�K�K����3����������AS�AS�T]�A^�1_�`� r �required_variables�CredentialsConfigurationc������dtddf���fd�}�j|||�t�j|��j�}�r|j���r�|�|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.
        �filenamerNc�n��t|�j�}�r|j���r	�|�yyr8)rkr_�require)rm�applied_configurationrjrrcs  ���r�__validatorz<DNSAuthenticator._configure_credentials.<locals>.__validator�s7���$<�X�t�y�y�$Q�!�!�%�-�-�.@�A���/�0�r )�strrirkr2r_ro)rrZr[rjrc�_DNSAuthenticator__validator�credentials_configurations`  ``  r�_configure_credentialsz'DNSAuthenticator._configure_credentials�sg���(	1�#�	1�$�	1�	
���S�%��5�$<�T�Y�Y�s�^�T�Y�Y�$W�!��%�-�-�.@�A���/�0�(�(r c����dtddf�fd�}tj|dj��d��\}}|tj
k(r|St
jdj����)	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
        �irNc�R��|s$tjdj����y)NzPlease enter your {0}.)r
�PluginErrorr3)rwr[s �rrqz6DNSAuthenticator._prompt_for_data.<locals>.__validator�s(�����(�(�)A�)H�)H��)O�P�P�r zInput your {0}T��force_interactive�{0} required to proceed.)rrr�validated_inputr3rM�OKr
ry)r[rs�coderLs`   rr]z!DNSAuthenticator._prompt_for_data�ss���	Q�3�	Q�4�	Q��,�,���#�#�E�*�"�$���h�
�<�?�?�"��O�� � �!;�!B�!B�5�!I�J�Jr c�����dtddf��fd�}tj|dj��d��\}}|tj
k(r|St
jdj����)	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
        rmrNc���|s$tjdj����tjj|�}t
|��r	�|�yy)Nz&Please enter a valid path to your {0}.)r
ryr3rrfrh�
validate_file)rmr[rcs ��rrqz6DNSAuthenticator._prompt_for_file.<locals>.__validator�sP�����(�(�)Q�)X�)X�Y^�)_�`�`��w�w�)�)�(�3�H��(�#���(�#�r zInput the path to your {0}Trzr|)rrr�validated_directoryr3rMr~r
ry)r[rcrsrrLs``   rrez!DNSAuthenticator._prompt_for_file�sp���		$�#�		$�$�		$��0�0��(�/�/��6�"�$���h�
�<�?�?�"��O�� � �!;�!B�!B�5�!I�J�Jr )�
)rNr8)NN)(�__name__�
__module__�__qualname__�__doc__r�NamespaceConfigrrr�classmethodrr(r*rr�AnnotatedChallenger5rr	r
�	Challenger:r>rB�ChallengeResponserQrT�abc�abstractmethodrErJrSrbrrirru�staticmethodr]re�
__classcell__)rs@rrrs����+�&�}�<�<�&�C�&�D�&�
�@B�.�x�	�':�.�:=�.�GK�.��.�
��[�-K�-K�(L�
�QT�
�"�C�"�H�T�*�BV�BV�=W�4X�"�
�$�3�$��t�K�$B�$B�C���*�6�6�7��0J�t�K�$B�$B�C�J��J�	���$��$�	���
$�s�
$�S�
$� �
$�%)�
$��
$�	���$�s�$�S�$� �$�%)�$��$�<�c�<�#�<�$�<�"FJ�a�3�a�s�a�#+�H�c�U�D�[�,A�#B�a�NR�a�$W[�LP�&)��&)�"�&)�8@���c��AR�8S�&)��H�&@�%A�4�%G�H�I�&)�
$�&)�P�K��K��K��K�,�K��K���3�%��+�9N�0O�K�[^�K��Kr r)�	metaclassc��eZdZdZd�fdedeegefddfd�Zdeeefddfd	�Zd
ede	efd�Z
d
edefd�Zd
ede	efd
�Z
y)rkz>Represents a user-supplied filed which stores API credentials.c��|Sr8r<)�xs r�<lambda>z!CredentialsConfiguration.<lambda>s��q�r rm�mapperrNc��t|�	tj|�|_||_
y#tj$rC}t
j
d||d��tjdj||���d}~wwxYw)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�	configobj�	ConfigObj�confobj�ConfigObjError�logger�debugr
ryr3r�)rrmr��es    rrz!CredentialsConfiguration.__init__s���	"�(�+�	�$�.�.�x�8�D�L������'�'�	��L�L�B����	
�
��$�$�B�I�I�����
��	�s�/�B�>B�Brjc	���g}|D]�}|j|�s4|jdj|j|�||���H|j	|�r�Z|jdj|j|�||����|rYtjdjt|�dk(rdnd|jjdj|����y)	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-�property�
propertiesz
 * N)�_hasrKr3r��_getr
ry�lenr�rm�join)rrj�messages�vars    rroz CredentialsConfiguration.require"s�����%�	T�C��9�9�S�>���� K�!'�����C�(8�:L�S�:Q�!R�T��Y�Y�s�^���� I�!'�����C�(8�:L�S�:Q�!R�T�	T���$�$�L�S�S�&)�(�m�q�&8�
�l����-�-����X�.���
�r r�c�$�|j|�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�s  rr2zCredentialsConfiguration.conf;s���y�y��~�r c�<�|j|�|jvSr8)r�r�r�s  rr�zCredentialsConfiguration._hasEs���{�{�3��4�<�<�/�/r c�V�|jj|j|��Sr8)r��getr�r�s  rr�zCredentialsConfiguration._getHs ���|�|������C� 0�1�1r )r�r�r�r�rrrrrrorr2�boolr�r�r<r rrkrks���H�EP����h��u�c�z�.B��UY��4�'�#�s�(�*;����2�����
��0��0��0�2��2���
�2r rkrmrc��tjj|�s$tjdj|���tjj
|�r$tjdj|���y)z&Ensure that the specified file exists.zFile not found: {0}zPath is a directory: {0}N)rrf�existsr
ryr3�isdir�rms rr�r�Lsc���7�7�>�>�(�#�� � �!6�!=�!=�h�!G�H�H�	�w�w�}�}�X��� � �!;�!B�!B�8�!L�M�M�r c�r�t|�tj|�rtj	d|�yy)zHEnsure that the specified file exists and warn about unsafe permissions.z8Unsafe permissions on credentials configuration file: %sN)r�r�has_world_permissionsr��warningr�s rr�r�Vs/���(���'�'��1����Q�S[�\�2r rFc��|jd�}tdt|��D�cgc]}dj||d���c}Scc}w)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
    �.rN)�split�ranger�r�)rF�	fragmentsrws   r�base_domain_name_guessesr�_s@�����S�!�I�-2�1�c�)�n�-E�F��C�H�H�Y�q�r�]�#�F�F��Fs�A))r�r��logging�timer�typingrrrrrr	r��acmer
�certbotrrr
r�certbot.compatrr�certbot.displayrrrM�certbot.pluginsr�	getLoggerr�r��Plugin�
Authenticator�ABCMetarrkrrr�r�r�r<r r�<module>r�s���0�
������������!���%���0�"�	��	�	�8�	$��fK�v�}�}�j�&>�&>�#�+�+�fK�RD2�D2�NN�C�N�D�N�]��]��]�G�S�G�T�#�Y�Gr 

Zerion Mini Shell 1.0