Spade

Mini Shell

Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/certbot/_internal/plugins/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyo

�
���_c@s�dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlm
Z
ej!e"�Z#ej$j%ej&�ej$j'ej(�dej)fd��Y��Z*dej+fd��YZ,dej+fd��YZ-d�Z.dS(sWebroot
plugin.i����N(t
challenges(tDefaultDict(tDict(tList(tSet(tachallenges(terrors(t
interfaces(tcli(t
filesystem(tos(tops(tutil(tcommon(t	safe_opent
AuthenticatorcBs�eZdZdZdZd�Zed��Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zed�Zd
�Zd�Zd�Zd�ZRS(sWebroot
Authenticator.s Place files in webroot directorys�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}).cCs|jj|jd��S(Ntpath(t	MORE_INFOtformattconf(tself((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyt	more_info,sc	Cs?|dddgdtdd�|ddidtdd�dS(	NRs-wtdefaulttactionthelpspublic_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)tmaps�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"}.(t_WebrootPathActiont_WebrootMapAction(tclstadd((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pytadd_parser_arguments/scCs
tjgS(N(RtHTTP01(Rtdomain((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pytget_chall_prefAscOsAtt|�j||�i|_tjt�|_g|_dS(N(	tsuperRt__init__t
full_rootstcollectionstdefaultdicttsett	performedt
_created_dirs(Rtargstkwargs((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyR#Es	cCsdS(N((R((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pytprepareMscCs7|j|�|j�g|D]}|j|�^qS(N(t
_set_webrootst_create_challenge_dirst_perform_single(Rtachallstachall((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pytperformPs

cCs|jd�rb|jd�d}tjd|�x�|D]"}|jd�j|j|�q9Wn�tttj|jd����}x�|D]�}|j|jd�kr�|j	|j|�}y|j
|�Wntk
r�nX|jd|�||jd�|j<q�q�WdS(NRi����s4Using
the webroot path %s for all unmatched domains.Ri(
Rtloggertinfot
setdefaultR tlistR'tsixt
itervaluest_prompt_for_webroottremovet
ValueErrortinsert(RR0twebroot_pathR1tknown_webrootstnew_webroot((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyR-Ws"	
#$
	
cCshd}x[|dkrc|rN|j||�}|dkr`|j|�}q`q	|j|t�}q	W|S(N(tNonet_prompt_with_webroot_listt_prompt_for_new_webroottTrue(RR
R>twebroot((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyR9mscCs�tjjtj�}d|jd�}xxtr�|jdj|�dg|d|dt�\}}|t	j
kr�tjd��n|dkr�dS||d	SWdS(
Ns--RsSelect the webroot for {0}:sEnter a new
webroottcli_flagtforce_interactivesIEvery requested domain must have a
webroot when using the webroot plugin.ii(tzopet	componentt
getUtilityRtIDisplaytoption_nameRCtmenuRtdisplay_utiltCANCELRtPluginErrorR@(RR
R>tdisplayt	path_flagtcodetindex((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyRA|s	
cCs\tjtdj|�dt�\}}|tjkrR|s@dStj	d��nt|�S(NsInput
the webroot for {0}:RFsIEvery requested domain must have a webroot when
using the webroot plugin.(
Rtvalidated_directoryt_validate_webrootRRCRMRNR@RRO(RR t
allowraiseRRRD((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyRB�sc
Cs�|jd�}|s'tjd��nxq|j�D]c\}}tjj|tjj	�|j
|<tjd|j
|�t
jd�}z�x�ttj|j
|�d
dt�D]�}tjj|�r�q�ny�t
j|d�|jj|�y#t
j||ddtd	t�Wn6ttfk
rN}tjd
�tjd|�nXWq�tk
r�}tjdj||���q�Xq�WWdt
j|�Xq4WdS(
NRs�Missing
parts of webroot configuration; please set either --webroot-path and
--domains, or --webroot-map. Run with  --help webroot for
examples.s-Creating root challenges validation dir at
%sii����tkeyi�t	copy_usert
copy_groups3Unable to change owner and uid of webroot directorys
Error was:
%ss=Couldn't create root for {0} http-01 challenge responses:
{1}(RRROtitemsR
RtjoinRRt
URI_ROOT_PATHR$R3tdebugR	tumasktsortedRtget_prefixestlentisdirtmkdirR)tappendtcopy_ownership_and_apply_modeRCtOSErrortAttributeErrorR4R(Rtpath_maptnameRt	old_umasktprefixt	exception((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyR.�s6"	-
cCstjj||jjd��S(Nttoken(R
RR[tchalltencode(Rt	root_pathR1((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyt_get_validation_path�scCs�|j�\}}|j|j}|j||�}tjd|�tjd�}z8t|dddd��}|j	|j
��WdQXWdtj|�X|j|j|�|S(Ns#Attempting to save
validation to %sitmodetwbtchmodi�(
tresponse_and_validationR$R
RqR3R]R	R^RtwriteRoR(R(RR1tresponset
validationRptvalidation_pathRjtvalidation_file((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyR/�scCsxx|D]p}|jj|jd�}|dk	r|j||�}tjd|�tj|�|j	|j|�qqWg}xs|j
r�|j
j�}ytj|�Wq�t
k
r�}|jd|�tjd|�tjd|�q�Xq�W||_
tjd�dS(NsRemoving %sis3Challenge directory %s was not empty,
didn't removes
Error was: %ssAll challenges cleaned up(R$tgetR
R@RqR3R]R
R:R(R)tpoptrmdirRfR<R4(RR0R1RpRytnot_removedRtexc((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pytcleanup�s$

	(t__name__t
__module__t__doc__tdescriptionRRtclassmethodRR!R#R,R2R-R9RAtFalseRBR.RqR/R�(((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyRs"								
	,		RcBseZdZdd�ZRS(s%Action
class for parsing
webroot_map.csex^tjtj|��D]D\}�t���|jj�fd�tj||�D��qWdS(Nc3s|]}|�fVqdS(N((t.0td(R=(sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pys	<genexpr>�s(	R7t	iteritemstjsontloadsRUtwebroot_maptupdateRtadd_domains(Rtparsert	namespaceR�t
option_stringtdomains((R=sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyt__call__�s%	N(R�R�R�R@R�(((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyR�sRcBs#eZdZd�Zdd�ZRS(s&Action
class for parsing
webroot_path.cOs&tt|�j||�t|_dS(N(R"RR#R�t_domain_before_webroot(RR*R+((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyR#�scCs�|jrtjd��n|jr[|jd}x<|jD]}|jj||�q;Wn|jrpt|_n|jjt	|��dS(NsPIf
you specify multiple webroot paths, one of them must precede all domain
flagsi����(
R�RROR=R�R�R5RCRdRU(RR�R�R=R�tprev_webrootR
((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyR�s		
	N(R�R�R�R#R@R�(((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyR�s	cCs8tjj|�s(tj|d��ntjj|�S(s�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

    s% does not exist or is not a directory(R
RRbRROtabspath(R=((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyRUs	(/R�targparseR%R�tloggingR7tzope.componentRGtzope.interfacetacmeRtacme.magic_typingRRRRtcertbotRRRtcertbot._internalRtcertbot.compatR	R
tcertbot.displayRRRMtcertbot.pluginsR
tcertbot.utilRt	getLoggerR�R3t	interfacetimplementertIAuthenticatortprovidertIPluginFactorytPluginRtActionRRRU(((sE/usr/lib/python2.7/site-packages/certbot/_internal/plugins/webroot.pyt<module>s<