diff --git a/src/repart/repart.c b/src/repart/repart.c index a1c49b3b02..0dae3f8610 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -202,6 +202,7 @@ static AppendMode arg_append_fstab = APPEND_NO; static char *arg_generate_fstab = NULL; static char *arg_generate_crypttab = NULL; static Set *arg_verity_settings = NULL; +static bool arg_relax_copy_block_security = false; STATIC_DESTRUCTOR_REGISTER(arg_node, freep); STATIC_DESTRUCTOR_REGISTER(arg_root, freep); @@ -8737,6 +8738,9 @@ static int parse_argv(int argc, char *argv[], X509 **ret_certificate, EVP_PKEY * r = parse_path_argument(optarg, /* suppress_root= */ false, &arg_image); if (r < 0) return r; + + arg_relax_copy_block_security = false; + break; case ARG_IMAGE_POLICY: @@ -9157,6 +9161,8 @@ static int parse_argv(int argc, char *argv[], X509 **ret_certificate, EVP_PKEY * arg_root = strdup("/sysusr"); if (!arg_root) return log_oom(); + + arg_relax_copy_block_security = true; } if (argc > optind) { @@ -9831,7 +9837,9 @@ static int run(int argc, char *argv[]) { r = context_open_copy_block_paths( context, loop_device ? loop_device->devno : /* if --image= is specified, only allow partitions on the loopback device */ - arg_root && !arg_image ? 0 : /* if --root= is specified, don't accept any block device */ + /* if --root= is specified, don't accept any block device, unless it + * was set automatically because we are in the initrd */ + arg_root && !arg_image && !arg_relax_copy_block_security ? 0 : (dev_t) -1); /* if neither is specified, make no restrictions */ if (r < 0) return r;