%PDF- %PDF-
Mini Shell

Mini Shell

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

�

M/�euD�
��dZddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z$ddl"m%Z&ddl'm(Z(ejRdk\rddl*m+Z,nddl,Z,ejZe.�Z/de0de0fd�Z1de0de0fd�Z2ejfd �Z4ejfd!ejj�Z6Gd"�d#e&e�$�Z%Gd%�d&e$e%e�$�Z#Gd'�d(e#ejne�$�Z8ed)d*�+�Z9Gd,�d*�Z:Gd-�d.�Z;d/e0d0e0d1e0d2e
e0ddf
d3�Z<d4e0d5e0dee0e0e0ffd6�Z=y)7zPlugin 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�returnc��|dzS)�9ArgumentParser options namespace (prefix of all options).�-��rs �8/usr/lib/python3/dist-packages/certbot/plugins/common.py�option_namespacer%*s���#�:��c�,�|jdd�dzS)�;ArgumentParser dest namespace (prefix of all destinations).r!�_)�replacer#s r$�dest_namespacer+/s���<�<��S�!�C�'�'r&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]+$c�&��eZdZdZdej
deddf�fd�Zee	de
dddfd	���Zed
ejdeddfd��Zedefd��Zdedefd
�Zedefd��Zdedefd�Zdedefd�Zdeej0defd�Z�xZS)rzGeneric plugin.�configrrNc�B��t�|�||�||_||_y�N)�super�__init__r-r)�selfr-r�	__class__s   �r$r1zPlugin.__init__>s ���
�����&������	r&�add).Nc��y)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")�clsr4s  r$�add_parser_argumentszPlugin.add_parser_argumentsCs�r&�parserc�^���dtdtdtddf��fd�}|j|�S)zkInject parser options.

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

        �arg_name_no_prefix�args�kwargsrNc�d���jdjt��|�g|��i|��y)Nz--{0}{1})�add_argument�formatr%)r:r;r<rr8s   ��r$r4z)Plugin.inject_parser_options.<locals>.addVs:����F����!�!�"2�4�"8�:L�M�
!��
!��
!r&)�strrr7)r6r8rr4s `` r$�inject_parser_optionszPlugin.inject_parser_optionsNs7���	!�C�	!��	!�s�	!�t�	!��'�'��,�,r&c�,�t|j�S)r )r%r�r2s r$r%zPlugin.option_namespace\s�� ��	�	�*�*r&c� �|j|zS)z'Option name (include plugin namespace).)r%)r2rs  r$�option_namezPlugin.option_nameas���$�$�t�+�+r&c�,�t|j�S)r()r+rrCs r$r+zPlugin.dest_namespacees���d�i�i�(�(r&�varc�@�|j|jdd�zS)z.Find a destination for given variable ``var``.r!r))r+r*�r2rGs  r$�destzPlugin.destjs ���"�"�S�[�[��c�%:�:�:r&c�L�t|j|j|��S)z0Find a configuration value for variable ``var``.)�getattrr-rJrIs  r$�confzPlugin.confps���t�{�{�D�I�I�c�N�3�3r&�failed_achallsc��djt|D�chc]}|j��c}��}dj|j|��Scc}w)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 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�sorted�typr?r)r2rN�achallrPs    r$�	auth_hintzPlugin.auth_hinttsK��(���f�~�%N�V�f�j�j�%N�O�P��\���T�Y�Y�v��6�	8��&Os�A)�__name__�
__module__�__qualname__�__doc__r�NamespaceConfigr@r1�classmethodrrr7�argparse�ArgumentParserrA�propertyr%rEr+rJrrMrr�AnnotatedChallengerU�
__classcell__�r3s@r$rr;s�����}�<�<��C��D��
���x�	�':��t������-�8�+B�+B�-�#�-�RV�-��-��+�#�+��+�,��,��,��)��)��)�;��;��;�4��4��4�8��[�-K�-K�(L�8�QT�8r&r)�	metaclassc	���eZdZdZdededdf�fd�Z	ddeeded	eddfd
�Z	deddfd�Z
dd
�Zdd�Zdde
ddfd�Zedefd��Zedefd��Zdd�Z�xZS)rz�An installer base class with reverter and ssl_dhparam methods defined.

    Installer plugins do not have to inherit from this class.

    r;r<rNc���t�|�|i|��t|j|j�|_t
