Spade

Mini Shell

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

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

�
���_c@s�dZddlZddlZddlZddlZddlmZddlZddl	Z
ddlmZddl
mZddl
mZddl
mZddl
mZdd	l
mZdd
lmZddlmZddlmZdd
lmZeje�Zd�Zd�Zejd�Z
ejdej!�Z"e
j#j$ej%�de&fd��Y�Z'de'fd��YZ(de&fd��YZ)de&fd��YZ*d�Z+d�Z,dS(sPlugin
common
functions.i����N(tutil(tList(tachallenges(tcrypto_util(terrors(t
interfaces(treverter(t	constants(t
filesystem(tos(t
PluginStoragecCs|dS(s9ArgumentParser options
namespace (prefix of all
options).t-((tname((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytoption_namespacescCs|jdd�dS(s;ArgumentParser
dest namespace (prefix of all
destinations).Rt_(treplace(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytdest_namespacessX(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)s3^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*[a-z]+$tPlugincBsqeZdZd�Zejd��Zed��Ze	d��Z
d�Ze	d��Zd�Z
d�ZRS(	sGeneric
plugin.cCs||_||_dS(N(tconfigR(tselfRR((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt__init__0s	cCsdS(s�Add
plugin arguments to the CLI argument parser.

        :param callable add: Function that proxies calls to
            `argparse.ArgumentParser.add_argument` prepending options
            with unique plugin name prefix.

       
N((tclstadd((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytadd_parser_arguments4scs��fd�}|j|�S(sYInject
parser options.

        See `~.IPlugin.inject_parser_options` for docs.

       
cs%�jdjt��|�||�S(Ns--{0}{1}(tadd_argumenttformatR
(targ_name_no_prefixtargstkwargs(Rtparser(s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyRFs(R(RRRR((RRs:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytinject_parser_options>scCs
t|j�S(s9ArgumentParser
options namespace (prefix of all
options).(R
R(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR
LscCs|j|S(s'Option
name (include plugin
namespace).(R
(RR((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytoption_nameQscCs
t|j�S(s;ArgumentParser
dest namespace (prefix of all
destinations).(RR(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyRUscCs|j|jdd�S(s.Find
a destination for given variable
``var``.RR(RR(Rtvar((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytdestZscCst|j|j|��S(s0Find
a configuration value for variable ``var``.(tgetattrRR!(RR
((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytconf`s(t__name__t
__module__t__doc__Rt	jose_utiltabstractclassmethodRtclassmethodRtpropertyR
RRR!R#(((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR*s	
		t	InstallercBsqeZdZd�Zed�Zd�Zd�Zd�Zdd�Z	e
d��Ze
d	��Zd
�Z
RS(s�An installer base class with reverter and ssl_dhparam methods
defined.

    Installer plugins do not have to inherit from this class.

   
cOsJtt|�j||�t|j|j�|_tj|j�|_dS(N(	tsuperR+RR
RRtstorageRtReverter(RRR((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyRkscCsd|r|jj}n|jj}y|||�Wn+tjk
r_}tjt|���nXdS(s�Add files to a checkpoint.

        :param set save_files: set of filepaths to save
        :param str save_notes: notes about changes during the save
        :param bool temporary: True if the files should be added to a
            temporary checkpoint rather than a permanent one. This is
            usually used for changes that will soon be reverted.

        :raises .errors.PluginError: when unable to add to checkpoint

       
N(Rtadd_to_temp_checkpointtadd_to_checkpointRt
ReverterErrortPluginErrortstr(Rt
save_filest
save_notest	temporarytcheckpoint_functerr((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR0pscCsFy|jj|�Wn+tjk
rA}tjt|���nXdS(s�Timestamp and save changes made
through the reverter.

        :param str title: Title describing checkpoint

        :raises .errors.PluginError: when an error occurs

       
N(Rtfinalize_checkpointRR1R2R3(RttitleR8((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR9�scCsCy|jj�Wn+tjk
r>}tjt|���nXdS(s�Revert all previously modified
files.

        Reverts all modified files that have not been saved as a checkpoint

        :raises .errors.PluginError: If unable to recover the configuration

       
N(Rtrecovery_routineRR1R2R3(RR8((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR;�scCsCy|jj�Wn+tjk
r>}tjt|���nXdS(skRollback temporary checkpoint.

        :raises .errors.PluginError: when unable to revert config

       
N(Rtrevert_temporary_configRR1R2R3(RR8((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR<�sicCsFy|jj|�Wn+tjk
rA}tjt|���nXdS(s�Rollback saved checkpoints.

        :param int rollback: Number of checkpoints to revert

        :raises .errors.PluginError: If there is a problem with the input
or
            the function is unable to correctly revert the configuration

       
N(Rtrollback_checkpointsRR1R2R3(RtrollbackR8((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR=�s	cCstjj|jjtj�S(s(Full
absolute path to ssl_dhparams file.(R	tpathtjoinRt
config_dirRtSSL_DHPARAMS_DEST(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytssl_dhparams�scCstjj|jjtj�S(s:Full
absolute path to digest of updated ssl_dhparams
file.(R	R?R@RRARtUPDATED_SSL_DHPARAMS_DIGEST(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytupdated_ssl_dhparams_digest�scCst|j|jtjtj�S(sJCopy
Certbot's ssl_dhparams file into the system's config dir if
required.(tinstall_version_controlled_fileRCRERtSSL_DHPARAMS_SRCtALL_SSL_DHPARAMS_HASHES(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytinstall_ssl_dhparams�s
(R$R%R&RtFalseR0R9R;R<R=R*RCRERI(((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR+es		
	
	tAddrcBs�eZdZed�Zed��Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�ZRS(
s�Represents an virtual host address.

    :param str addr: addr part of vhost address
    :param str port: port number or \*, or ""

   
cCs||_||_dS(N(ttuptipv6(RRLRM((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR�s	cCs�|jd�r�|jd�}||d
}d}t|�|dkrm||ddkrm||d}n|||fdt�S|jd�}||d|df�Sd	S(
sInitialize Addr from string.t[t]itit:RMiN(t
startswithtrfindtlentTruet	partition(Rtstr_addrtendIndexthosttportRL((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt
fromstring�s*cCs#|jdrd|jS|jdS(Nis%s:%si(RL(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt__str__�s
cCs'|jr
|j�|jdfS|jS(s5Normalized representation of addr/port tuple
       
i(RMtget_ipv6_explodedRL(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytnormalized_tuple�s	cCs,t||j�r(|j�|j�kStS(N(t
isinstancet	__class__R^RJ(Rtother((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt__eq__�scCs
t|j�S(N(thashRL(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt__hash__�scCs|jdS(s
Return addr part of Addr
object.i(RL(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytget_addr�scCs|jdS(sReturn
port.i(RL(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytget_portscCs
|j|jd|f|j�S(s6Return new address object with same addr and new
port.i(R`RLRM(RRZ((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytget_addr_objscCs+|jd�}|jd�}|j|�S(s7Return
IPv6 address in normalized form, helper
functionRNRO(tlstriptrstript
_explode_ipv6(Rtaddr((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt_normalize_ipv6	scCs*|jr&dj|j|jd��SdS(sReturn
IPv6 in normalized
formRQiRP(RMR@RlRL(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR]s	cCs�ddddddddg}|jd�}t|�t|�kr[|dt|�!}nt}x�t|�D]u\}}|s�t}qnnt|�dkr�|jd�}n|s�t|�||<qnt|�||t|�<qnW|S(s#Explode
IPv6 address for
comparisont0RQii(tsplitRTRJt	enumerateRURhR3(RRktresultt	addr_listt
append_to_endtitblock((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyRjs(R$R%R&RJRR)R[R\R^RbRdReRfRgRlR]Rj(((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyRK�s									tChallengePerformercBs,eZdZd�Zdd�Zd�ZRS(svAbstract
base for challenge performers.

    :ivar configurator: Authenticator and installer plugin
    :ivar achalls: Annotated challenges
    :vartype achalls: `list` of `.KeyAuthorizationAnnotatedChallenge`
    :ivar indices: Holds the indices of challenges from a larger array
        so the user of the class doesn't have to.
    :vartype indices: `list` of `int`

   
cCs||_g|_g|_dS(N(tconfiguratortachallstindices(RRv((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR:s		cCs3|jj|�|dk	r/|jj|�ndS(s�Store
challenge to be performed when perform() is called.

        :param .KeyAuthorizationAnnotatedChallenge achall: Annotated
            challenge.
        :param int idx: index to challenge in a larger array

       
N(RwtappendtNoneRx(Rtachalltidx((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt	add_chall?scCs
t��dS(s�Perform
all added challenges.

        :returns: challenge responses
        :rtype: `list` of
`acme.challenges.KeyAuthorizationChallengeResponse`


       
N(tNotImplementedError(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytperformKsN(R$R%R&RRzR}R(((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyRu.s
	cs�tj�����fd�����fd�}tjj��sS|�dStj��}|�krrdS||kr�|�nftjj��r�t�d��}|j�}WdQX|�kr�dSn��tjd����dS(s�Copy
a file into an active location (likely the system's config dir) if
required.

       :param str dest_path: destination path for version controlled file
       :param str digest_path: path to save a digest of the file in
       :param str src_path: path to version controlled file found in
distribution
       :param list all_hashes: hashes of every released version of the file
   
cs)t�d��}|j��WdQXdS(Ntw(topentwrite(tf(tcurrent_hashtdigest_path(s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt_write_current_hash`scstj�����dS(N(tshutiltcopyfile((R�t	dest_pathtsrc_path(s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt_install_current_filedsNtrsh%s
has been manually modified; updated file saved to %s. We recommend updating
%s for security
purposes.(	Rt	sha256sumR	R?tisfileR�treadtloggertwarning(R�R�R�t
all_hashesR�tactive_file_digestR�tsaved_digest((R�R�R�R�R�s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyRFVs&
	cCs�d�}|d�}|d�}|d�}tj|tj�tj|tj�tj|tj�tj|tjjd|��}t	j
|tjj||�dt�|||fS(s5Setup the directories necessary for
the configurator.cSstjtj|��S(s�Return the real path of a
temp directory with the specified prefix

        Some plugins rely on real paths of symlinks for working correctly.
For
        example, certbot-apache uses real paths of configuration files to
tell
        a virtual host from another. On systems where TMP itself is a
symbolic
        link, (ex: OS X) such plugins will be confused. This function
prevents
        such a case.
       
(Rtrealpathttempfiletmkdtemp(tprefix((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytexpanded_tempdir�s	ttempRtworkttestdatatsymlinks(RtchmodRtCONFIG_DIRS_MODEt
pkg_resourcestresource_filenameR	R?R@R�tcopytreeRU(ttest_dirtpkgR�ttemp_dirRAtwork_dirttest_configs((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt	dir_setup�s	(-R&tloggingtreR�R�tjosepyRR'R�tzope.interfacetzopetacme.magic_typingRtcertbotRRRRRtcertbot._internalRtcertbot.compatRR	tcertbot.plugins.storageR
t	getLoggerR$R�R
Rtcompiletprivate_ips_regext
IGNORECASEthostname_regext	interfacetimplementertIPlugintobjectRR+RKRuRFR�(((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt<module>s>			:gb(	2