AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/certbot/_internal/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/certbot/_internal/__pycache__/hooks.cpython-310.pyc
o

6��a��@sUdZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lm
ZddlmZe�e�Zdd�Zd
d�Zdd�Zdd�Ze�Zeeed<dd�Zdd�ZgZeeed<dd�Zdd�Z dd�Z!dd �Z"d!d"�Z#d#d$�Z$d%d&�Z%dS)'z;Facilities for implementing hooks that call shell commands.�N)�List)�Set)�errors)�util)�
filesystem)�misc)�os)�opscCs4t|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)�config�r�9/usr/lib/python3/dist-packages/certbot/_internal/hooks.py�validate_hookssrcCs.t�|�st�|�t�|�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)�	shell_cmdrrr�_progs

	

rcCs`|r,|�dd�d}t|�s.tjd}tj�|�r d�||�}nd�|||�}t�|��dSdS)z�Check that a command provided as a hook is plausibly executable.

    :raises .errors.HookCommandNotFound: if the command is not found
    N�r�PATHz3{1}-hook command {0} exists, but is not executable.z>Unable to find {2}-hook command {0} in the PATH.
(PATH is {1}))	�splitrr�environr�exists�formatr�HookCommandNotFound)r�	hook_name�cmdr�msgrrrr*s
�
�rcCsB|jdkr|jrt|j�D]}t|�q
|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

    r
N)�verb�directory_hooks�
list_hooks�renewal_pre_hooks_dir�_run_pre_hook_if_necessaryr)r�hookr&rrrr<s
�r�executed_pre_hookscCs0|tvrt�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)r.�logger�info�	_run_hook�add��commandrrrr,Ts	
r,cCsX|j}|jdkr!|jrt|j�D]}t|�q|rt|�dSdS|r*td|�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)rr(r)r*�renewal_post_hooks_dir�_run_eventuallyr1)rr&r-rrrrds

��r�
post_hookscCs|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)r8�appendr3rrrr7�s	�r7cCstD]}td|�qdS)zGRun any post hooks that were saved up in the course of the 'renew' verbr5N)r8r1)r&rrr�run_saved_post_hooks�s�r:cCs |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�domains�lineage_pathrrrr�s
	��rcCsrt�}|jrt|j�D]}t||||j�|�|�q|jr7|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)
�setr)r*�renewal_deploy_hooks_dirr;r<r2rr/r0)rr=r>�executed_dir_hooksr-rrrr�s
���rcCs<|r
t�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)r/r0�joinrr!r1)r4r=r>r<rrrr;�s�
r;cCs6tj||t��d�\}}}t�d|�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)�cmd_namer�
returncode�err�outrrrr1�s

�r1cs.�fdd�t���D�}dd�|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

    c3s�|]
}tj��|�VqdS)N)rrrE)�.0�f��dir_pathrr�	<genexpr>�s�zlist_hooks.<locals>.<genexpr>cSs$g|]}t�|�r|�d�s|�qS)�~)r�
is_executable�endswith)rPrrrr�
<listcomp>�s$zlist_hooks.<locals>.<listcomp>)r�listdir�sorted)rS�allpaths�hooksrrRrr*�s	r*)&�__doc__�logging�typingrr�certbotrr�certbot.compatrrr�certbot.displayr	rJ�certbot.pluginsr�	getLogger�__name__r/rrrrr?r.�str�__annotations__r,rr8r7r:rrr;r1r*rrrr�<module>s6

 

Anon7 - 2022
AnonSec Team