j|j�|_yr/)r0r1rr-r�storager�Reverter)r2r;r<r3s   �r$r1zInstaller.__init__�sA���
���$�)�&�)�$�T�[�[�$�)�)�<��� �)�)�$�+�+�6��
r&�
save_files�
save_notes�	temporaryc���|r|jj}n|jj}	|||�y#tj$r#}tj
t
|���d}~wwxYw)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)r�add_to_temp_checkpoint�add_to_checkpointr�
ReverterError�PluginErrorr@)r2rgrhri�checkpoint_func�errs      r$rlzInstaller.add_to_checkpoint�s_���"�m�m�B�B�O�"�m�m�=�=�O�	/��J�
�3���#�#�	/��$�$�S��X�.�.��	/�s�	;�A1�A,�,A1�titlec��	|jj|�y#tj$r#}tjt|���d}~wwxYw)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_checkpointrrmrnr@)r2rqrps   r$rszInstaller.finalize_checkpoint�sD��	/��M�M�-�-�e�4���#�#�	/��$�$�S��X�.�.��	/����A�A�Ac��	|jj�y#tj$r#}tjt|���d}~wwxYw)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_routinerrmrnr@�r2rps  r$rvzInstaller.recovery_routine�sB��	/��M�M�*�*�,���#�#�	/��$�$�S��X�.�.��	/����A�A�Ac��	|jj�y#tj$r#}tjt|���d}~wwxYw)zkRollback temporary checkpoint.

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

        N)r�revert_temporary_configrrmrnr@rws  r$rzz!Installer.revert_temporary_config�sB��	/��M�M�1�1�3���#�#�	/��$�$�S��X�.�.��	/�rx�rollbackc��	|jj|�y#tj$r#}tjt|���d}~wwxYw)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_checkpointsrrmrnr@)r2r{rps   r$r}zInstaller.rollback_checkpoints�sD��	/��M�M�.�.�x�8���#�#�	/��$�$�S��X�.�.��	/�rtc��tjj|jjt
