HEX
Server: LiteSpeed
System: Linux cluster02.load-balancer.x2.network 4.18.0-553.51.1.lve.1.el8.x86_64 #1 SMP Wed May 14 14:34:57 UTC 2025 x86_64
User: kbdhpghp (1098)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/certbot/_internal/plugins/__pycache__/webroot.cpython-36.pyc
3

گab>�@s�dZddlZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z"ddl#m$Z$ddl#m!Z!ddl%m&Z&ej'e(�Z)dZ*ddgZ+Gdd�de$j,ej-�Z-Gdd �d ej.�Z/Gd!d"�d"ej.�Z0e1e1d#�d$d%�Z2dS)&zWebroot plugin.�N)�Any)�Callable)�DefaultDict)�Dict)�Iterable)�List)�Optional)�Sequence)�Set)�Type)�Union)�
challenges)�crypto_util)�errors)�
interfaces)�cli)�"KeyAuthorizationAnnotatedChallenge)�
filesystem)�os)�ops)�util)�common)�	safe_opena!<?xml version="1.0" encoding="UTF-8" ?>
<!--Generated by Certbot-->
<configuration>
  <system.webServer>
      <staticContent>
          <remove fileExtension="."/>
          <mimeMap fileExtension="." mimeType="text/plain" />
      </staticContent>
  </system.webServer>
</configuration>
Z@20c5ca1bd58fa8ad5f07a2f1be8b7cbb707c20fcb607a8fc8db9393952846a97Z@8d31383d3a079d2098a9d0c0921f4ab87e708b9868dc3f314d54094c2fe70336csTeZdZdZdZdZed�dd�Zee	d/dd	�d
d��Z
eeed�d
d�Z
eeeejd�dd�Zeedd��fdd�Zdd�dd�Zeeeejd�dd�Zeedd�dd�Zeeeeed�dd�Zeeeeed�dd �Zd0eeeed"�d#d$�Zdd�d%d&�Zeeed'�d(d)�Zeejd*�d+d,�Z eedd�d-d.�Z!�Z"S)1�
AuthenticatorzWebroot Authenticator.z Place files in webroot directoryz�Authenticator plugin that performs http-01 challenge by saving
necessary validation resources to appropriate paths on the file
system. It expects that there is some other HTTP server configured
to serve all files under specified web root ({0}).)�returncCs|jj|jd��S)N�path)�	MORE_INFO�format�conf)�self�r �/usr/lib/python3.6/webroot.py�	more_infoCszAuthenticator.more_info.N)�addrcCs&|ddgtdd�|ditdd�dS)Nrz-wapublic_html / webroot path. This can be specified multiple times to handle different domains; each domain will have the webroot path that preceded it.  For instance: `-w /var/www/example -d example.com -d www.example.com -w /var/www/thing -d thing.net -d m.thing.net` (default: Ask))�default�action�help�mapa�JSON dictionary mapping domains to webroot paths; this implies -d for each entry. You may need to escape this from your shell. E.g.: --webroot-map '{"eg1.is,m.eg1.is":"/www/eg1/", "eg2.is":"/www/eg2"}' This option is merged with, but takes precedence over, -w / -d entries. At present, if you put webroot-map in a config file, it needs to be on a single line, like: webroot-map = {"example.com":"/var/www"}.)�_WebrootPathAction�_WebrootMapAction)�clsr#r r r!�add_parser_argumentsFs
z"Authenticator.add_parser_arguments)�failed_achallsrcCsdS)Nz�The Certificate Authority failed to download the temporary challenge files created by Certbot. Ensure that the listed domains serve their content from the provided --webroot-path/-w and that files created there can be downloaded from the internet.r )rr,r r r!�	auth_hintXszAuthenticator.auth_hint)�domainrcCstjgS)N)r
�HTTP01)rr.r r r!�get_chall_pref^szAuthenticator.get_chall_pref)�args�kwargsrcs*t�j||�i|_tjt�|_g|_dS)N)�super�__init__�
full_roots�collections�defaultdict�set�	performed�
_created_dirs)rr1r2)�	__class__r r!r4bszAuthenticator.__init__cCsdS)Nr )rr r r!�prepareiszAuthenticator.prepare)�achallsrcs$�j|��j��fdd�|D�S)Ncsg|]}�j|��qSr )�_perform_single)�.0�achall)rr r!�
<listcomp>qsz)Authenticator.perform.<locals>.<listcomp>)�
_set_webroots�_create_challenge_dirs)rr=r )rr!�performls
zAuthenticator.performcCs�|jd�rH|jd�d}tjd|�x�|D]}|jd�j|j|�q*Wn�tt|jd�j���}xj|D]b}|j|jd�krd|j|j|�}y|j	|�Wnt
k
r�YnX|jd|�||jd�|j<qdWdS)Nr�z4Using the webroot path %s for all unmatched domains.r'r���)r�logger�info�
setdefaultr.�listr8�values�_prompt_for_webroot�remove�
ValueError�insert)rr=�webroot_pathr@�known_webrootsZnew_webrootr r r!rBss"


