HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/certbot/_internal/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/certbot/_internal/__pycache__/hooks.cpython-311.pyc
�

E��c�!�
�V�UdZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	l
mZdd
l
mZddl
m
Z
ddlmZddlm	Zeje��Zd
ejddfd�Zdedeefd�Zdededdfd�Zd
ejddfd�Ze��Zeeed<deddfd�Zd
ejddfd�Z gZ!eeed<deddfd�Z"d&d�Z#d
ejdeededdfd�Z$d
ejdeededdfd�Z%dedeeded e&ddf
d!�Z'd"ededefd#�Z(d$edeefd%�Z)dS)'z;Facilities for implementing hooks that call shell commands.�N)�List)�Optional)�Set)�
configuration)�errors)�util)�
filesystem)�misc)�os)�ops�config�returnc��t|jd��t|jd��t|jd��t|jd��dS)z#Check hook commands are executable.�pre�post�deploy�renewN)�
validate_hook�pre_hook�	post_hook�deploy_hook�
renew_hook)r
s �9/usr/lib/python3/dist-packages/certbot/_internal/hooks.py�validate_hooksrsS���&�/�5�)�)�)��&�"�F�+�+�+��&�$�h�/�/�/��&�#�W�-�-�-�-�-��	shell_cmdc��tj|��s*tj|��tj|��sdStj�|��S)z�Extract the program run by a shell command.

    :param str shell_cmd: command to be executed

    :returns: basename of command or None if the command isn't found
    :rtype: str or None

    N)r�
exe_exists�	plug_util�path_surgeryr�path�basename)rs r�_progr#sT���?�9�%�%����y�)�)�)���y�)�)�	��4�
�7���I�&�&�&r�	hook_namec��|r�|�dd��d}t|��s\tjd}tj�|��r	|�d|�d�}nd|�d|�d|�d	�}t
j|���dSdS)
z�Check that a command provided as a hook is plausibly executable.

    :raises .errors.HookCommandNotFound: if the command is not found
    N�r�PATHz-hook command z exists, but is not executable.zUnable to find z in the PATH.
