From 2a40a1f313430555be9c370c719e3203e723dce9 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 29 Jul 2026 12:22:54 +0100 Subject: [PATCH] sysupdate: Ensure internal helper contexts are run in offline mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, `CONTEXT_NULL` initialises `.offline` to false, so helper contexts are being accidentally run in online mode. Fix that. The following commit will rework this to be safe by default, but let’s fix the individual instances first. Signed-off-by: Philip Withnall (cherry picked from commit 4212fba4a4258a19057642d13a0ae52181675e23) --- src/sysupdate/sysupdate.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/sysupdate/sysupdate.c b/src/sysupdate/sysupdate.c index 3a776d972c..097e7834dc 100644 --- a/src/sysupdate/sysupdate.c +++ b/src/sysupdate/sysupdate.c @@ -1284,11 +1284,15 @@ DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(target_identifier_hash_ops, TargetIdentifier, target_identifier_hash_func, target_identifier_compare_func, TargetIdentifier, target_identifier_free); -static int enumerate_image_class(RuntimeScope runtime_scope, TargetClass class, Set **targets) { +static int enumerate_image_class(Context *context, RuntimeScope runtime_scope, TargetClass class, Set **targets) { _cleanup_hashmap_free_ Hashmap *images = NULL; Image *image; int r; + assert(context); + assert(runtime_scope >= 0 && runtime_scope < _RUNTIME_SCOPE_MAX && runtime_scope != RUNTIME_SCOPE_GLOBAL); + assert(class >= 0 && class < _TARGET_CLASS_MAX); + r = image_discover(runtime_scope, (ImageClass) class, NULL, &images); if (r < 0) return r; @@ -1308,6 +1312,15 @@ static int enumerate_image_class(RuntimeScope runtime_scope, TargetClass class, if (r < 0) return r; + image_context.verify = context->verify; + image_context.offline = true; + + if (context->image_policy) { + image_context.image_policy = image_policy_copy(context->image_policy); + if (!image_context.image_policy) + return log_oom(); + } + /* Load the components in a separate Context specific to the given Image before * committing to loading that state to the main Context. */ r = context_load_offline( @@ -1387,7 +1400,7 @@ static int context_enumerate_targets(Context *context, Set **targets) { assert(context); FOREACH_ARRAY(class, discoverable_classes, ELEMENTSOF(discoverable_classes)) { - r = enumerate_image_class(RUNTIME_SCOPE_SYSTEM, *class, targets); + r = enumerate_image_class(context, RUNTIME_SCOPE_SYSTEM, *class, targets); if (r < 0) return r; } @@ -1440,6 +1453,15 @@ static int context_load_paths_from_target(Context *context) { if (r < 0) return r; + image_context.verify = context->verify; + image_context.offline = true; + + if (context->image_policy) { + image_context.image_policy = image_policy_copy(context->image_policy); + if (!image_context.image_policy) + return log_oom(); + } + /* Load the components in a separate Context specific to the given Image before * committing to loading that state to the main Context. */ r = context_load_offline(&image_context, 0, 0);