zAuthenticator._set_webroots)r.rQrcCsFd}x<|dkr@|r2|j||�}|dkr>|j|�}q|j|d�}qW|S)NT)�_prompt_with_webroot_list�_prompt_for_new_webroot)rr.rQ�webrootr r r!rL�s
z!Authenticator._prompt_for_webrootcCsbd|jd�}xNtjdj|�dg||dd�\}}|tjkrFtjd��|dkrRdS||d	SdS)
Nz--rzSelect the webroot for {0}:zEnter a new webrootT)Zcli_flag�force_interactivezIEvery requested domain must have a webroot when using the webroot plugin.rrE)Zoption_name�display_utilZmenur�CANCELr�PluginError)rr.rQZ	path_flag�code�indexr r r!rR�s
z'Authenticator._prompt_with_webroot_listF)r.�
allowraisercCs>tjtdj|�dd�\}}|tjkr6|s,dStjd��t|�S)NzInput the webroot for {0}:T)rUzIEvery requested domain must have a webroot when using the webroot plugin.)rZvalidated_directory�_validate_webrootrrVrWrrX)rr.r[rYrTr r r!rS�s
z%Authenticator._prompt_for_new_webrootc	Cs�|jd�}|stjd���x�|j�D�]�\}}tjj|tjjtj	j
��|j|<tj
d|j|�tjd�}z�x�ttj|j|�dd�td�D]�}tjj|�r�q�yttj|d�|jj|�ytj||dddd	�Wn>ttfk
�r}ztjd
�tj
d|�WYdd}~XnXWq�tk
�rJ}ztjdj||���WYdd}~Xq�Xq�WWdtj|�Xtjs$tjj|j|d
�}tjj|��r�tjd|j|�q$tjd|j|�t |ddd��}|j!t"�WdQRXq$WdS)Nr'z�Missing parts of webroot configuration; please set either --webroot-path and --domains, or --webroot-map. Run with  --help webroot for examples.z-Creating root challenges validation dir at %s�rE)�keyi�T)Z	copy_userZ
copy_groupz3Unable to change owner and uid of webroot directoryz
Error was: %sz=Couldn't create root for {0} http-01 challenge responses: {1}z
web.configzPA web.config file has not been created in %s because another one already exists.zGCreating a web.config file in %s to allow IIS to serve challenge files.�wi�)�mode�chmodrF)#rrrX�itemsrr�join�normcaser
r/Z
URI_ROOT_PATHr5rG�debugr�umask�sortedrZget_prefixes�len�isdir�mkdirr:�appendZcopy_ownership_and_apply_mode�OSError�AttributeErrorZwarningr�
POSIX_MODE�existsrHr�write�_WEB_CONFIG_CONTENT)	rZpath_map�namer�	old_umask�prefixZ	exception�web_config_pathZ
web_configr r r!rC�sL

