sysupdate: Ensure internal helper contexts are run in offline mode
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 <pwithnall@gnome.org> (cherry picked from commit 4212fba4a4258a19057642d13a0ae52181675e23)
This commit is contained in:
committed by
Luca Boccassi
parent
0450557040
commit
2a40a1f313
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user