sysext: introduce ARCHITECTURE field to match host architecture
When an extension image has binaries they should match the host architecture. Currently there is no way to specify this requirement. Introduce an ARCHITECTURE field in the extension's release file that may be set to prevent loading on the wrong host architecture. Since this new field is introduced late, we don't want to make specifying it mandatory as it would break existing sysext images. See https://github.com/systemd/systemd/issues/24061
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "architecture.h"
|
||||
#include "env-util.h"
|
||||
#include "extension-release.h"
|
||||
#include "log.h"
|
||||
@@ -15,7 +16,7 @@ int extension_release_validate(
|
||||
const char *host_sysext_scope,
|
||||
char **extension_release) {
|
||||
|
||||
const char *extension_release_id = NULL, *extension_release_sysext_level = NULL;
|
||||
const char *extension_release_id = NULL, *extension_release_sysext_level = NULL, *extension_architecture = NULL;
|
||||
|
||||
assert(name);
|
||||
assert(!isempty(host_os_release_id));
|
||||
@@ -48,6 +49,16 @@ int extension_release_validate(
|
||||
}
|
||||
}
|
||||
|
||||
/* When the architecture field is present and not '_any' it must match the host - for now just look at uname but in
|
||||
* the future we could check if the kernel also supports 32 bit or binfmt has a translator set up for the architecture */
|
||||
extension_architecture = strv_env_pairs_get(extension_release, "ARCHITECTURE");
|
||||
if (!isempty(extension_architecture) && !streq(extension_architecture, "_any") &&
|
||||
!streq(architecture_to_string(uname_architecture()), extension_architecture)) {
|
||||
log_debug("Extension '%s' is for architecture '%s', but deployed on top of '%s'.",
|
||||
name, extension_architecture, architecture_to_string(uname_architecture()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
extension_release_id = strv_env_pairs_get(extension_release, "ID");
|
||||
if (isempty(extension_release_id)) {
|
||||
log_debug("Extension '%s' does not contain ID in extension-release but requested to match '%s' or be '_any'",
|
||||
|
||||
Reference in New Issue
Block a user