/usr/lib/python3/dist-packages/uaclient/__pycache__
NameSizeModeActions
actions.cpython-310.pyc113810644editdlrm
apt.cpython-310.pyc283670644editdlrm
apt_news.cpython-310.pyc73460644editdlrm
config.cpython-310.pyc137600644editdlrm
contract.cpython-310.pyc248990644editdlrm
contract_data_types.cpython-310.pyc80680644editdlrm
data_types.cpython-310.pyc147880644editdlrm
defaults.cpython-310.pyc29130644editdlrm
event_logger.cpython-310.pyc78400644editdlrm
exceptions.cpython-310.pyc250390644editdlrm
gpg.cpython-310.pyc10250644editdlrm
livepatch.cpython-310.pyc106950644editdlrm
lock.cpython-310.pyc46350644editdlrm
log.cpython-310.pyc46330644editdlrm
secret_manager.cpython-310.pyc12560644editdlrm
security_status.cpython-310.pyc165980644editdlrm
snap.cpython-310.pyc64710644editdlrm
status.cpython-310.pyc183610644editdlrm
system.cpython-310.pyc227620644editdlrm
types.cpython-310.pyc4720644editdlrm
update_contract_info.cpython-310.pyc13320644editdlrm
upgrade_lts_contract.cpython-310.pyc29920644editdlrm
util.cpython-310.pyc135250644editdlrm
version.cpython-310.pyc24990644editdlrm
yaml.cpython-310.pyc11780644editdlrm
__init__.cpython-310.pyc1440644editdlrm
Edit: /usr/lib/python3/dist-packages/uaclient/__pycache__/apt.cpython-310.pyc (28367B)
o SKj@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl m Z mZmZmZmZmZmZddlZddlmZddlmZmZmZmZmZmZmZddlm Z ddl!m"Z"dZ#d Z$d Z%d Z&d Z'd Z(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5ej67e dej67e dgej67e dej67e dej67e dej67e d gd!Z8gd"Z9e:Z;eZ?ej@Gd#d$d$ejAZBed%d&eCfd'eCfd(eCfgZDd)d*ZEeEd+eCd,eCfd-d.ZFd/d0ZGd1eCd2eeCfd3d4ZH  dd5eeCd6eeCd7ee eCeCfd2eCfd8d9ZIe dd:  dd6eeCd7ee eCeCfd2eCfd;d<ZJGd=d>d>ZKd?d@ZLdAdBZMdCeCd2eeCfdDdEZN FddCeCdGeOd2eeCfdHdIZP dd7ee eCeCfd2eCfdJdKZQeRejSejTfe9dLeCfdMdNZU  ddOeeCdPeeeCd7ee eCeCfd2eCfdQdRZVdSeCd2eejWfdTdUZXdSeeCd2eejWfdVdWZY ddXejWdYeeCd2eejZfdZd[Z[d\eeCd]eCd^eOd_eCd2eCf d`daZ\ Fdd\eeCd]eCd^eOd_eCdbeCdceOd2eCfdddeZ] FddfeCd_eCdgeCd\eeCdbeCdheeCdieeOd2dfdjdkZ^dldmZ_dndoZ` ddfeCd_eCdheeCdbeeCd2df dpdqZadrdsZbdtduZcdvdwZddxdyZedzeCd2eOfd{d|Zfd2eeDfd}d~Zgd2eeCfddZhddeBjifdeeCdeeCdeeBd2dfddZjd2eekfddZld2eekfddZmd2eejfddZnddZodddZpdeeCdeCfddZqdeeCdeCfddZrdeeCfddZsddZtddZudeeCd2e eCeeCeeCfffddZvd2eCfddZwdS)N) lru_cachewraps)DictIterableList NamedTupleOptionalSetUnion)AcquireProgress) event_logger exceptionsgpgmessagessecret_managersystemutil)ESM_APT_ROOTDIR)status_cache_filegN@z # ubuntu-pro-clientzDir::Etc::netrc/zDir::Etc::netrcparts/zDir::State::lists/a/* * Autogenerated by ubuntu-pro-client * Do not edit this file directly * * To change what ubuntu-pro-client sets, use the `pro config set` * or the `pro config unset` commands to set/unset either: * global_apt_http_proxy and global_apt_https_proxy * for a global apt proxy * or * ua_apt_http_proxy and ua_apt_https_proxy * for an apt proxy that only applies to Ubuntu Pro related repos. */ z$Acquire::http::Proxy "{proxy_url}"; z%Acquire::https::Proxy "{proxy_url}"; z4Acquire::http::Proxy::esm.ubuntu.com "{proxy_url}"; z5Acquire::https::Proxy::esm.ubuntu.com "{proxy_url}"; z/etc/apt/trusted.gpg.d/z/usr/share/keyringsz/usr/lib/apt/methods/httpsz /usr/sbin/update-ca-certificatesz//etc/apt/apt.conf.d/90ubuntu-advantage-aptproxyz*/var/lib/apt/periodic/update-success-stampz/var/lib/dpkg/status)xenialbionicfocaljammyz# Written by ubuntu-pro-client Types: deb{deb_src} URIs: {url} Suites: {suites} Components: main Signed-By: {keyrings_dir}/{keyring_file} zetc/apt/sources.listzvar/lib/dpkg/statuszetc/apt/apt.conf.dzetc/apt/preferences.dzvar/cache/apt/archives/partialzvar/lib/apt/lists/partial)filesfolders)g?g@g$@c@seZdZeZeZdS) AptProxyScopeN)__name__ __module__ __qualname__objectGLOBALUACLIENTr"r"./usr/lib/python3/dist-packages/uaclient/apt.pyrcs rInstalledAptPackagenameversionarchcstfdd}|S)z*Decorator ensuring apt_pkg is initialized.cs&tjddkr t|i|S)NDir)apt_pkgconfiggetinit)argskwargsfr"r#new_fqsz"ensure_apt_pkg_init..new_f)r)r1r2r"r0r#ensure_apt_pkg_initnsr3abcCs t||SN)r*version_compare)r4r5r"r"r#r7|s r7c CsxtjdsdS|d\}}t}|d}|ds |d}n|}dj|||d}zz3tj||dd t } tj dd d ||tj | d gt td Wdn1sXwYWnOtjy} z4tdt| | jdkrt| j} td| rtj|dtd| rtj|dtjt| dd} ~ wtjytjt |dwWt|dSt|w)aValidate apt credentials for a PPA. @param repo_url: private-ppa url path @param username: PPA login username. @param password: PPA login password or resource token. @raises: UbuntuProError for invalid credentials, timeout or unexpected errors. z/usr/lib/apt/apt-helperN://z -validation/z9machine {repo_path} login {username} password {password} ) repo_pathusernamepasswordmodez download-filez {}://{}/pool/zapt-helper-output)timeout retry_sleepszError running apt-helper: %sdz401\s+unauthorized|httperror401)repozconnection timed outdetail)secondsrC) ospathexistssplit!get_apt_auth_file_from_apt_configendswithformatr write_filetempfileTemporaryDirectorysubpjoinAPT_HELPER_TIMEOUT APT_RETRIESr ProcessExecutionErrorLOGerrorstr exit_codestderrlowerresearchAPTInvalidCredentials APTTimeoutAPTUnexpectedError subprocessTimeoutExpiredAPTCommandTimeoutensure_file_absent) repo_urlr;r<protocolr: apt_auth_file auth_pathrepo_path_slash auth_linetmpderZr"r"r#assert_valid_apt_credentialss\            rm apt_errorreturncCsVt}|dD]}|r(td|}|r(d|ddd}||q |S)aAParse apt update errors for invalid apt config in user machine. This functions parses apt update errors regarding the presence of invalid apt config in the system, for example, a ppa that cannot be reached, for example. In that scenario, apt will output a message in the following formats: The repository 'ppa 404 Release' ... Failed to fetch ppa 404 ... On some releases, both of these errors will be present in the apt error message. :param apt_error: The apt error string :return: a NamedMessage containing the error message  z2(Failed to fetch |The repository .)(?P[^\s]+)z- urlz/distsr)setstriprJr\r] groupdictadd)rn failed_reposline pattern_matchrepo_url_matchr"r"r#(_parse_apt_update_for_invalid_apt_configs rzcmd error_msgoverride_env_varsc Csztj|dt|d\}}W|StjyR}z7tdt|t|dt|jvr-t  t |j}|r@tj d t |d|rD|nt|}tj|dd}~ww) aRun an apt command, retrying upon failure APT_RETRIES times. :param cmd: List containing the apt command to run, passed to subp. :param error_msg: The string to raise as UbuntuProError when all retries are exhausted in failure. :param override_env_vars: Passed directly as subp's override_env_vars arg :return: stdout from successful run of the apt command. :raise UbuntuProError: on issues running apt-cache policy. T)capturerAr}z Error running apt command %s: %sz%Could not get lock /var/lib/dpkg/lockrp)rvrDN)rrQrTr rUrVrWrXrZAPTProcessConflictErrorrzAPTInvalidRepoErrorrRsortedr`)r{r|r}out_errrlrvmsgr"r"r#run_apt_commands,    r)maxsizecCstddg||dS)N apt-cachepolicy)r{r|r})r)r|r}r"r"r#get_apt_cache_policy s rc@s$eZdZddZddZddZdS)PreserveAptCfgcCs||_i|_dSr6)apt_funccurrent_apt_cfg)selfrr"r"r#__init__s zPreserveAptCfg.__init__cs&tjfddD|_|S)Ncsi|] }|t|qSr")copydeepcopyr,).0keycfgr"r# sz,PreserveAptCfg.__enter__..)r*r+keysrr)rr"rr# __enter__s  zPreserveAptCfg.__enter__cCs4tj}|jD] }|||j|qtdSr6)r*r+rrrr init_system)rtypevalue tracebackrrr"r"r#__exit__$s zPreserveAptCfg.__exit__N)rrrrrrr"r"r"r#rs rcCs.tjD]}tj|qttdSr6)r*r+rclearr-Cacherr"r"r#get_apt_pkg_cache.s rcCshz(ttjD]}td|stj|q tjdtt t dWSt y3iYSw)Nz^Acquirer() _ensure_esm_cache_structurer*r+rr\r]rrrrr-r Exceptionrr"r"r#get_esm_apt_pkg_cache5s    rpkg_namec Cshtt}z||}WntyYWddSwWdn1s&wY|jr2|jjSdSr6)rrKeyError current_verver_str)rcachepackager"r"r#get_pkg_versionMs   rFcheck_esm_cachec CsTtt7}z||}WntyYWddSwt|}||}|s1 WddS|j}Wdn1s>wY|sG|SttU}|rz||}Wntyf|YWdSwt|} | |} | s||WdS| j} t| |dkr| WdSWd|SWd|S1swY|S)Nr) rrrr*DepCacheget_candidate_verrrr7) rrrr dep_cache candidatecandidate_version esm_cache esm_package esm_dep_cache esm_candidateesm_candidate_versionr"r"r#get_pkg_candidate_versionZsZ               rc CszQz tddg|d}Wn?tjy$}z tdt|td}~wtjy7}ztj|j dd}~wtj yJ}ztj |j dd}~wwWt |St w)Napt-getupdater{r}z Error running apt-get update: %srepo_msgrD)rr rrVrWrXAPTUpdateProcessConflictErrorrAPTUpdateInvalidRepoErrorrUbuntuProErrorAPTUpdateFailedr cache_clear)r}rrlr"r"r#run_apt_update_commands&  rsources_list_pathc CsDtt}tjdtj|tjddtjddt}| t }tj tj dd}t |}zQz||||dWdn1sOwYWn/ttd d yq}z td t|td}~wty}ztjt|d d}~wwWtntwWddS1swYdS) NzDir::Etc::sourcelistzDir::Etc::sourcepartszN.O.F.O.L.D.E.RzAPT::List-Cleanup0zDir::State::ListslockrErrorr"zError updating apt cache: %srD)rrr*r+rrrGrHabspath SourceListread_main_listr rRfind_dirFileLockrgetattrrVrWrXr r SystemErrorrrr)rr sources_listfetch_progress lock_filerrlr"r"r#update_sources_lists:    "rpackages apt_optionsc Csv|durg}ztgd|||d}W|Stjy'td|ttjy:}ztj|jdd}~ww)N)rinstall --assume-yesrz)Error running apt install for packages %sr) rr rrVrWAPTInstallProcessConflictErrorrAPTInstallInvalidRepoErrorr)rrr}rrlr"r"r#run_apt_install_commands&  rorigincCsvt}tt(}|jD]}|j}|r$|jD]\}}|j|kr#||qq Wdt|S1s2wYt|Sr6) rrrrrr file_listrrulist)rresultrrinstalled_versionfile_r"r"r# get_installed_packages_by_origins     rc Cs|durgSt}tt8}t|}|jD]$}|j}|r:||}|r:||kr:|jD]\}}|j |kr9| |q+qWdt |S1sHwYt |Sr6) rrrrr*rrrrrrrur) rrrrrrrrrr"r"r#;get_installed_packages_with_uninstalled_candidate_in_origins&          rrexclude_origincs6g}|jD]}fdd|jD}|r||q|S)Ncs(g|]\}}|jdkr|jkr|qS)now) componentr)rrrrr"r# s z3get_remote_versions_for_package..) version_listrappend)rrvalid_versionsr& valid_originsr"rr#get_remote_versions_for_packages   rsuitesseriesupdates_enabledrecCsRd}|D]"}||vr qd}d|vr|std||d}|dj|||d7}q|S)Nr)-updatesz?Not enabling apt suite "%s" because "%s-updates" is not enabledz# zC{maybe_comment}deb {url} {suite} main # deb-src {url} {suite} main ) maybe_commentrqsuite)rVwarningrM)rrrrecontentrrr"r"r#_get_list_file_contents& r keyring_fileinclude_deb_srcc sZfdd|D}|stddd|D}|rdnd}tj|d|t||d}|S) Ncsg|]}|vr|qSr"r"rrrr"r#r:z-_get_sources_file_content..zPNot enabling service-related -updates suites because "%s-updates" is not enabledcSsg|]}d|vr|qS)rr"rr"r"r#rAsz deb-srcr) )rqr keyrings_dirrdeb_src)rVrDEB822_REPO_FILE_CONTENTrMrR KEYRINGS_DIR) rrrrerrappliable_suitesrrr"rr#_get_sources_file_content2s$ r repo_filename credentials snapshot_urlscheck_updates_pocketcCs*z |d\}}Wn tyd}|}Ynwtj|tj} |dr-|dd}t |||d} |rWd} t dd gt j } | D]} d | | vrOqEd | vrTqEd} |g|D]} t| ||q\| tvrtjt|}tjt|}t||t|| | |}nt|| | ||}t||dS) zAdd an authenticated apt repo and credentials to the system. @raises: InvalidAPTCredentialsError when the token provided can't access the repo PPA. :bearerr9NTFrrz a={}-updatesz o=Ubuntu,)rJ ValueErrorrsecrets add_secretrget_release_inforrLrmrrAPT_POLICY_FAILED splitlinesrMadd_apt_auth_conf_entrySERIES_NOT_USING_DEB822rGrHrRr APT_KEYS_DIRrexport_gpg_keyrrrN)rrerrrrrr;r<rrrrwrqsource_keyring_filedestination_keyring_filerr"r"r#add_auth_apt_repoRsJ          rc Cst}d|vr|d\}}n|}|ds|d7}tj|r&t|}nd}dj|||t d}d}g} | D].} |sb| } t | dkrb| d} | |krW| |d }q9| |vrb| |d }| | q9|so| || dtj |d | d d d S)zBAdd or replace an apt auth line in apt's auth.conf file or conf.d.r8r9r)z:machine {repo_path} login {login} password {password}{cmt})r:loginr<cmtFTrpr=r>N)rKrJrLrGrHrIr load_filerMAPT_AUTH_COMMENTr lenrrNrR) rerr<rg _protocolr: orig_contentrepo_auth_lineadded_new_auth new_linesrw split_linecurr_line_repor"r"r#r sH           r csd|vr |d\}}n|}|dr|dd}t}tj|rNt|}dj|dd fdd | D}|sDt |dStj ||d d dSdS) z+Remove a repo from the shared apt auth filer8r9Nrzmachine {repo_path}/ login)r:rpcsg|]}|vr|qSr"r")rrw auth_prefixr"r#rrz2remove_repo_from_apt_auth_file..r=r>) rJrLrKrGrHrIrrrMrRr rdrN)rerr:rgapt_authrr"r"r#remove_repo_from_apt_auth_files      r%cCs^t||drtt|d|r!tjt|}t||g|D]}t |q&dS)z>Remove an authenticated apt repo and credentials to the systemz.sourcesrN) rrdrLrset_filename_extensionrGrHrRrr%)rrerrrqr"r"r#remove_auth_apt_repos     r'cCsB|d\}}|dr|dd}dj||d}t||dS)z.Add an apt preferences file and pin for a PPA.r8r9Nrz.)r<) package_list pkg_namesr"r"r#r97sr9 http_proxy https_proxy proxy_scopecCs|s|r!|r!d}|tjkrd}n|tjkrd}ttjj|dd}|r@|tjkr3|tj|d7}n |tjkr@|t j|d7}|r]|tjkrP|t j|d7}n |tjkr]|t j|d7}|dkret |}|dkrpt tdSt t|dS)a Writes an apt conf file that configures apt to use the proxies provided as args. If both args are None, then no apt conf file is written. If this function previously wrote a conf file, and was run again with both args as None, the existing file is removed. :param http_proxy: the url of the http proxy apt should use, or None :param https_proxy: the url of the https proxy apt should use, or None :return: None r)z UA-scopedglobal)scope) proxy_urlN)rr!r eventinforSETTING_SERVICE_PROXY_SCOPErMAPT_CONFIG_UA_PROXY_HTTPAPT_CONFIG_GLOBAL_PROXY_HTTPAPT_CONFIG_UA_PROXY_HTTPSAPT_CONFIG_GLOBAL_PROXY_HTTPSAPT_PROXY_CONFIG_HEADERrrdAPT_PROXY_CONF_FILErN)r?r@rAmessageapt_proxy_configr"r"r#setup_apt_proxy=sD       rPcC d}tjtrttj}|Sr6)rGrHrIAPT_UPDATE_SUCCESS_STAMP_PATHstatst_mtime cache_timer"r"r#get_apt_cache_timeu  rWcCrQr6)rGrHrIDPKG_STATUS_PATHrSrT) status_timer"r"r#get_dpkg_status_time|rXr[cCs$t}|dur dStj|tjjSr6)rWdatetime fromtimestamptimezoneutcrUr"r"r#get_apt_cache_datetimesr`cstjtjtdddtdtd}tfdd|Dr!dStttdD]}t |q*tdD] }tj |ddd q6dS) Nz**/*T) recursiverrc3s|]}|vVqdSr6r")rrexisting_filesr"r# sz._ensure_esm_cache_structure..i)exist_okr?) r3rGrHrRrESM_BASIC_FILE_STRUCTUREallrensure_folder_absent create_filemakedirs) desired_filesrfolderr"rbr#rs    rc CstsdStddlm}ddlm}ddlm}m }d}d}t }|dur/||d}| dgD]"}| ddd krG| d d d k}| ddd krW| d d d k}q5||} |rl| d|jkrl| n| tr||} |r| d|jkr| n| ttJ} t} | Gdddt} | }z | || dWnty}ztdt|WYd}~n d}~wwWddSWddS1swYdS)Nr)status)ApplicationStatus)ESMAppsEntitlementESMInfraEntitlementFservicesr%r)zesm-apps availablenoyesz esm-infrac@s,eZdZdejfddZdejfddZdS)z-update_esm_caches..EsmAcquireProgressitemcStd|jdS)NzFetched ESM Apt Cache item: {})rVdebugrMurirrur"r"r#donesz2update_esm_caches..EsmAcquireProgress.donecSrv)Nz&Failed to fetch ESM Apt Cache item: {})rVrrMrxryr"r"r#fails z2update_esm_caches..EsmAcquireProgress.failN)rrrr*AcquireItemDescrzr{r"r"r"r#EsmAcquireProgresssr}z%Failed to fetch the ESM Apt Cache: {})ris_current_series_ltsruaclient.actionsrm(uaclient.entitlements.entitlement_statusrnuaclient.entitlements.esmrorprreadr,application_statusDISABLEDsetup_local_esm_repodisable_local_esm_repois_current_series_active_esmrrr*rrr rrrVrrMrX)rrmrnrorpapps_availableinfra_availablecurrent_statusserviceappsinfrarrr}rrlr"r"r#update_esm_cachessZ        "r package_names error_messagecC"tgdt||ddiddS)a Remove APT packages from the system. Setting DEBIAN_FRONTEND to noninteractive makes sure no prompts will appear during the operation. In this case, --force-confdef will automatically pick the default option when some debconf should appear. In the absence of a default option, --force-confold will automatically choose to keep the old configuration file. )rremover$-o Dpkg::Options::="--force-confdef"$-o Dpkg::Options::="--force-confold"DEBIAN_FRONTENDnoninteractiver}Nrrrrr"r"r#remove_packages  rcCr)a Purge APT packages from the system - remove everything. Setting DEBIAN_FRONTEND to noninteractive makes sure no prompts will appear during the operation. In this case, --force-confdef will automatically pick the default option when some debconf should appear. In the absence of a default option, --force-confold will automatically choose to keep the old configuration file. )rpurgerrrrrrNrrr"r"r#purge_packagesrrcCst|gdddiddS)a6 Install packages, allowing downgrades. The --allow downgrades flag is needed because sometimes we need to reinstall the packages to a lower version (passed in the package_name string, as package=version). Setting DEBIAN_FRONTEND to noninteractive makes sure no prompts will appear during the operation. In this case, --force-confdef will automatically pick the default option when some debconf should appear. In the absence of a default option, --force-confold will automatically choose to keep the old configuration file. )z--allow-downgradesrrrr)rr}N)r)rr"r"r#reinstall_packagess  rcCs*tjD]}tj|qttjSr6)r*r+rr init_configrr"r"r#_get_apt_config-srcCs8tt}||}Wd|S1swY|Sr6)rrr)base_keyapt_cfg apt_cfg_keysr"r"r#get_apt_config_keys7s   r cfg_namescCsdi}tt"}|D]}||}t|s||pd}|||<q Wd|S1s+wY|S)z Get all APT configuration values for the given config names. If one of the config names is not present on the APT config, that config name will have a value of None N)rrr,rX value_list)r apt_cfg_dictrcfg_name cfg_valuer"r"r#get_apt_config_values>s      rcCsd}d}tj|r |S|S)Nz/etc/apt/sources.listz&/etc/apt/sources.list.d/ubuntu.sources)rGrHrI)old_sources_pathnew_sources_pathr"r"r#get_system_sources_fileTs r)NN)Fr6)roN)xrr\enumr3loggingrGr\rarO functoolsrrtypingrrrrrr r r*apt.progress.baser uaclientr r rrrrruaclient.defaultsruaclient.files.state_filesrrSrr/r.r1rLrIrKrHrJrrAPT_METHOD_HTTPS_FILECA_CERTIFICATES_FILErMrRrYrrrHrRrfrTget_event_loggerrE getLoggerreplace_top_level_logger_namerrVuniqueEnumrrXr$r3r7rmrzrrrrrrboolrrretryrrrrPackagerrVersionrrrrr r%r'r*rKr6r7r:r<r9r rPfloatrWr[r`rrrrrrrrrr"r"r"r#s$ $      9 ( +   -  (       ' A/   8 E