j�S)z(Full absolute path to ssl_dhparams file.)r�pathrQr-�
config_dirr�SSL_DHPARAMS_DESTrCs r$�ssl_dhparamszInstaller.ssl_dhparams�s)���w�w�|�|�D�K�K�2�2�I�4O�4O�P�Pr&c��tjj|jjt
j�S)z:Full absolute path to digest of updated ssl_dhparams file.)rrrQr-r�r�UPDATED_SSL_DHPARAMS_DIGESTrCs r$�updated_ssl_dhparams_digestz%Installer.updated_ssl_dhparams_digest�s)���w�w�|�|�D�K�K�2�2�I�4Y�4Y�Z�Zr&c��t|j|jtjtj
�y)zJCopy Certbot's ssl_dhparams file into the system's config dir if required.N)�install_version_controlled_filer�r�r�SSL_DHPARAMS_SRC�ALL_SSL_DHPARAMS_HASHESrCs r$�install_ssl_dhparamszInstaller.install_ssl_dhparams�s.��'�����,�,��&�&��-�-�		/r&�F�rN)�)rVrWrXrYrr1r
r@�boolrlrsrvrz�intr}r^r�r�r�r`ras@r$rr�s�����
7�c�7�S�7�T�7�-2�/�C��H�/�#�/�%)�/�6:�/�./��/��/�/�	/�/�S�/��/��Q�c�Q��Q��[�S�[��[�/r&rc��eZdZdZy)�Configuratorzt
    A plugin that extends certbot.plugins.common.Installer
    and implements certbot.interfaces.Authenticator
    N)rVrWrXrYr"r&r$r�r��s��r&r��GenericAddr�Addr)�boundc��eZdZdZddeeefdefd�Zede	e
dedee
fd��Zdefd	�Z
deeeffd
�Zdedefd�Zdefd
�Zdefd�Zdefd�Zde
dede
fd�Zdedeefd�Zdefd�Zdedeefd�Zy)r�z�Represents an virtual host address.

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

    �tup�ipv6c� �||_||_yr/)r�r�)r2r�r�s   r$r1z
Addr.__init__s�������	r&r6�str_addrrc��|jd�rK|jd�}|d|dz}d}t|�|dzkDr||dzdk(r||dzd}|||fd�	�S|jd�}||d
|df�S)zInitialize Addr from string.�[�]Nr����:T)r�r)�
startswith�rfind�len�	partition)r6r��endIndex�host�portr�s      r$�
fromstringzAddr.fromstrings������s�#��~�~�c�*�H��M�X��\�*�D��D��8�}�x�!�|�+���A��0F�#�0M���1��
�.����d�|�$�/�/��$�$�S�)�C���A���A��'�(�(r&c�\�|jdrd|jzS|jdS)Nr�z%s:%sr�r�rCs r$�__str__zAddr.__str__s*���8�8�A�;��T�X�X�%�%��x�x��{�r&c�p�|jr|j�|jdfS|jS)z5Normalized representation of addr/port tuple
        r�)r��get_ipv6_explodedr�rCs r$�normalized_tuplezAddr.normalized_tuple s0���9�9��)�)�+�T�X�X�a�[�8�8��x�x�r&�otherc�r�t||j�r!|j�|j�k(Sy)NF)�
isinstancer3r�)r2r�s  r$�__eq__zAddr.__eq__'s2���e�T�^�^�,��(�(�*�e�.D�.D�.F�F�F�r&c�,�t|j�Sr/)�hashr�rCs r$�__hash__z
Addr.__hash__/s���D�H�H�~�r&c� �|jdS)z Return addr part of Addr object.rr�rCs r$�get_addrz
Addr.get_addr2����x�x��{�r&c� �|jdS)zReturn port.r�r�rCs r$�get_portz
Addr.get_port6r�r&r2r�c�X�|j|jd|f|j�S)z6Return new address object with same addr and new port.r)r3r�r�)r2r�s  r$�get_addr_objzAddr.get_addr_obj:s$���~�~�t�x�x��{�D�1�4�9�9�=�=r&�addrc�h�|jd�}|jd�}|j|�S)z7Return IPv6 address in normalized form, helper functionr�r�)�lstrip�rstrip�
_explode_ipv6)r2r�s  r$�_normalize_ipv6zAddr._normalize_ipv6>s/���{�{�3����{�{�3����!�!�$�'�'r&c�v�|jr-dj|j|jd��Sy)zReturn IPv6 in normalized formr�rr�)r�rQr�r�rCs r$r�zAddr.get_ipv6_explodedDs.���9�9��8�8�D�0�0����!��=�>�>�r&c�B�gd�}|jd�}t|�t|�kDr|dt|�}d}t|�D]T\}}|sd}�t|�dkDr|jd�}|st	|�||<�;t	|�||t|�z
<�V|S)z#Explode IPv6 address for comparison)�0r�r�r�r�r�r�r�r�rFTr�r�)�splitr��	enumerater�r@)r2r��result�	addr_list�
append_to_end�i�blocks       r$r�zAddr._explode_ipv6Js���9���J�J�s�O�	��y�>�C��K�'�!�!�C��K�0�I��
�!�)�,�
	6�H�A�u��!%�
���5�z�A�~����S�)�� ���J��q�	�,/�u�:��q��Y��'�(�
	6��
r&Nr�)rVrWrXrYrr@r�r1r[rr�r	r�r�r�rr�r�r�r�r�r�rr�r�r�r"r&r$r�r�s����E�#�s�(�O��4���)��[�)�)�S�)�X�k�=R�)��)����
�%��S��/���C��D���#���#���#��>�;�>�c�>�k�>�(�C�(�D��I�(��3���#��$�s�)�r&c�t�eZdZdZdefd�Z	d
dejdee	ddfd�Z
deejfd	�Zy)�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`

    �configuratorc�.�||_g|_g|_yr/)r��achalls�indices)r2r�s  r$r1zChallengePerformer.__init__os��(���MO���"$��r&NrT�idxrc�v�|jj|�|�|jj|�yy)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�)r2rTr�s   r$�	add_challzChallengePerformer.add_challts2��	
�����F�#��?��L�L����$�r&c��t��)z�Perform all added challenges.

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


        )�NotImplementedErrorrCs r$�performzChallengePerformer.perform�s
