Skip to content

Commit dcdf117

Browse files
committed
[UEFI] Adding feature flag to be used for partner testing
1 parent ff91f97 commit dcdf117

4 files changed

Lines changed: 52 additions & 2 deletions

File tree

src/core/src/bootstrap/Constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class SystemPaths(EnumBackport):
5858

5959
class AzGPSPaths(EnumBackport):
6060
EULA_SETTINGS = "/var/lib/azure/linuxpatchextension/patch.eula.settings"
61+
UEFI_SETTINGS = "/var/lib/azure/linuxpatchextension/patch.uefi.settings"
6162

6263
class EnvSettings(EnumBackport):
6364
LOG_FOLDER = "logFolder"
@@ -87,6 +88,11 @@ class EulaSettings(EnumBackport):
8788
ACCEPTED_BY = 'AcceptedBy'
8889
LAST_MODIFIED = 'LastModified'
8990

91+
class UEFISettings(EnumBackport):
92+
ENABLE_UEFI_CERT_UPDATE = 'EnableUEFICertUpdate'
93+
ENABLED_By = 'EnabledBy'
94+
LAST_MODIFIED = 'LastModified'
95+
9096
TEMP_FOLDER_DIR_NAME = "tmp"
9197
TEMP_FOLDER_CLEANUP_ARTIFACT_LIST = ["*.list", "azgps*"]
9298

src/core/src/core_logic/ExecutionConfig.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def __init__(self, env_layer, composite_logger, execution_parameters):
9292
# EULA config
9393
self.accept_package_eula = self.__is_eula_accepted_for_all_patches()
9494

95+
# UEFI config
96+
self.enable_uefi_cert_update = self.__is_uefi_cert_update_enabled()
97+
9598
def __transform_execution_config_for_auto_assessment(self):
9699
self.activity_id = str(uuid.uuid4())
97100
self.included_classifications_list = self.included_package_name_mask_list = self.excluded_package_name_mask_list = []
@@ -267,3 +270,42 @@ def __fetch_specific_eula_setting(settings_source, setting_to_fetch):
267270
return settings_source[setting_to_fetch]
268271
return None
269272

273+
def __is_uefi_cert_update_enabled(self):
274+
# type: () -> bool
275+
""" Reads customer provided config on UEFI cert update from disk and returns a boolean.
276+
NOTE: This is a temporary solution implemented expressly for validating cert updates with partners and will be deprecated soon """
277+
is_uefi_cert_update_enabled = False
278+
try:
279+
if os.path.exists(Constants.AzGPSPaths.UEFI_SETTINGS):
280+
uefi_cert_update_settings = json.loads(self.env_layer.file_system.read_with_retry(Constants.AzGPSPaths.UEFI_CERT_UPDATE_SETTINGS) or 'null')
281+
enable_uefi_cert_update = self.__fetch_specific_uefi_cert_update_setting(uefi_cert_update_settings, Constants.UEFISettings.ENABLE_UEFI_CERT_UPDATE)
282+
enabled_by = self.__fetch_specific_uefi_cert_update_setting(uefi_cert_update_settings, Constants.UEFISettings.ENABLED_BY)
283+
last_modified = self.__fetch_specific_uefi_cert_update_setting(uefi_cert_update_settings, Constants.UEFISettings.LAST_MODIFIED)
284+
if enable_uefi_cert_update is not None and self.__is_truthy(enable_uefi_cert_update):
285+
is_uefi_cert_update_enabled = True
286+
self.composite_logger.log_debug("UEFI cert update config values from disk: [EnableUefiCertUpdate={0}] [EnabledBy={1}] [LastModified={2}]. Computed value of [IsUefiCertUpdateEnabled={3}]"
287+
.format(str(enable_uefi_cert_update), str(enabled_by), str(last_modified), str(is_uefi_cert_update_enabled)))
288+
else:
289+
self.composite_logger.log_debug("No UEFI cert update settings found on the VM. Computed value of [IsUefiCertUpdateEnabled={0}]".format(str(is_uefi_cert_update_enabled)))
290+
except Exception as error:
291+
self.composite_logger.log_debug("Error occurred while reading and parsing UEFI cert update settings. Not enabling UEFI cert update. Error=[{0}]".format(repr(error)))
292+
293+
return is_uefi_cert_update_enabled
294+
295+
@staticmethod
296+
def __is_truthy(value):
297+
# type: (any) -> bool
298+
"""Case-insensitive truthy evaluator for config values."""
299+
if isinstance(value, bool):
300+
return value
301+
if isinstance(value, int):
302+
return value == 1
303+
304+
# Cross-version text types:
305+
# py2 -> (str, unicode)
306+
# py3 -> (str, str)
307+
text_types = (str, type(u""))
308+
if isinstance(value, text_types):
309+
return value.strip().lower() in ("true", "1")
310+
return False
311+

src/core/src/core_logic/PatchInstaller.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ def start_installation(self, simulate=False):
7777
self.composite_logger.log_debug("Attempting to reboot the machine prior to patch installation as there is a reboot pending...")
7878
reboot_manager.start_reboot_if_required_and_time_available(maintenance_window.get_remaining_time_in_minutes(None, False))
7979

80-
# Update certs if available
81-
self.try_update_certificates_for_default_patching()
80+
# Update certificates if feature flag to update certs is set
81+
if self.execution_config.enable_uefi_cert_update:
82+
self.try_update_certificates_for_default_patching()
8283

8384
if self.execution_config.max_patch_publish_date != str():
8485
self.package_manager.set_max_patch_publish_date(self.execution_config.max_patch_publish_date)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"EnableUEFICertUpdate": "true", "EnabledBy": "LSG", "LastModified": "2026-05-23"}

0 commit comments

Comments
 (0)