&
"$z$Authenticator._create_challenge_dirs)�	root_pathr@rcCstjj||jjd��S)N�token)rrrcZchall�encode)rrvr@r r r!�_get_validation_path�sz"Authenticator._get_validation_path)r@rcCs�|j�\}}|j|j}|j||�}tjd|�tjd�}z,t|ddd��}|j	|j
��WdQRXWdtj|�X|j|j|�|S)Nz#Attempting to save validation to %sr]�wbi�)r`ra)
Zresponse_and_validationr5r.ryrGrerrfrrprxr9r#)rr@ZresponseZ
validationrv�validation_pathrsZvalidation_filer r r!r>�s
zAuthenticator._perform_singlec
Cs6x�|D]�}|jj|jd�}|dk	r|j||�}tjd|�tj|�|j|j|�t	j
stjj|d�}tjj
|�rtj|�}|tkr�tjd|�tj|�qtjd|�qWg}xn|j�r |jj�}ytj|�Wq�tk
�r}	z*|jd|�tjd|�tjd|	�WYdd}	~	Xq�Xq�W||_tjd�dS)	NzRemoving %sz
web.configz4Cleaning web.config file generated by Certbot in %s.zQNot cleaning up the web.config file in %s because it is not generated by Certbot.rz3Challenge directory %s was not empty, didn't removez
Error was: %szAll challenges cleaned up)r5�getr.ryrGrerrMr9rrnrrcror�	sha256sum�_WEB_CONFIG_SHA256SUMSrHr:�pop�rmdirrlrO)
rr=r@rvr{rur}Znot_removedr�excr r r!�cleanups8





"zAuthenticator.cleanup).N)F)#�__name__�
__module__�__qualname__�__doc__�descriptionr�strr"�classmethodrr+r�AnnotatedChallenger-rr
Z	Challenger0rr4r<rZChallengeResponserDrBrrLrR�boolrSrCryr>r��
__classcell__r r )r;r!r8s(
:rc@s>eZdZdZdejejeee	e
dfeedd�dd�ZdS)r)z%Action class for parsing webroot_map.N)�parser�	namespace�webroot_map�
option_stringrcsZ|dkrdSxHtjt|��j�D]2\}�t���|jj�fdd�tj||�D��q WdS)Nc3s|]}|�fVqdS)Nr )r?�d)rPr r!�	<genexpr>1sz-_WebrootMapAction.__call__.<locals>.<genexpr>)	�json�loadsr�rbr\r��updaterZadd_domains)rr�r�r�r��domainsr )rPr!�__call__)sz_WebrootMapAction.__call__)N)
r�r�r�r��argparse�ArgumentParser�	Namespacerr�r	rrr�r r r r!r)&sr)csXeZdZdZeedd��fdd�Zd	ejeje	e
eedfee
dd�dd�Z
�ZS)
r(z&Action class for parsing webroot_path.N)r1r2rcst�j||�d|_dS)NF)r3r4�_domain_before_webroot)rr1r2)r;r r!r47sz_WebrootPathAction.__init__)r�r�rPr�rcCsp|dkrdS|jrtjd��|jrL|jd}x*|jD]}|jj||�q4Wn|jrXd|_|jjtt	|���dS)NzPIf you specify multiple webroot paths, one of them must precede all domain flagsrETrF)
r�rrXrPr�r�rIrkr\r�)rr�r�rPr�Zprev_webrootr.r r r!r�;s
z_WebrootPathAction.__call__)N)r�r�r�r�rr4r�r�r�rr�r	rr�r�r r )r;r!r(4sr()rPrcCs&tjj|�stj|d��tjj|�S)z�Validates and returns the absolute path of webroot_path.

    :param str webroot_path: path to the webroot directory

    :returns: absolute path of webroot_path
    :rtype: str

    z% does not exist or is not a directory)rrrirrX�abspath)rPr r r!r\Qs	r\)3r�r�r6r�ZloggingZtypingrrrrrrrr	r
rrZacmer
ZcertbotrrrZcertbot._internalrZcertbot.achallengesrr�Zcertbot.compatrrZcertbot.displayrrrVZcertbot.pluginsrZcertbot.utilrZ	getLoggerr�rGrqr~ZPluginrZActionr)r(r�r\r r r r!�<module>sJ
o