Your IP : 216.73.216.172


Current Path : /lib/python3/dist-packages/certbot/plugins/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/certbot/plugins/__pycache__/selection.cpython-38.pyc

U

�]16�@s�dZddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Ze�e�ZejjZd2d	d
�Zd3dd
�Zd4dd�Zdd�Zdd�Zdd�Zdddddddddd d!d"d#d$d%d&d'gZd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z dS)5z=Decide which plugins to use for authentication & installation�)�print_functionN)�errors)�
interfaces)�os)�util�<How would you like to authenticate and install certificates?cCst||||tjtjf�S)zPick configurator plugin.)�pick_pluginr�IAuthenticator�
IInstaller��config�default�plugins�question�r�;/usr/lib/python3/dist-packages/certbot/plugins/selection.py�pick_configurators
�r�+How would you like to install certificates?cCst||||tjf�S)zPick installer plugin.)rrr
rrrr�pick_installers�r�4How would you like to authenticate with the ACME CA?cCst||||tjf�S)zPick authentication plugin.)rrr	rrrr�pick_authenticator"s�rcs�t|�\}��sdS|��fdd��}|�|�|�tjf�}t|�dkrXt�d���|r�t	|�
��d}t�d|�|�|�St�d���dS)	a/
    Get an unprepared interfaces.IInstaller object.

    :param certbot.interfaces.IConfig config: Configuration
    :param certbot.plugins.disco.PluginsRegistry plugins:
        All plugins registered as entry points.

    :returns: Unprepared installer plugin or None
    :rtype: IPlugin or None
    Ncs
|j�kS�N��name�Zp_ep��req_instrr�<lambda>8�z*get_unprepared_installer.<locals>.<lambda>�zfFound multiple installers with the name %s, Certbot is unable to determine which one to use. Skipping.rzSelecting plugin: %sz:Could not select or initialize the requested installer %s.)
�cli_plugin_requests�filter�init�verifyrr
�lenr�PluginSelectionError�list�values�logger�debug)rr�_Z
installers�instrrr�get_unprepared_installer)s&
��
�r,c	s��dk	r|��fdd��}n|jr,t�d��|���|�}|�|�|�|�}|��|�	�}t
|�dkr�t�d|�t
tt�|��|�}|dkr�dS|��St
|�dkr�t|���d}t�d|�|jr�dS|��St�d	�dSdS)
a�Pick plugin.

    :param certbot.interfaces.IConfig: Configuration
    :param str default: Plugin name supplied by user or ``None``.
    :param certbot.plugins.disco.PluginsRegistry plugins:
        All plugins registered as entry points.
    :param str question: Question to be presented to the user in case
        multiple candidates are found.
    :param list ifaces: Interfaces that plugins must provide.

    :returns: Initialized plugin.
    :rtype: IPlugin

    Ncs
|j�kSrrr�r
rrrXrzpick_plugin.<locals>.<lambda>aMissing command line flags. For non-interactive execution, you will need to specify a plugin on the command line.  Run with '--help plugins' to see a list of options, and see https://eff.org/letsencrypt-plugins for more detail on what the plugins do and how to use them.rzMultiple candidate plugins: %srzSingle candidate plugin: %szNo candidate plugin)r!Znoninteractive_moder�MissingCommandlineFlagZvisible�ifacesr"r#�prepareZ	availabler$r(r)�
choose_pluginr&�sixZ
itervaluesr'�
misconfigured)	rr
rrr/ZfilteredZverified�prepared�	plugin_eprr-rrGs2�


rc	Cs�dd�|D�}tdd�|D��}ttj�}dtjkrl|td�krldd�t|�D�d}|j|||d	�\}}n|j||d
d�\}}|tj	kr�||}|j
r�ttj�jd�|�
��d
d�q�|Sq dSq dS)z�Allow the user to choose their plugin.

    :param list prepared: List of `~.PluginEntryPoint`.
    :param str question: Question to be presented to the user.

    :returns: Plugin entry point chosen by the user.
    :rtype: `~.PluginEntryPoint`

    cSs g|]}|j|jrdnd�qS)z [Misconfigured]�)Zdescription_with_namer3��.0r5rrr�
<listcomp>�s��z!choose_plugin.<locals>.<listcomp>css|]}|jVqdSrrr7rrr�	<genexpr>�sz choose_plugin.<locals>.<genexpr>ZCERTBOT_AUTO)�apache�nginxcSsg|]\}}|jdkr|�qS)r;r)r8�n�prrrr9�s
rr-T)Zforce_interactivezxThe selected plugin encountered an error while parsing your server configuration and cannot be used. The error was:

