tree-wide: hook up image dissection policy logic everywhere
This commit is contained in:
@@ -46,11 +46,13 @@ static char *arg_image = NULL;
|
||||
static bool arg_reboot = false;
|
||||
static char *arg_component = NULL;
|
||||
static int arg_verify = -1;
|
||||
static ImagePolicy *arg_image_policy = NULL;
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_definitions, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_component, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
|
||||
|
||||
typedef struct Context {
|
||||
Transfer **transfers;
|
||||
@@ -872,6 +874,7 @@ static int process_image(
|
||||
|
||||
r = mount_image_privately_interactively(
|
||||
arg_image,
|
||||
arg_image_policy,
|
||||
(ro ? DISSECT_IMAGE_READ_ONLY : 0) |
|
||||
DISSECT_IMAGE_FSCK |
|
||||
DISSECT_IMAGE_MKDIR |
|
||||
@@ -1022,7 +1025,7 @@ static int verb_pending_or_reboot(int argc, char **argv, void *userdata) {
|
||||
|
||||
if (arg_image || arg_root)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"The --root=/--image switches may not be combined with the '%s' operation.", argv[0]);
|
||||
"The --root=/--image= switches may not be combined with the '%s' operation.", argv[0]);
|
||||
|
||||
r = context_make_offline(&context, NULL);
|
||||
if (r < 0)
|
||||
@@ -1205,8 +1208,10 @@ static int verb_help(int argc, char **argv, void *userdata) {
|
||||
"\n%3$sOptions:%4$s\n"
|
||||
" -C --component=NAME Select component to update\n"
|
||||
" --definitions=DIR Find transfer definitions in specified directory\n"
|
||||
" --root=PATH Operate relative to root path\n"
|
||||
" --image=PATH Operate relative to image file\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"
|
||||
" -m --instances-max=INT How many instances to maintain\n"
|
||||
" --sync=BOOL Controls whether to sync data to disk\n"
|
||||
" --verify=BOOL Force signature verification on or off\n"
|
||||
@@ -1238,6 +1243,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
ARG_IMAGE,
|
||||
ARG_REBOOT,
|
||||
ARG_VERIFY,
|
||||
ARG_IMAGE_POLICY,
|
||||
};
|
||||
|
||||
static const struct option options[] = {
|
||||
@@ -1254,6 +1260,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
{ "reboot", no_argument, NULL, ARG_REBOOT },
|
||||
{ "component", required_argument, NULL, 'C' },
|
||||
{ "verify", required_argument, NULL, ARG_VERIFY },
|
||||
{ "image-policy", required_argument, NULL, ARG_IMAGE_POLICY },
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -1351,6 +1358,17 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user