dissect-tool: expose image filtering via new --image-filter= parameter
This commit is contained in:
+19
-2
@@ -102,6 +102,7 @@ static RuntimeScope arg_runtime_scope = _RUNTIME_SCOPE_INVALID;
|
||||
static bool arg_all = false;
|
||||
static uid_t arg_uid_base = UID_INVALID;
|
||||
static bool arg_quiet = false;
|
||||
static ImageFilter *arg_image_filter = NULL;
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
|
||||
@@ -110,6 +111,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_verity_settings, verity_settings_done);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_argv, strv_freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_loop_ref, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_image_filter, image_filter_freep);
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
@@ -155,6 +157,8 @@ static int help(void) {
|
||||
" not embedded in IMAGE\n"
|
||||
" --image-policy=POLICY\n"
|
||||
" Specify image dissection policy\n"
|
||||
" --image-filter=FILTER\n"
|
||||
" Specify image dissection filter\n"
|
||||
" --json=pretty|short|off\n"
|
||||
" Generate JSON output\n"
|
||||
" --loop-ref=NAME Set reference string for loopback device\n"
|
||||
@@ -295,6 +299,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
ARG_SYSTEM,
|
||||
ARG_USER,
|
||||
ARG_ALL,
|
||||
ARG_IMAGE_FILTER,
|
||||
};
|
||||
|
||||
static const struct option options[] = {
|
||||
@@ -336,6 +341,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
{ "user", no_argument, NULL, ARG_USER },
|
||||
{ "all", no_argument, NULL, ARG_ALL },
|
||||
{ "quiet", no_argument, NULL, 'q' },
|
||||
{ "image-filter", required_argument, NULL, ARG_IMAGE_FILTER },
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -610,6 +616,17 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
arg_quiet = true;
|
||||
break;
|
||||
|
||||
case ARG_IMAGE_FILTER: {
|
||||
_cleanup_(image_filter_freep) ImageFilter *f = NULL;
|
||||
r = image_filter_parse(optarg, &f);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse image filter expression: %s", optarg);
|
||||
|
||||
image_filter_free(arg_image_filter);
|
||||
arg_image_filter = TAKE_PTR(f);
|
||||
break;
|
||||
}
|
||||
|
||||
case '?':
|
||||
return -EINVAL;
|
||||
|
||||
@@ -2108,7 +2125,7 @@ static int action_validate(void) {
|
||||
&arg_verity_settings,
|
||||
/* mount_options= */ NULL,
|
||||
arg_image_policy,
|
||||
/* image_filter= */ NULL,
|
||||
arg_image_filter,
|
||||
arg_flags,
|
||||
/* ret= */ NULL);
|
||||
if (r < 0)
|
||||
@@ -2232,7 +2249,7 @@ static int run(int argc, char *argv[]) {
|
||||
&arg_verity_settings,
|
||||
/* mount_options= */ NULL,
|
||||
arg_image_policy,
|
||||
/* image_filter= */ NULL,
|
||||
arg_image_filter,
|
||||
arg_flags,
|
||||
&m);
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user