a }|g=@sLdZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd lm Z dd l m Z dd l m Z dd l m Z dd lmZddlmZddlmZeeZd5e jeeejeee jdddZd6e jeeejeee jdddZd7e jeeejeee jdddZ e jejee jdddZ!e de jdZ"e jeeejeeeee"dd d!Z#eej$eeej$d"d#d$Z%gd%Z&e jejee jee jdd&d'd(Z'e jejeeee jee jfd)d*d+Z(eeeeeed,d-d.Z)e jeeeeefd/d0d1Z*eeeejdd2d3d4Z+dS)8z=Decide which plugins to use for authentication & installationN)cast)Iterable)List)Optional)Tuple)Type)TypeVar) configuration)errors) interfaces)disco)os)utilBz*get_unprepared_installer..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_requestsfilterinitlenr PluginSelectionErrorlistvaluesloggerdebug)rr_Z installersinstrr#rget_unprepared_installer2s$     r3P)bound)rrrrifacesrc sdur|fdd}n|jr,td|}||}||||}t |dkrt d|t t ||}|durdStt|St |dkrt |d}t d||jrdS|St d dSdS) aPick plugin. :param certbot.configuration.NamespaceConfig config: Configuration :param str default: Plugin name supplied by user or ``None``. :param certbot._internal.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: Plugin Ncs |Sr r!r"rrrr%fr&zpick_plugin..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.r'zMultiple candidate plugins: %srzSingle candidate plugin: %szNo candidate plugin)r)Znoninteractive_moder MissingCommandlineFlagZvisibler6r*prepareZ availabler+r/r0 choose_pluginr-r.rr4 misconfigured) rrrrr6ZfilteredpreparedZ plugin_ep1Z plugin_ep2rr7rrSs2       r)r<rrcCsddd|D}tj||dd\}}|tjkrZ||}|jrTtjd|ddq^|SqdSqdS) zAllow 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|jrdndqS)z [Misconfigured])Zdescription_with_namer;).0 plugin_eprrr s z!choose_plugin..T)Zforce_interactivezxThe selected plugin encountered an error while parsing your server configuration and cannot be used. The error was: {0}F)pauseN) display_utilZmenuZOKr;Z notificationformatr9)r<rZoptscodeindexr?rrrr:s  r:)webrootmanual standalonedns-cloudflaredns-digitalocean dns-dnsimpledns-dnsmadeeasy dns-gehirn dns-google dns-linode dns-luadns dns-nsonedns-ovh dns-rfc2136 dns-route53dns-sakuracloud)rrauthr2rcCsVd|_|r ||}|r |j|_d|_|r@||}|r@|j|_td|j|jdS)zFUpdate the config entries to reflect the plugins we actually selected.Nz0Plugins selected: Authenticator %s, Installer %s) authenticatorZ find_initname installerr/info)rrrVr2Zauth_epZinst_eprrrrecord_chosen_pluginss  r[)rrverbrcCst|\}}d}|dkrd}|dkr`d}}ddlm}|tvrh|shd|tj|} t| nd }}|d krvd}n|d vrd}|j rt d |d } d } |dkr||krt |||} t ttj| } t ttj| } n(|s|rt||||} |rt|||} |r| std|||r2| s2td|||d kr| d ur|jpR|j} |d uof| jdv}| st|rt ttj| } t d| | 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: tuple of (`Installer` or None, `Authenticator` or None) :rtype: tuple r=enhancezMWhich installer would you like to use to configure the selected enhancements?runTr cli_commandzWith 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)installr]zRSpecifying an authenticator doesn't make sense when running Certbot with verb "%s"NrYrW)nginxapachez*Selected authenticator %s and installer %s)r(certbot._internal.clir`noninstaller_pluginsrCr linesepr r8rWr/Zwarningrrrr rrrrdiagnose_configurator_problemrbrcrXr0r[)rrr\req_authr$Zinstaller_questionZ need_instZ need_authr`msgrWrY configuratorZselected_configuratorZinteractively_selectedrrrchoose_configurator_pluginssV           rk) previouslynowrcCs6|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 now: the request currently being processed zIToo many flags setting configurators/installers/authenticators {0} -> {1})r r,rCrepr)rlrmrirrrset_configuratorsro)rrcCsx|j}}t||j}t||j}|jrt|d}|jrPt|d}|jrbt|d}td||||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 rbrcrHrFrGrIrJrKrLrMrNrOrPrQrRrSrTrUz+Requested authenticator %s and installer %s)rjrorYrWrbrcrHrFrGZdns_cloudflareZdns_digitaloceanZ dns_dnsimpleZdns_dnsmadeeasyZ dns_gehirnZ dns_googleZ dns_linodeZ dns_luadnsZ dns_nsoneZdns_ovhZ dns_rfc2136Z dns_route53Zdns_sakuracloudr/r0)rr$rhrrrr($sV                       r()cfg_type requestedrrcCsd|r,||vrd|}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}rYrr_zCertbot 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)rCZproblemrdr`r r,)rprqrrir`rrrrgZs     rg)r)r)r),__doc__ZloggingtypingrrrrrrrZcertbotr r r Zcertbot._internal.pluginsr Zcertbot.compatr Zcertbot.displayrrBZ getLogger__name__r/ZNamespaceConfigstrZPluginsRegistryZPluginrrrrrr3r4rZPluginEntryPointr:rer[rkror(rgrrrrs|                     8    R 6