a }|g@sBdZddlZddlZddlmZddlmZddlmZddlmZddlmZddl m Z m Z dd l m Z dd lmZdd lmZdd lmZdd lmZzddlmZddlmZWneyeZeZYn0ddddddddZdZeeZee ee dddZ!GdddeZ"GdddeZ#Gd d!d!e Z$dS)"z0Module configuring Certbot in a snap environmentN)Iterable)List)Optional)Tuple)Union)PreparedRequestSession) HTTPAdapter) HTTPError)RequestException)os)Error)HTTPConnection)HTTPConnectionPoolzaarch64-linux-gnuzarm-linux-gnueabihfzi386-linux-gnuzpowerpc64le-linux-gnuzpowerpc-linux-gnuzx86_64-linux-gnuzs390x-linux-gnu)Zarm64ZarmhfZi386Zppc64elZpowerpcZamd64Zs390xz python3.12)cli_argsreturnc Cstjd}|tvr"td|dtjdt|tjd<t}|dtz|jddd }| Wn^t y}zFt |t r|j jd krtd td n td |WYd}~n d}~00Wdn1s0Y|}g}g}|didgD]}|did} |did} | dkr| dkr|dd} |didg} t| dkrt| dvr|| q|d| tq|rtdddd|D} t| d |tjd!<|d"|S)#z Prepare runtime environment for a certbot execution in snap. :param list cli_args: List of command line arguments :return: Update list of command line arguments :rtype: list Z SNAP_ARCHz$Unrecognized value of SNAP_ARCH: {0}z{0}/usr/lib/{1}/libaugeas.so.0ZSNAPZCERTBOT_AUGEAS_PATHz http://snapd/z:http://snapd/v2/connections?snap=certbot&interface=contentg>@)timeoutizYAn error occurred while fetching Certbot snap plugins: your version of snapd is outdated.z[Please run "sudo snap install core; sudo snap refresh core" in your terminal and try again.z^An error occurred while fetching Certbot snap plugins: make sure the snapd service is running.NresultZ establishedplugz plug-attrsZcontentpluginz certbot-1ZslotZsnapz slot-attrsreadrz(/snap/{0}/current/lib/{1}/site-packages/zThe following plugins are using an outdated python version and must be updated to be compatible with Certbot 3.0. Please see https://community.letsencrypt.org/t/certbot-3-0-could-have-potential-third-party-snap-breakages/226940 for more information: css|]}d|VqdS)z * {}N)format).0rrA/usr/lib/python3.9/site-packages/certbot/_internal/snap_config.py fzprepare_env..:ZCERTBOT_PLUGIN_PATHz--preconfigured-renewal)r environget_ARCH_TRIPLET_MAPr rrZmount _SnapdAdapterZraise_for_statusr isinstancer responseZ status_codeLOGGERerrorZjsonlenCURRENT_PYTHON_VERSION_STRINGappendZwarningjoin)rZ snap_archZsessionr$edataZ connectionsZoutdated_pluginsrrZ plug_contentZ plugin_nameZ slot_readZ plugin_listrrr prepare_env)sT      8      r-cs0eZdZddfdd ZddddZZS)_SnapdConnectionNrcstdd|_dSNZ localhost)super__init__sockself __class__rrr2qs z_SnapdConnection.__init__cCs"ttjtj|_|jddS)Nz/run/snapd.socket)socketZAF_UNIXZ SOCK_STREAMr3connectr4rrrr9usz_SnapdConnection.connect)__name__ __module__ __qualname__r2r9 __classcell__rrr6rr.psr.cs0eZdZddfdd ZedddZZS)_SnapdConnectionPoolNr/cstddSr0)r1r2r4r6rrr2{sz_SnapdConnectionPool.__init__cCstSN)r.r4rrr _new_conn~sz_SnapdConnectionPool._new_conn)r:r;r<r2r.r@r=rrr6rr>zsr>c @s\eZdZdeeeeedddZd ee eeeee ee eeffedddZ dS) r"N)urlproxiesrcCstSr?r>)r5rArBrrrget_connectionsz_SnapdAdapter.get_connection)requestverifyrBcertrcCstS)zRequired method for creating a new connection pool. Simply return our shim that forces a UNIX socket connection to snapd.rC)r5rErFrBrGrrrget_connection_with_tls_contextsz-_SnapdAdapter.get_connection_with_tls_context)N)NN) r:r;r<strrrr>rDrboolrrrHrrrrr"s  r")%__doc__Zloggingr8typingrrrrrZrequestsrrZrequests.adaptersr Zrequests.exceptionsr r Zcertbot.compatr Zcertbot.errorsr Zurllib3.connectionrZurllib3.connectionpoolr ImportErrorobjectr!r(Z getLoggerr:r%rIr-r.r>r"rrrrsB               G