a }|g4 @sdZddlZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd l m Z dd l m Z dd l mZdd lmZdd lmZddlmZdd lmZeeZd@eeedddZeeje ejdddZdAeee eeedddZdBe e j e eeedddZ!eeeedddZ"eeeed d!d"Z#dCeee ee eeefd#d$d%Z$dDeeed'd(d)Z%eeddd*d+Z&eedd,d-d.Z'edd/d0d1Z(ee)eedd2d3d4Z*eeedd5d6Z+dEed7e eeffeegefee eee eefd8d9d:Z,eegefeee eefd;dd?Z.dS)Fz+Contains UI methods for LE user operations.N)indent)Any)Callable)Iterable)List)Optional)Tuple)errors) interfaces)util)account)osFT)invalidoptionalreturncCsd}d}d}|r(|r"||7}d}q,d}nd}z"tj|r>||n|dd\}}Wn"tjypd}t|Yn0|tjkr|rtdtd t|r|S|r||}d}t|}q,d S) aJPrompt for valid email address. :param bool invalid: True if an invalid address was provided by the user :param bool optional: True if the user can use --register-unsafely-without-email to avoid providing an e-mail :returns: e-mail address :rtype: str :raises errors.Error: if the user cancels z-There seem to be problems with that address. zCEnter email address (used for urgent renewal and security notices) a If you really want to skip this, you can run the client with --register-unsafely-without-email but you will then be unable to receive notice about impending expiration or revocation of your certificates or problems with your Certbot installation that will lead to failure to renew. FTforce_interactivezoYou should register before running non-interactively, or provide --agree-tos and --email flags.zHAn e-mail address or --register-unsafely-without-email must be provided.z#An e-mail address must be provided.N) display_util input_textr ZMissingCommandlineFlagOKErrorr Z safe_emailbool)rrZinvalid_prefixmsgZunsafe_suggestionZsuggest_unsafecodeZemailr7/usr/lib/python3.9/site-packages/certbot/display/ops.py get_emails8    r)accountsrcCs8dd|D}tjd|dd\}}|tjkr4||SdS)zChoose an account. :param list accounts: Containing at least one :class:`~certbot._internal.account.Account` cSsg|] }|jqSr)Zslug).0Zaccrrr Tz"choose_account..zPlease choose an accountTrN)rZmenur)rlabelsrindexrrrchoose_accountLs  r#)valuesquestionrcCs2tj|r |nd|dd\}}|tjkr.|r.|SgS)aDisplay screen to let user pick one or multiple values from the provided list. :param list values: Values to select from :param str question: Question to ask to user while choosing values :returns: List of selected values :rtype: list T)tagsr)r checklistr)r$r%ritemsrrr choose_values\s  r*) installerr%rcCsZ|durtdtSt|}t|}|s6tSt||\}}|tjkrV|rV|SgS)aQDisplay screen to select domains to validate. :param installer: An installer object :type installer: :class:`certbot.interfaces.Installer` :param `str` question: Overriding default question to ask the user if asked to choose from domain names. :returns: List of selected names :rtype: `list` of `str` Nz$No installer, picking names manually) loggerdebug_choose_names_manuallylistZ get_all_namesget_valid_domains _filter_namesrr)r+r%domainsnamesrrrr choose_namesms  r4)r2rc Cs@g}|D]2}z|t|Wqtjy8YqYq0q|S)zHelper method for choose_names that implements basic checks on domain names :param list domains: Domain names to validate :return: List of valid domains :rtype: list )appendr enforce_domain_sanityr ConfigurationError)r2Z valid_domainsdomainrrrr0s r0)FQDNsrcCst|dddS)zSort FQDNs by SLD (and if many, by their subdomains) :param list FQDNs: list of domain names :returns: Sorted list of domain names :rtype: list cSs|ddddddS)N.)split)Zfqdnrrrr z_sort_names..)key)sorted)r9rrr _sort_namessrA)r3override_questionrcCs>t|}|r|}nd}tj||ddd\}}|dd|DfS)aDetermine which names the user would like to select from a list. :param list names: domain names :returns: tuple of the form (`code`, `names`) where `code` - str display exit code `names` - list of names selected :rtype: tuple zWhich names would you like to activate HTTPS for? We recommend selecting either all domains, or all domains in a VirtualHost/server block. --domainsT)r'cli_flagrcSsg|] }t|qSr)str)rsrrrrr z!_filter_names..)rArr()r3rBZ sorted_namesr%rrrrr1s  r1r&) prompt_prefixrc Cs&tj|dddd\}}|tjkr"i}d}zt|}Wn"ty\g}dtj}Yn0t |D]N\}}zt |||<Wqft j y}zt|||<WYd}~qfd}~00qf|rdtj}|D]\} } |d tj| | }q|d tj}|rtj|dd } | r"tSn|SgS) zManually input names for those without an installer. :param str prompt_prefix: string to prepend to prompt for domains :returns: list of provided names :rtype: `list` of `str` zaPlease enter the domain name(s) you would like on your certificate (comma and/or space separated)rCT)rDrr&ziInternationalized domain names are not presently supported.{0}{0}Would you like to re-enter the names?{0}Nz;r z#_gen_https_names..Nr;z, and https://r&)lenrJjoinrRrrrrQ-s    rQ.)method validatormessagedefaultkwargsrc Ks|durJz ||Wn4tjyHtjd||ddtd|Yn0||fd|i|\}}|tjkrz||||fWStjy}z0tjd||ddtjt |ddWYd}~qd}~00qJ||fSqJdS) Nz>Encountered invalid default value "%s" when prompting for "%s"T)exc_infozInvalid default "{0}"rgz/Validator rejected "%s" when prompting for "%s"F)pause) r rr,r-AssertionErrorrJrrZ notificationrE)rdrerfrgrhrrawerrorrrr_get_validatedBs.   *rn)reargsrhrcOsttj|g|Ri|S)aLike `~certbot.display.util.input_text`, but with validation. :param callable validator: A method which will be called on the supplied input. If the method raises an `errors.Error`, its text will be displayed and the user will be re-prompted. :param list `*args`: Arguments to be passed to `~certbot.display.util.input_text`. :param dict `**kwargs`: Arguments to be passed to `~certbot.display.util.input_text`. :return: as `~certbot.display.util.input_text` :rtype: tuple )rnrrrerorhrrrvalidated_input_s rqcOsttj|g|Ri|S)a"Like `~certbot.display.util.directory_select`, but with validation. :param callable validator: A method which will be called on the supplied input. If the method raises an `errors.Error`, its text will be displayed and the user will be re-prompted. :param list `*args`: Arguments to be passed to `~certbot.display.util.directory_select`. :param dict `**kwargs`: Arguments to be passed to `~certbot.display.util.directory_select`. :return: as `~certbot.display.util.directory_select` :rtype: tuple )rnrZdirectory_selectrprrrvalidated_directoryns rr)FT)N)N)N)r&)N)/__doc__ZloggingtextwraprtypingrrrrrrZcertbotr r r Zcertbot._internalr Zcertbot._internal.displayrHZcertbot.compatr Zcertbot.displayrZ getLogger__name__r,rrErZAccountr#r*Z Installerr4r0rAr1r.rSrUrWintr^rQrnrqrrrrrrs\               6     6