��"�#�#r&r/)rVrWrXrYr�r1r�"KeyAuthorizationAnnotatedChallenger	r�r�rr�!KeyAuthorizationChallengeResponser�r"r&r$r�r�csU��	�%�\�%�(,�%�� N� N�%���}�%�04�%�$��j�J�J�K�$r&r��	dest_path�digest_path�src_path�
all_hashesc�������	�tj���	d�	�fd��d���fd�}tjj	��s|�ytj��}|�	k(ry||vr|�ytjj	��r+t�d�5}|j
�}ddd��	k(ry��tjd����y#1swY�/xYw)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
    Nc�j��t�d�5}|j��ddd�y#1swYyxYw)N�w)�open�write)�file_h�current_hashr�s ��r$�_write_current_hashz<install_version_controlled_file.<locals>._write_current_hash�s0���
�+�s�
#�	'�v��L�L��&�	'�	'�	'�s�)�2c�@��tj�����yr/)�shutil�copyfile)r�r�r�s���r$�_install_current_filez>install_version_controlled_file.<locals>._install_current_file�s�������)�,��r&�rzh%s has been manually modified; updated file saved to %s. We recommend updating %s for security purposes.r�)	r�	sha256sumrr�isfiler��read�logger�warning)
r�r�r�r�r��active_file_digest�f�saved_digestr�r�s
```     @@r$r�r��s�����(�(��2�L�'��
�7�7�>�>�)�$����%�.�.�y�9���\�)���Z�'����7�7�>�>�+�&��k�3�'�
(�1� �v�v�x��
(��|�+��	�����K��x��	,�
(�
(�s�#C"�"C+�test_dir�pkgc�Z�dtdtfd�}|d�}|d�}|d�}tj|tj�tj|tj�tj|tj�tj|�jd�j|�}tj|�5}tj|tjj||�d�	�d
d
d
�|||fS#1swY�xYw)z5Setup the directories necessary for the configurator.�prefixrc�R�tjtj|��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�tempfile�mkdtemp)r�s r$�expanded_tempdirz#dir_setup.<locals>.expanded_tempdir�s ���"�"�8�#3�#3�F�#;�<�<r&�tempr-�work�testdataT)�symlinksN)r@r�chmodr�CONFIG_DIRS_MODE�importlib_resources�files�joinpath�as_filer��copytreerrrQ)r�r�r��temp_dirr��work_dir�test_dir_refrs        r$�	dir_setupr�s���	=��	=��	=� ��'�H�!�(�+�J���'�H����X�y�9�9�:����Z��!;�!;�<����X�y�9�9�:�&�,�,�S�1�:�:�:�F�O�O�PX�Y�L�	�	$�	$�\�	2�C�d�����"�'�'�,�,�x��2�T�	C�C��Z��)�)�	C�C�s�7D!�!D*)>rY�abcrrr\�logging�rer��sysr��typingrrrrr	r
rrr
�acmer�certbotrrrrrr�certbot._internalr�certbot.compatrr�certbot.interfacesr�AbstractInstallerr�AbstractPlugin�certbot.plugins.storager�version_info�importlib.resources�	resourcesr�	getLoggerrVr�r@r%r+�compile�private_ips_regex�
IGNORECASE�hostname_regex�
Authenticatorr�r�r�r�r�rr"r&r$�<module>r"s��������	�
�
�������������!�����'�%��=�7�1����v��5��	��	�	�8�	$���3��3��
(��(��(�
�B�J�J�7�8������:�B�M�M�K��Q8�^�w�Q8�he/�!�6�W�e/�P�9�j�6�6�'���m�6�2��_�_�D&$�&$�R,,�s�,,��,,�PS�,,�08��
�,,�BF�,,�f*��*�#�*�%��S�#�
�*>�*r&

Zerion Mini Shell 1.0