Server IP : 172.67.216.182 / Your IP : 172.70.147.4 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/uaclient/entitlements/ |
Upload File : |
import os from typing import Tuple, Type, Union from uaclient import gpg, system from uaclient.apt import APT_KEYS_DIR, ESM_REPO_FILE_CONTENT, KEYRINGS_DIR from uaclient.defaults import ESM_APT_ROOTDIR from uaclient.entitlements import repo from uaclient.entitlements.base import UAEntitlement from uaclient.entitlements.entitlement_status import CanDisableFailure class ESMBaseEntitlement(repo.RepoEntitlement): help_doc_url = "https://ubuntu.com/security/esm" @property def dependent_services(self) -> Tuple[Type[UAEntitlement], ...]: from uaclient.entitlements.ros import ( ROSEntitlement, ROSUpdatesEntitlement, ) return (ROSEntitlement, ROSUpdatesEntitlement) def _perform_enable(self, silent: bool = False) -> bool: from uaclient.jobs.update_messaging import update_apt_and_motd_messages enable_performed = super()._perform_enable(silent=silent) if enable_performed: update_apt_and_motd_messages(self.cfg) self.disable_local_esm_repo() return enable_performed def setup_local_esm_repo(self) -> None: series = system.get_platform_info()["series"] # Ugly? Yes, but so is python < 3.8 without removeprefix assert self.name.startswith("esm-") esm_name = self.name[len("esm-") :] repo_filename = os.path.normpath( ESM_APT_ROOTDIR + self.repo_list_file_tmpl.format(name=self.name), ) keyring_file = self.repo_key_file # No need to create if already present if os.path.exists(repo_filename): return system.write_file( repo_filename, ESM_REPO_FILE_CONTENT.format(name=esm_name, series=series), ) # Set up GPG key source_keyring_file = os.path.join(KEYRINGS_DIR, keyring_file) destination_keyring_file = os.path.normpath( ESM_APT_ROOTDIR + APT_KEYS_DIR + keyring_file ) os.makedirs(os.path.dirname(destination_keyring_file), exist_ok=True) gpg.export_gpg_key(source_keyring_file, destination_keyring_file) def disable_local_esm_repo(self) -> None: keyring_file = os.path.normpath( ESM_APT_ROOTDIR + APT_KEYS_DIR + self.repo_key_file ) repo_filename = os.path.normpath( ESM_APT_ROOTDIR + self.repo_list_file_tmpl.format(name=self.name), ) system.ensure_file_absent(repo_filename) system.ensure_file_absent(keyring_file) class ESMAppsEntitlement(ESMBaseEntitlement): origin = "UbuntuESMApps" name = "esm-apps" title = "Ubuntu Pro: ESM Apps" description = "Expanded Security Maintenance for Applications" repo_key_file = "ubuntu-advantage-esm-apps.gpg" def disable( self, silent=False ) -> Tuple[bool, Union[None, CanDisableFailure]]: from uaclient.jobs.update_messaging import update_apt_and_motd_messages disable_performed, fail = super().disable(silent=silent) if disable_performed: update_apt_and_motd_messages(self.cfg) if system.is_current_series_lts(): self.setup_local_esm_repo() return disable_performed, fail class ESMInfraEntitlement(ESMBaseEntitlement): name = "esm-infra" origin = "UbuntuESM" title = "Ubuntu Pro: ESM Infra" description = "Expanded Security Maintenance for Infrastructure" repo_key_file = "ubuntu-advantage-esm-infra-trusty.gpg" def disable( self, silent=False ) -> Tuple[bool, Union[None, CanDisableFailure]]: from uaclient.jobs.update_messaging import update_apt_and_motd_messages disable_performed, fail = super().disable(silent=silent) if disable_performed: update_apt_and_motd_messages(self.cfg) if system.is_current_series_active_esm(): self.setup_local_esm_repo() return disable_performed, fail