{0}F)�pauseN)�set�z_utilrZIDisplayr�environ�	enumerateZmenu�display_utilZOKr3Znotification�formatr0)	r4rZopts�namesZdispZ
apache_idx�code�indexr5rrrr1}s(
�


��r1�webroot�manual�
standalone�dns-cloudflare�dns-cloudxns�dns-digitalocean�dns-dnsimple�dns-dnsmadeeasy�
dns-gehirn�
dns-google�
dns-linode�
dns-luadns�	dns-nsone�dns-ovh�dns-rfc2136�dns-route53�dns-sakuracloudcCsB|r|�|�jnd|_|r&|�|�jnd|_t�d|j|j�dS)zFUpdate the config entries to reflect the plugins we actually selected.Nz0Plugins selected: Authenticator %s, Installer %s)Z	find_initr�
authenticator�	installerr(�info)rrZauthr+rrr�record_chosen_plugins�s�r]cCs>t|�\}}d}|dkrd}|dkr`d}}ddlm}|tkrh|shd�|tj|�}	t�|	��nd	}}|d
krtd}|dks�|dkr�d}|j	r�t
�d|�d}
}|dkr�||kr�t|||�}
}n&|s�|r�t
||||�}|r�t|||�}
t
�d
|
|�|�r|�std||�|�r(|
�s(td||�t|||
|�||
fS)a;
    Figure out which configurator we're going to use, modifies
    config.authenticator and config.installer strings to reflect that choice if
    necessary.

    :raises errors.PluginSelectionError if there was a problem

    :returns: (an `IAuthenticator` or None, an `IInstaller` or None)
    :rtype: tuple
    NZenhancezMWhich installer would you like to use to configure the selected enhancements?�runTr��cli_commandz�With the {0} plugin, you probably want to use the "certonly" command, eg:{1}{1}    {2} certonly --{0}{1}{1}(Alternatively, add a --installer flag. See https://eff.org/letsencrypt-plugins{1} and "--help plugins" for more information.)FZcertonly�installzRSpecifying an authenticator doesn't make sense when running Certbot with verb "%s"z*Selected authenticator %s and installer %sr[rZ)r �certbot.clir`�noninstaller_pluginsrEr�lineseprr.rZr(Zwarningrrrr)�diagnose_configurator_problemr])rrZverb�req_authrZinstaller_questionZ	need_instZ	need_authr`�msgrZr[rrr�choose_configurator_plugins�sJ
��rhcCs6|s|S|r2||kr2d}t�|�t|�t|����|S)z�
    Setting configurators multiple ways is okay, as long as they all agree
    :param str previously: previously identified request for the installer/authenticator
    :param str requested: the request currently being processed
    zIToo many flags setting configurators/installers/authenticators {0} -> {1})rr%rE�repr)Z
previouslyZnowrgrrr�set_configurator�srjcCs�|j}}t||j�}t||j�}|jr<t|d�}t|d�}|jrVt|d�}t|d�}|jrft|d�}|jrvt|d�}|jr�t|d�}|j	r�t|d�}|j
r�t|d�}|jr�t|d�}|jr�t|d	�}|j
r�t|d
�}|jr�t|d�}|jr�t|d�}|j�rt|d
�}|j�rt|d�}|j�r,t|d�}|j�r>t|d�}|j�rPt|d�}|j�rbt|d�}|j�rtt|d�}t�d||�||fS)z�
    Figure out which plugins the user requested with CLI and config options

    :returns: (requested authenticator string or None, requested installer string or None)
    :rtype: tuple
    r<r;rKrIrJrLrMrNrOrPrQrRrSrTrUrVrWrXrYz+Requested authenticator %s and installer %s)Zconfiguratorrjr[rZr<r;rKrIrJZdns_cloudflareZdns_cloudxnsZdns_digitaloceanZdns_dnsimpleZdns_dnsmadeeasyZ
dns_gehirnZ
dns_googleZ
dns_linodeZ
dns_luadnsZ	dns_nsoneZdns_ovhZdns_rfc2136Zdns_route53Zdns_sakuracloudr(r))rrrfrrrr sZ





















r cCsd|r,||krd�|�}qVd�|||j�}n*|dkrLddlm}d�|�}n
d�|�}t�|��dS)	a>
    Raise the most helpful error message about a plugin being unavailable

    :param str cfg_type: either "installer" or "authenticator"
    :param str requested: the plugin that was requested
    :param .PluginsRegistry plugins: available plugins

    :raises error.PluginSelectionError: if there was a problem
    z8The requested {0} plugin does not appear to be installedzkThe {0} plugin is not working; there may be problems with your existing configuration.
The error was: {1!r}r[rr_z�Certbot doesn't know how to automatically configure the web server on this system. However, it can still get a certificate for you. Please run "{0} certonly" to do so. You'll need to manually configure your web server to use the resulting certificate.z/{0} could not be determined or is not installedN)rEZproblemrbr`rr%)Zcfg_typeZ	requestedrrgr`rrrre8s��
re)r)r)r)!�__doc__Z
__future__rZloggingr2Zzope.component�zopeZcertbotrrZcertbot.compatrZcertbot.displayrrDZ	getLogger�__name__r(Z	componentZ
getUtilityrArrrr,rr1rcr]rhrjr rerrrr�<module>sL
�
�
�
6'
�@7