diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-11-30 18:43:18 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-04-05 20:45:30 +0200 |
commit | 84be0c710d9d562f6d2cf986cc2a8ff4c98a138b (patch) | |
tree | b374ebea1d604154fa0e004560f428c7f111352c /src/boot | |
parent | dissect: add image dissection policy framework (diff) | |
download | systemd-84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.tar.xz systemd-84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.zip |
tree-wide: hook up image dissection policy logic everywhere
Diffstat (limited to 'src/boot')
-rw-r--r-- | src/boot/bootctl.c | 19 | ||||
-rw-r--r-- | src/boot/bootctl.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 82c7e498ba..b9d034d550 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -52,6 +52,7 @@ char *arg_image = NULL; InstallSource arg_install_source = ARG_INSTALL_SOURCE_AUTO; char *arg_efi_boot_option_description = NULL; bool arg_dry_run = false; +ImagePolicy *arg_image_policy = NULL; STATIC_DESTRUCTOR_REGISTER(arg_esp_path, freep); STATIC_DESTRUCTOR_REGISTER(arg_xbootldr_path, freep); @@ -60,6 +61,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_entry_token, freep); STATIC_DESTRUCTOR_REGISTER(arg_root, freep); STATIC_DESTRUCTOR_REGISTER(arg_image, freep); STATIC_DESTRUCTOR_REGISTER(arg_efi_boot_option_description, freep); +STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep); int acquire_esp( bool unprivileged_mode, @@ -168,6 +170,8 @@ static int help(int argc, char *argv[], void *userdata) { " --boot-path=PATH Path to the $BOOT partition\n" " --root=PATH Operate on an alternate filesystem root\n" " --image=PATH Operate on disk image as filesystem root\n" + " --image-policy=POLICY\n" + " Specify disk image dissection policy\n" " --install-source=auto|image|host\n" " Where to pick files when using --root=/--image=\n" " -p --print-esp-path Print path to the EFI System Partition mount point\n" @@ -218,6 +222,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_ARCH_ALL, ARG_EFI_BOOT_OPTION_DESCRIPTION, ARG_DRY_RUN, + ARG_IMAGE_POLICY, }; static const struct option options[] = { @@ -244,6 +249,7 @@ static int parse_argv(int argc, char *argv[]) { { "all-architectures", no_argument, NULL, ARG_ARCH_ALL }, { "efi-boot-option-description", required_argument, NULL, ARG_EFI_BOOT_OPTION_DESCRIPTION }, { "dry-run", no_argument, NULL, ARG_DRY_RUN }, + { "image-policy", required_argument, NULL, ARG_IMAGE_POLICY }, {} }; @@ -376,6 +382,18 @@ static int parse_argv(int argc, char *argv[]) { arg_dry_run = true; break; + case ARG_IMAGE_POLICY: { + _cleanup_(image_policy_freep) ImagePolicy *p = NULL; + + r = image_policy_from_string(optarg, &p); + if (r < 0) + return log_error_errno(r, "Failed to parse image policy: %s", optarg); + + image_policy_free(arg_image_policy); + arg_image_policy = TAKE_PTR(p); + break; + } + case '?': return -EINVAL; @@ -478,6 +496,7 @@ static int run(int argc, char *argv[]) { r = mount_image_privately_interactively( arg_image, + arg_image_policy, DISSECT_IMAGE_GENERIC_ROOT | DISSECT_IMAGE_RELAX_VAR_CHECK, &unlink_dir, diff --git a/src/boot/bootctl.h b/src/boot/bootctl.h index c87d43694f..dd98b959c2 100644 --- a/src/boot/bootctl.h +++ b/src/boot/bootctl.h @@ -4,6 +4,7 @@ #include "sd-id128.h" #include "boot-entry.h" +#include "image-policy.h" #include "json.h" #include "pager.h" @@ -34,6 +35,7 @@ extern char *arg_image; extern InstallSource arg_install_source; extern char *arg_efi_boot_option_description; extern bool arg_dry_run; +extern ImagePolicy *arg_image_policy; static inline const char *arg_dollar_boot_path(void) { /* $BOOT shall be the XBOOTLDR partition if it exists, and otherwise the ESP */ |