%PDF- %PDF-
Mini Shell

Mini Shell

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

�

M/�e�)���UdZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlm
Z
ddlmZdd
lmZdd	lm
Zej(e�Zdej.ddfd�Zdedeefd�Zdededdfd�Zdej.ddfd�Ze�Zeeed<deddfd�Z dej.deeddfd�Z!gZ"eeed<deddfd�Z#deedeeddfd�Z$dej.deed eddfd!�Z%dej.deed eddfd"�Z&dedeed ed#e'd$e'ddfd%�Z(d+d&eded'eeeefdefd(�Z)d)edeefd*�Z*y),z;Facilities for implementing hooks that call shell commands.�N)�Dict)�List)�Optional)�Set)�
configuration)�errors)�util)�
filesystem)�misc)�os)�ops�config�returnc��t|jd�t|jd�t|jd�t|jd�y)z#Check hook commands are executable.�pre�post�deploy�renewN)�
validate_hook�pre_hook�	post_hook�deploy_hook�
renew_hook)rs �9/usr/lib/python3/dist-packages/certbot/_internal/hooks.py�validate_hooksrs@���&�/�/�5�)��&�"�"�F�+��&�$�$�h�/��&�#�#�W�-��	shell_cmdc��tj|�s+tj|�tj|�sytj
j
|�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$sB���?�?�9�%����y�)����y�)��
�7�7���I�&�&r�	hook_namec��|r}|jdd�d}t|�s\tjd}tjj|�r	|�d|�d�}nd|�d|�d|�d	�}t
j|��yy)
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 z0)
See also the --disable-hook-validation option.)�splitr$r�environr"�existsr�HookCommandNotFound)rr%�cmdr"�msgs     rrr.s���
��o�o�d�A�&�q�)���S�z��:�:�f�%�D��w�w�~�~�c�"���^�I�;�6U�V��&�i�[��s�e�C[��f�M�O��
�,�,�S�1�1��rc��|jdk(r1|jr%t|j�D]
}t	|��|j
}|rt	|�yy)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   rrrBsU���{�{�g��&�"8�"8��v�;�;�<�	-�D�&�t�,�	-��/�/�C�
�"�3�'�r�executed_pre_hooks�commandc��|tvrtjd|�ytd|�tj	|�y)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 rr4r4Zs4���$�$����@�'�J��*�g�&����w�'r�renewed_domainsc�R�|j}|jdk(r@|jr%t|j�D]
}t|��|rt|�yy|rJdj
|�}t|�dkDrtjd�|dd}td||dd��yy)	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� i}z?Limiting RENEWED_DOMAINS environment variable to 32k charactersN�	post-hook���RENEWED_DOMAINS�FAILED_DOMAINS)rr0r1r2�renewal_post_hooks_dir�_run_eventually�join�lenr9�warningr;)rr>r-r5�renewed_domains_strs     rrrjs���,�
�
�C�
�{�{�g���!�!�"�6�#@�#@�A�
&����%�
&���C� ��

�!�h�h��7���"�#�f�,��N�N�\�]�"5�g�v�">�����#6�#%�	
�		
�

r�
post_hooksc�@�|tvrtj|�yy)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)rL�appendr=s rrGrG�s���j� ����'�"�!r�failed_domainsc��dj|�}dj|�}t|�dkDrtjd�|dd}t|�dkDrtjd�|dd}tD]}td|||d���y)zGRun any post hooks that were saved up in the course of the 'renew' verbr@i�>z?Limiting RENEWED_DOMAINS environment variable to 16k charactersNz>Limiting FAILED_DOMAINS environment variable to 16k charactersrArC)rHrIr9rJrLr;)r>rOrK�failed_domains_strr-s     r�run_saved_post_hooksrR�s����(�(�?�3�����.�1�����&�(����X�Y�1�'�6�:��
����'����W�X�0��&�9���
�����#6�"4�
�	
�
r�domains�lineage_pathc�x�|jr.t|j|||j|j�yy)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�run_deploy_hooks)rrSrTs   rrr�s6�������+�+�W�%�v�~�~�v�7N�7N�	P�rc��t�}|jrNt|j�D]6}t	||||j
|j�|j|��8|jr]|j|vr!tjd|j�yt	|j|||j
|j�yy)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_dirrVrWrXr<rr9r:)rrSrT�executed_dir_hooksr5s     rrr�s���$���
����v�>�>�?�	)�D��T�7�L�&�.�.�&�Ja�Ja�b��"�"�4�(�	)������� 2�2��K�K�J��)�)�
+�
�V�.�.��)�6�>�>�6�;R�;R�
T�rrWrXc��|r|stjd|�ydj|�tjd<|tjd<td|�y)atRun 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
    :param bool run_deploy_hooks: True if deploy hooks should run despite Certbot doing a dry run

    z)Dry run: skipping deploy hook command: %sNr@rD�RENEWED_LINEAGEzdeploy-hook)r9r:rHrr*r;)r7rSrTrWrXs     rrVrV�sP�� �'����?��	 ��$'�H�H�W�$5�B�J�J� �!�$0�B�J�J� �!�
�m�W�%r�cmd_name�	extra_envc���tj�}|j|xsi�tj|||��\}}}tjd|�d�|||�|S)aHRun 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`
    :param dict extra_env: extra environment variables to set
    :type extra_env: `dict` of `str` to `str`

    :returns: stderr if there was any)�envzHook '�')r	�env_no_snap_for_external_calls�updater�execute_command_status�display_ops�report_executed_command)r_rr`rb�
returncode�err�outs       rr;r;sb���
-�
-�
/�C��J�J�y��B���6�6��)��&��J��S��'�'�&��
�!�(<�j�#�s�S��Jr�dir_pathc�����fd�tj��D�}|D�cgc],}tj|�s�|j	d�r�+|��.}}t|�Scc}w)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�^�K�|]$}tjj�|����&y�w�N)rr"rH)�.0�frls  �r�	<genexpr>zlist_hooks.<locals>.<genexpr>+s �����H�a������X�q�)�H�s�*-�~)r�listdirr
�
is_executable�endswith�sorted)rl�allpathsr"�hookss`   rr2r2"sX���I�2�:�:�h�3G�H�H�&�d�d�*�*B�*B�4�*H�QU�Q^�Q^�_b�Qc�T�d�E�d��%�=���
es�A"�A"�A"ro)+�__doc__�logging�typingrrrr�certbotrrr	�certbot.compatr
rr�certbot.displayr
rg�certbot.pluginsr �	getLogger�__name__r9�NamespaceConfigr�strr$rrrZr6�__annotations__r4rrLrGrRrr�boolrVr;r2�rr�<module>r�s��A������!���%���.�-�	��	�	�8�	$��.�=�8�8�.�T�.�'�S�'�X�c�]�'�"2�S�2�S�2�T�2�((�]�2�2�(�t�(�* #�u��C��H�$�
(��
(��
(� /
��)�)�/
��#�Y�/
�
�/
�d�
�D��I��
#�S�
#�T�
#�
�$�s�)�
�T�#�Y�
�SW�
�4P�
�5�5�P��S�	�P�!�P�&*�P�T�}�4�4�T�t�C�y�T� �T�%)�T�B&�c�&�D��I�&�S�&�SW�&�'+�&�04�&�4�������c�3�h��8P��\_��$����c��r

Zerion Mini Shell 1.0