(PATH is �))�splitr#r�environr!�existsr�HookCommandNotFound)rr$�cmdr!�msgs     rrr-s���
�2��o�o�d�A�&�&�q�)���S�z�z�		2��:�f�%�D��w�~�~�c�"�"�
��V�V�I�V�V�V���d�i�c�c�s�c�c�\`�c�c�c���,�S�1�1�1�2�2�		2�		2rc��|jdkr-|jr&t|j��D]}t	|���|j}|rt	|��dSdS)a�Run pre-hooks if they exist and haven't already been run.

    When Certbot is running with the renew subcommand, this function
    runs any hooks found in the config.renewal_pre_hooks_dir (if they
    have not already been run) followed by any pre-hook in the config.
    If hooks in config.renewal_pre_hooks_dir are run and the pre-hook in
    the config is a path to one of these scripts, it is not run twice.

    :param configuration.NamespaceConfig config: Certbot settings

    rN)�verb�directory_hooks�
list_hooks�renewal_pre_hooks_dir�_run_pre_hook_if_necessaryr)r
�hookr-s   rrr@sq���{�g���&�"8���v�;�<�<�	-�	-�D�&�t�,�,�,�,�
�/�C�
�(�"�3�'�'�'�'�'�(�(r�executed_pre_hooks�commandc��|tvrt�d|��dStd|��t�|��dS)z�Run the specified pre-hook if we haven't already.

    If we've already run this exact command before, a message is logged
    saying the pre-hook was skipped.

    :param str command: pre-hook to be run

    z*Pre-hook command already run, skipping: %szpre-hookN)r6�logger�info�	_run_hook�add�r7s rr4r4XsU���$�$�$����@�'�J�J�J�J�J��*�g�&�&�&����w�'�'�'�'�'rc���|j}|jdkrB|jr&t|j��D]}t|���|rt|��dSdS|rt
d|��dSdS)a�Run post-hooks if defined.

    This function also registers any executables found in
    config.renewal_post_hooks_dir to be run when Certbot is used with
    the renew subcommand.

    If the verb is renew, we delay executing any post-hooks until
    :func:`run_saved_post_hooks` is called. In this case, this function
    registers all hooks found in config.renewal_post_hooks_dir to be
    called followed by any post-hook in the config. If the post-hook in
    the config is a path to an executable in the post-hook directory, it
    is not scheduled to be run twice.

    :param configuration.NamespaceConfig config: Certbot settings

    r�	post-hookN)rr0r1r2�renewal_post_hooks_dir�_run_eventuallyr;)r
r-r5s   rrrhs���$�
�C�
�{�g����!�	&�"�6�#@�A�A�
&�
&����%�%�%�%��	!��C� � � � � �	!�	!�

�$��+�s�#�#�#�#�#�$�$r�
post_hooksc�P�|tvrt�|��dSdS)z�Registers a post-hook to be run eventually.

    All commands given to this function will be run exactly once in the
    order they were given when :func:`run_saved_post_hooks` is called.

    :param str command: post-hook to register to be run

    N)rB�appendr=s rrArA�s1���j� � ����'�"�"�"�"�"�!� rc�:�tD]}td|���dS)zGRun any post hooks that were saved up in the course of the 'renew' verbr?N)rBr;)r-s r�run_saved_post_hooksrF�s.���$�$���+�s�#�#�#�#�$�$r�domains�lineage_pathc�P�|jrt|j|||j��dSdS)aRun post-issuance hook if defined.

    :param configuration.NamespaceConfig config: Certbot settings
    :param domains: domains in the obtained certificate
    :type domains: `list` of `str`
    :param str lineage_path: live directory path for the new cert

    N)r�_run_deploy_hook�dry_run)r
rGrHs   rrr�sC����7���+�W�%�v�~�	7�	7�	7�	7�	7�7�7rc�V�t��}|jrCt|j��D].}t	||||j��|�|���/|jrI|j|vr"t�	d|j��dSt	|j|||j��dSdS)a]Run post-renewal hooks.

    This function runs any hooks found in
    config.renewal_deploy_hooks_dir followed by any renew-hook in the
    config. If the renew-hook in the config is a path to a script in
    config.renewal_deploy_hooks_dir, it is not run twice.

    If Certbot is doing a dry run, no hooks are run and messages are
    logged saying that they were skipped.

    :param configuration.NamespaceConfig config: Certbot settings
    :param domains: domains in the obtained certificate
    :type domains: `list` of `str`
    :param str lineage_path: live directory path for the new cert

    z0Skipping deploy-hook '%s' as it was already run.N)
�setr1r2�renewal_deploy_hooks_dirrJrKr<rr9r:)r
rGrH�executed_dir_hooksr5s     rrr�s���$����
��)��v�>�?�?�	)�	)�D��T�7�L�&�.�I�I�I��"�"�4�(�(�(�(�
��;��� 2�2�2��K�K�J��)�
+�
+�
+�
+�
+�
�V�.��)�6�>�
;�
;�
;�
;�
;�;�;rrKc���|rt�d|��dSd�|��tjd<|tjd<td|��dS)aRun the specified deploy-hook (if not doing a dry run).

    If dry_run is True, command is not run and a message is logged
    saying that it was skipped. If dry_run is False, the hook is run
    after setting the appropriate environment variables.

    :param str command: command to run as a deploy-hook
    :param domains: domains in the obtained certificate
    :type domains: `list` of `str`
    :param str lineage_path: live directory path for the new cert
    :param bool dry_run: True iff Certbot is doing a dry run

    z)Dry run: skipping deploy hook command: %sN� �RENEWED_DOMAINS�RENEWED_LINEAGEzdeploy-hook)r9r:�joinrr*r;)r7rGrHrKs    rrJrJ�si�������?��	 �	 �	 ���$'�H�H�W�$5�$5�B�J� �!�$0�B�J� �!�
�m�W�%�%�%�%�%r�cmd_namec��tj||tj�����\}}}t	jd|�d�|||��|S)z�Run a hook command.

    :param str cmd_name: the user facing name of the hook being run
    :param shell_cmd: shell command to execute
    :type shell_cmd: `list` of `str` or `str`

    :returns: stderr if there was any)�envzHook '�')r
�execute_command_statusr�env_no_snap_for_external_calls�display_ops�report_executed_command)rUr�
returncode�err�outs     rr;r;�s]�� �6��)��!D�!F�!F�H�H�H��J��S��'�(<��(<�(<�(<�j�#�s�S�S�S��Jr�dir_pathc�z���fd�tj���D��}d�|D��}t|��S)z�List paths to all hooks found in dir_path in sorted order.

    :param str dir_path: directory to search

    :returns: `list` of `str`
    :rtype: sorted list of absolute paths to executables in dir_path

    c3�X�K�|]$}tj��|��V��%dS)N)rr!rT)�.0�fr`s  �r�	<genexpr>zlist_hooks.<locals>.<genexpr>�s3�����H�H�a�����X�q�)�)�H�H�H�H�H�Hrc�d�g|]-}tj|���|�d���+|��.S)�~)r	�
is_executable�endswith)rcr!s  r�
<listcomp>zlist_hooks.<locals>.<listcomp>�s=��d�d�d�d�*�*B�4�*H�*H�d�QU�Q^�Q^�_b�Qc�Qc�d�T�d�d�dr)r�listdir�sorted)r`�allpaths�hookss`  rr2r2�sH���I�H�H�H�2�:�h�3G�3G�H�H�H�H�d�d�h�d�d�d�E��%�=�=�r)rN)*�__doc__�logging�typingrrr�certbotrrr�certbot.compatr	r
r�certbot.displayrr[�certbot.pluginsr�	getLogger�__name__r9�NamespaceConfigr�strr#rrrMr6�__annotations__r4rrBrArFrr�boolrJr;r2�rr�<module>r}sA��A�A�A�����������������������!�!�!�!�!�!�������������%�%�%�%�%�%�������������.�.�.�.�.�.�-�-�-�-�-�-�	��	�8�	$�	$��.�=�8�.�T�.�.�.�.�'�S�'�X�c�]�'�'�'�'�"2�S�2�S�2�T�2�2�2�2�&(�]�2�(�t�(�(�(�(�* #�s�u�u��C��H�$�$�$�
(��
(��
(�
(�
(�
(� $�m�3�$��$�$�$�$�>�
�D��I����
#�S�
#�T�
#�
#�
#�
#�$�$�$�$�7�
�5�7��S�	�7�!�7�&*�7�7�7�7�;�}�4�;�t�C�y�;� �;�%)�;�;�;�;�B&�c�&�D��I�&�S�&�SW�&�\`�&�&�&�&�0��������������c�������r