• File: common.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/lib/python2.7/site-packages/certbot/plugins/common.pyc
  • Date Modified: 10/08/2021 7:08 AM
  • File size: 17.05 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

_c@sdZddlZddlZddlZddlZddlmZddlZddl	Z
ddlmZddl
mZddl
mZddl
mZddl
mZdd	l
mZdd
lmZddlmZddlmZdd
lmZejeZdZdZejdZ ejdej!Z"e
j#j$ej%de&fdYZ'de'fdYZ(de&fdYZ)de&fdYZ*dZ+dZ,dS(sPlugin common functions.iN(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|jdddS(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]+$tPlugincBsqeZdZdZejdZedZe	dZ
dZe	dZdZ
dZRS(	sGeneric plugin.cCs||_||_dS(N(tconfigR(tselfRR((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt__init__0s	cCsdS(sAdd 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_arguments4scsfd}|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|jS(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|jS(s;ArgumentParser dest namespace (prefix of all destinations).(RR(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyRUscCs|j|jddS(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	InstallercBsqeZdZdZedZdZdZdZddZ	e
dZe
d	Zd
Z
RS(sAn 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(sAdd 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(sTimestamp 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.pyR9scCsCy|jjWn+tjk
r>}tjt|nXdS(sRevert 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|jjWn+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(sRollback 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|jjtjS(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_dhparamsscCstjj|jjtjS(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_digestscCst|j|jtjtjS(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_dhparamss
(R$R%R&RtFalseR0R9R;R<R=R*RCRERI(((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR+es		
	
	tAddrcBseZdZedZedZdZdZdZ	dZ
dZdZd	Z
d
ZdZdZRS(
sRepresents 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.pyRs	cCs|jdr|jd}||d }d}t||dkrm||ddkrm||d}n|||fdtS|jd}||d|dfSd	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
fromstrings*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_tuples	cCs,t||jr(|j|jkStS(N(t
isinstancet	__class__R^RJ(Rtother((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt__eq__scCs
t|jS(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_addrscCs|jdS(sReturn port.i(RL(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pytget_portscCs |j|jd|f|jS(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|jdSdS(sReturn IPv6 in normalized formRQiRP(RMR@RlRL(R((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyR]s	cCsddddddddg}|jd}t|t|kr[|dt|!}nt}xt|D]u\}}|st}qnnt|dkr|jd}n|st|||<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.pyRKs									tChallengePerformercBs,eZdZdZddZdZRS(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(sStore 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
tdS(sPerform 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
	cstjfdfd}tjjsS|dStj}|krrdS||kr|nftjjrtd}|j}WdQX|krdSntjddS(sCopy 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)td}|jWdQXdS(Ntw(topentwrite(tf(tcurrent_hashtdigest_path(s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt_write_current_hash`scstjdS(N(tshutiltcopyfile((Rt	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?tisfileRtreadtloggertwarning(RRRt
all_hashesRtactive_file_digestRtsaved_digest((RRRRRs:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyRFVs&
	cCsd}|d}|d}|d}tj|tjtj|tjtj|tjtj|tjjd|}t	j
|tjj||dt|||fS(s5Setup the directories necessary for the configurator.cSstjtj|S(sReturn 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_tempdirs	ttempRtworkttestdatatsymlinks(RtchmodRtCONFIG_DIRS_MODEt
pkg_resourcestresource_filenameR	R?R@RtcopytreeRU(ttest_dirtpkgRttemp_dirRAtwork_dirttest_configs((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt	dir_setups	(-R&tloggingtreRRtjosepyRR'Rtzope.interfacetzopetacme.magic_typingRtcertbotRRRRRtcertbot._internalRtcertbot.compatRR	tcertbot.plugins.storageR
t	getLoggerR$RR
Rtcompiletprivate_ips_regext
IGNORECASEthostname_regext	interfacetimplementertIPlugintobjectRR+RKRuRFR(((s:/usr/lib/python2.7/site-packages/certbot/plugins/common.pyt<module>s>			:gb(	2