]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/analyze/analyze.c
basic: move version() to build.h+c
[thirdparty/systemd.git] / src / analyze / analyze.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /***
3 Copyright © 2013 Simon Peeters
4 ***/
5
6 #include <getopt.h>
7 #include <inttypes.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11
12 #include "sd-bus.h"
13
14 #include "alloc-util.h"
15 #include "analyze.h"
16 #include "analyze-blame.h"
17 #include "analyze-calendar.h"
18 #include "analyze-capability.h"
19 #include "analyze-cat-config.h"
20 #include "analyze-condition.h"
21 #include "analyze-critical-chain.h"
22 #include "analyze-dot.h"
23 #include "analyze-dump.h"
24 #include "analyze-exit-status.h"
25 #include "analyze-filesystems.h"
26 #include "analyze-inspect-elf.h"
27 #include "analyze-log-control.h"
28 #include "analyze-plot.h"
29 #include "analyze-security.h"
30 #include "analyze-service-watchdogs.h"
31 #include "analyze-syscall-filter.h"
32 #include "analyze-time.h"
33 #include "analyze-time-data.h"
34 #include "analyze-timespan.h"
35 #include "analyze-timestamp.h"
36 #include "analyze-unit-files.h"
37 #include "analyze-unit-paths.h"
38 #include "analyze-compare-versions.h"
39 #include "analyze-verify.h"
40 #include "build.h"
41 #include "bus-error.h"
42 #include "bus-locator.h"
43 #include "bus-map-properties.h"
44 #include "bus-unit-util.h"
45 #include "calendarspec.h"
46 #include "cap-list.h"
47 #include "capability-util.h"
48 #include "conf-files.h"
49 #include "copy.h"
50 #include "def.h"
51 #include "exit-status.h"
52 #include "extract-word.h"
53 #include "fd-util.h"
54 #include "fileio.h"
55 #include "filesystems.h"
56 #include "format-table.h"
57 #include "glob-util.h"
58 #include "hashmap.h"
59 #include "locale-util.h"
60 #include "log.h"
61 #include "main-func.h"
62 #include "mount-util.h"
63 #include "nulstr-util.h"
64 #include "pager.h"
65 #include "parse-argument.h"
66 #include "parse-util.h"
67 #include "path-util.h"
68 #include "pretty-print.h"
69 #include "rm-rf.h"
70 #if HAVE_SECCOMP
71 # include "seccomp-util.h"
72 #endif
73 #include "sort-util.h"
74 #include "special.h"
75 #include "stat-util.h"
76 #include "string-table.h"
77 #include "strv.h"
78 #include "strxcpyx.h"
79 #include "terminal-util.h"
80 #include "time-util.h"
81 #include "tmpfile-util.h"
82 #include "unit-name.h"
83 #include "verb-log-control.h"
84 #include "verbs.h"
85 #include "version.h"
86
87 DotMode arg_dot = DEP_ALL;
88 char **arg_dot_from_patterns = NULL, **arg_dot_to_patterns = NULL;
89 usec_t arg_fuzz = 0;
90 PagerFlags arg_pager_flags = 0;
91 BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
92 const char *arg_host = NULL;
93 LookupScope arg_scope = LOOKUP_SCOPE_SYSTEM;
94 RecursiveErrors arg_recursive_errors = _RECURSIVE_ERRORS_INVALID;
95 bool arg_man = true;
96 bool arg_generators = false;
97 char *arg_root = NULL;
98 static char *arg_image = NULL;
99 char *arg_security_policy = NULL;
100 bool arg_offline = false;
101 unsigned arg_threshold = 100;
102 unsigned arg_iterations = 1;
103 usec_t arg_base_time = USEC_INFINITY;
104 char *arg_unit = NULL;
105 JsonFormatFlags arg_json_format_flags = JSON_FORMAT_OFF;
106 bool arg_quiet = false;
107 char *arg_profile = NULL;
108
109 STATIC_DESTRUCTOR_REGISTER(arg_dot_from_patterns, strv_freep);
110 STATIC_DESTRUCTOR_REGISTER(arg_dot_to_patterns, strv_freep);
111 STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
112 STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
113 STATIC_DESTRUCTOR_REGISTER(arg_security_policy, freep);
114 STATIC_DESTRUCTOR_REGISTER(arg_unit, freep);
115 STATIC_DESTRUCTOR_REGISTER(arg_profile, freep);
116
117 int acquire_bus(sd_bus **bus, bool *use_full_bus) {
118 bool user = arg_scope != LOOKUP_SCOPE_SYSTEM;
119 int r;
120
121 if (use_full_bus && *use_full_bus) {
122 r = bus_connect_transport(arg_transport, arg_host, user, bus);
123 if (IN_SET(r, 0, -EHOSTDOWN))
124 return r;
125
126 *use_full_bus = false;
127 }
128
129 return bus_connect_transport_systemd(arg_transport, arg_host, user, bus);
130 }
131
132 int bus_get_unit_property_strv(sd_bus *bus, const char *path, const char *property, char ***strv) {
133 _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
134 int r;
135
136 assert(bus);
137 assert(path);
138 assert(property);
139 assert(strv);
140
141 r = sd_bus_get_property_strv(
142 bus,
143 "org.freedesktop.systemd1",
144 path,
145 "org.freedesktop.systemd1.Unit",
146 property,
147 &error,
148 strv);
149 if (r < 0)
150 return log_error_errno(r, "Failed to get unit property %s: %s", property, bus_error_message(&error, r));
151
152 return 0;
153 }
154
155 void time_parsing_hint(const char *p, bool calendar, bool timestamp, bool timespan) {
156 if (calendar && calendar_spec_from_string(p, NULL) >= 0)
157 log_notice("Hint: this expression is a valid calendar specification. "
158 "Use 'systemd-analyze calendar \"%s\"' instead?", p);
159 if (timestamp && parse_timestamp(p, NULL) >= 0)
160 log_notice("Hint: this expression is a valid timestamp. "
161 "Use 'systemd-analyze timestamp \"%s\"' instead?", p);
162 if (timespan && parse_time(p, NULL, USEC_PER_SEC) >= 0)
163 log_notice("Hint: this expression is a valid timespan. "
164 "Use 'systemd-analyze timespan \"%s\"' instead?", p);
165 }
166
167 static int help(int argc, char *argv[], void *userdata) {
168 _cleanup_free_ char *link = NULL, *dot_link = NULL;
169 int r;
170
171 pager_open(arg_pager_flags);
172
173 r = terminal_urlify_man("systemd-analyze", "1", &link);
174 if (r < 0)
175 return log_oom();
176
177 /* Not using terminal_urlify_man() for this, since we don't want the "man page" text suffix in this case. */
178 r = terminal_urlify("man:dot(1)", "dot(1)", &dot_link);
179 if (r < 0)
180 return log_oom();
181
182 printf("%s [OPTIONS...] COMMAND ...\n\n"
183 "%sProfile systemd, show unit dependencies, check unit files.%s\n"
184 "\nCommands:\n"
185 " [time] Print time required to boot the machine\n"
186 " blame Print list of running units ordered by\n"
187 " time to init\n"
188 " critical-chain [UNIT...] Print a tree of the time critical chain\n"
189 " of units\n"
190 " plot Output SVG graphic showing service\n"
191 " initialization\n"
192 " dot [UNIT...] Output dependency graph in %s format\n"
193 " dump [PATTERN...] Output state serialization of service\n"
194 " manager\n"
195 " cat-config Show configuration file and drop-ins\n"
196 " unit-files List files and symlinks for units\n"
197 " unit-paths List load directories for units\n"
198 " exit-status [STATUS...] List exit status definitions\n"
199 " capability [CAP...] List capability definitions\n"
200 " syscall-filter [NAME...] List syscalls in seccomp filters\n"
201 " filesystems [NAME...] List known filesystems\n"
202 " condition CONDITION... Evaluate conditions and asserts\n"
203 " compare-versions VERSION1 [OP] VERSION2\n"
204 " Compare two version strings\n"
205 " verify FILE... Check unit files for correctness\n"
206 " calendar SPEC... Validate repetitive calendar time\n"
207 " events\n"
208 " timestamp TIMESTAMP... Validate a timestamp\n"
209 " timespan SPAN... Validate a time span\n"
210 " security [UNIT...] Analyze security of unit\n"
211 " inspect-elf FILE... Parse and print ELF package metadata\n"
212 "\nOptions:\n"
213 " --recursive-errors=MODE Control which units are verified\n"
214 " --offline=BOOL Perform a security review on unit file(s)\n"
215 " --threshold=N Exit with a non-zero status when overall\n"
216 " exposure level is over threshold value\n"
217 " --security-policy=PATH Use custom JSON security policy instead\n"
218 " of built-in one\n"
219 " --json=pretty|short|off Generate JSON output of the security\n"
220 " analysis table\n"
221 " --no-pager Do not pipe output into a pager\n"
222 " --system Operate on system systemd instance\n"
223 " --user Operate on user systemd instance\n"
224 " --global Operate on global user configuration\n"
225 " -H --host=[USER@]HOST Operate on remote host\n"
226 " -M --machine=CONTAINER Operate on local container\n"
227 " --order Show only order in the graph\n"
228 " --require Show only requirement in the graph\n"
229 " --from-pattern=GLOB Show only origins in the graph\n"
230 " --to-pattern=GLOB Show only destinations in the graph\n"
231 " --fuzz=SECONDS Also print services which finished SECONDS\n"
232 " earlier than the latest in the branch\n"
233 " --man[=BOOL] Do [not] check for existence of man pages\n"
234 " --generators[=BOOL] Do [not] run unit generators\n"
235 " (requires privileges)\n"
236 " --iterations=N Show the specified number of iterations\n"
237 " --base-time=TIMESTAMP Calculate calendar times relative to\n"
238 " specified time\n"
239 " --profile=name|PATH Include the specified profile in the\n"
240 " security review of the unit(s)\n"
241 " -h --help Show this help\n"
242 " --version Show package version\n"
243 " -q --quiet Do not emit hints\n"
244 " --root=PATH Operate on an alternate filesystem root\n"
245 " --image=PATH Operate on disk image as filesystem root\n"
246 "\nSee the %s for details.\n",
247 program_invocation_short_name,
248 ansi_highlight(),
249 ansi_normal(),
250 dot_link,
251 link);
252
253 /* When updating this list, including descriptions, apply changes to
254 * shell-completion/bash/systemd-analyze and shell-completion/zsh/_systemd-analyze too. */
255
256 return 0;
257 }
258
259 static int parse_argv(int argc, char *argv[]) {
260 enum {
261 ARG_VERSION = 0x100,
262 ARG_ORDER,
263 ARG_REQUIRE,
264 ARG_ROOT,
265 ARG_IMAGE,
266 ARG_SYSTEM,
267 ARG_USER,
268 ARG_GLOBAL,
269 ARG_DOT_FROM_PATTERN,
270 ARG_DOT_TO_PATTERN,
271 ARG_FUZZ,
272 ARG_NO_PAGER,
273 ARG_MAN,
274 ARG_GENERATORS,
275 ARG_ITERATIONS,
276 ARG_BASE_TIME,
277 ARG_RECURSIVE_ERRORS,
278 ARG_OFFLINE,
279 ARG_THRESHOLD,
280 ARG_SECURITY_POLICY,
281 ARG_JSON,
282 ARG_PROFILE,
283 };
284
285 static const struct option options[] = {
286 { "help", no_argument, NULL, 'h' },
287 { "version", no_argument, NULL, ARG_VERSION },
288 { "quiet", no_argument, NULL, 'q' },
289 { "order", no_argument, NULL, ARG_ORDER },
290 { "require", no_argument, NULL, ARG_REQUIRE },
291 { "root", required_argument, NULL, ARG_ROOT },
292 { "image", required_argument, NULL, ARG_IMAGE },
293 { "recursive-errors", required_argument, NULL, ARG_RECURSIVE_ERRORS },
294 { "offline", required_argument, NULL, ARG_OFFLINE },
295 { "threshold", required_argument, NULL, ARG_THRESHOLD },
296 { "security-policy", required_argument, NULL, ARG_SECURITY_POLICY },
297 { "system", no_argument, NULL, ARG_SYSTEM },
298 { "user", no_argument, NULL, ARG_USER },
299 { "global", no_argument, NULL, ARG_GLOBAL },
300 { "from-pattern", required_argument, NULL, ARG_DOT_FROM_PATTERN },
301 { "to-pattern", required_argument, NULL, ARG_DOT_TO_PATTERN },
302 { "fuzz", required_argument, NULL, ARG_FUZZ },
303 { "no-pager", no_argument, NULL, ARG_NO_PAGER },
304 { "man", optional_argument, NULL, ARG_MAN },
305 { "generators", optional_argument, NULL, ARG_GENERATORS },
306 { "host", required_argument, NULL, 'H' },
307 { "machine", required_argument, NULL, 'M' },
308 { "iterations", required_argument, NULL, ARG_ITERATIONS },
309 { "base-time", required_argument, NULL, ARG_BASE_TIME },
310 { "unit", required_argument, NULL, 'U' },
311 { "json", required_argument, NULL, ARG_JSON },
312 { "profile", required_argument, NULL, ARG_PROFILE },
313 {}
314 };
315
316 int r, c;
317
318 assert(argc >= 0);
319 assert(argv);
320
321 while ((c = getopt_long(argc, argv, "hH:M:U:", options, NULL)) >= 0)
322 switch (c) {
323
324 case 'h':
325 return help(0, NULL, NULL);
326
327 case ARG_VERSION:
328 return version();
329
330 case 'q':
331 arg_quiet = true;
332 break;
333
334 case ARG_RECURSIVE_ERRORS:
335 if (streq(optarg, "help")) {
336 DUMP_STRING_TABLE(recursive_errors, RecursiveErrors, _RECURSIVE_ERRORS_MAX);
337 return 0;
338 }
339 r = recursive_errors_from_string(optarg);
340 if (r < 0)
341 return log_error_errno(r, "Unknown mode passed to --recursive-errors='%s'.", optarg);
342
343 arg_recursive_errors = r;
344 break;
345
346 case ARG_ROOT:
347 r = parse_path_argument(optarg, /* suppress_root= */ true, &arg_root);
348 if (r < 0)
349 return r;
350 break;
351
352 case ARG_IMAGE:
353 r = parse_path_argument(optarg, /* suppress_root= */ false, &arg_image);
354 if (r < 0)
355 return r;
356 break;
357
358 case ARG_SYSTEM:
359 arg_scope = LOOKUP_SCOPE_SYSTEM;
360 break;
361
362 case ARG_USER:
363 arg_scope = LOOKUP_SCOPE_USER;
364 break;
365
366 case ARG_GLOBAL:
367 arg_scope = LOOKUP_SCOPE_GLOBAL;
368 break;
369
370 case ARG_ORDER:
371 arg_dot = DEP_ORDER;
372 break;
373
374 case ARG_REQUIRE:
375 arg_dot = DEP_REQUIRE;
376 break;
377
378 case ARG_DOT_FROM_PATTERN:
379 if (strv_extend(&arg_dot_from_patterns, optarg) < 0)
380 return log_oom();
381
382 break;
383
384 case ARG_DOT_TO_PATTERN:
385 if (strv_extend(&arg_dot_to_patterns, optarg) < 0)
386 return log_oom();
387
388 break;
389
390 case ARG_FUZZ:
391 r = parse_sec(optarg, &arg_fuzz);
392 if (r < 0)
393 return r;
394 break;
395
396 case ARG_NO_PAGER:
397 arg_pager_flags |= PAGER_DISABLE;
398 break;
399
400 case 'H':
401 arg_transport = BUS_TRANSPORT_REMOTE;
402 arg_host = optarg;
403 break;
404
405 case 'M':
406 arg_transport = BUS_TRANSPORT_MACHINE;
407 arg_host = optarg;
408 break;
409
410 case ARG_MAN:
411 r = parse_boolean_argument("--man", optarg, &arg_man);
412 if (r < 0)
413 return r;
414 break;
415
416 case ARG_GENERATORS:
417 r = parse_boolean_argument("--generators", optarg, &arg_generators);
418 if (r < 0)
419 return r;
420 break;
421
422 case ARG_OFFLINE:
423 r = parse_boolean_argument("--offline", optarg, &arg_offline);
424 if (r < 0)
425 return r;
426 break;
427
428 case ARG_THRESHOLD:
429 r = safe_atou(optarg, &arg_threshold);
430 if (r < 0 || arg_threshold > 100)
431 return log_error_errno(r < 0 ? r : SYNTHETIC_ERRNO(EINVAL), "Failed to parse threshold: %s", optarg);
432
433 break;
434
435 case ARG_SECURITY_POLICY:
436 r = parse_path_argument(optarg, /* suppress_root= */ false, &arg_security_policy);
437 if (r < 0)
438 return r;
439 break;
440
441 case ARG_JSON:
442 r = parse_json_argument(optarg, &arg_json_format_flags);
443 if (r <= 0)
444 return r;
445 break;
446
447 case ARG_ITERATIONS:
448 r = safe_atou(optarg, &arg_iterations);
449 if (r < 0)
450 return log_error_errno(r, "Failed to parse iterations: %s", optarg);
451
452 break;
453
454 case ARG_BASE_TIME:
455 r = parse_timestamp(optarg, &arg_base_time);
456 if (r < 0)
457 return log_error_errno(r, "Failed to parse --base-time= parameter: %s", optarg);
458
459 break;
460
461 case ARG_PROFILE:
462 if (isempty(optarg))
463 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Profile file name is empty");
464
465 if (is_path(optarg)) {
466 r = parse_path_argument(optarg, /* suppress_root= */ false, &arg_profile);
467 if (r < 0)
468 return r;
469 if (!endswith(arg_profile, ".conf"))
470 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Profile file name must end with .conf: %s", arg_profile);
471 } else {
472 r = free_and_strdup(&arg_profile, optarg);
473 if (r < 0)
474 return log_oom();
475 }
476
477 break;
478
479 case 'U': {
480 _cleanup_free_ char *mangled = NULL;
481
482 r = unit_name_mangle(optarg, UNIT_NAME_MANGLE_WARN, &mangled);
483 if (r < 0)
484 return log_error_errno(r, "Failed to mangle unit name %s: %m", optarg);
485
486 free_and_replace(arg_unit, mangled);
487 break;
488 }
489 case '?':
490 return -EINVAL;
491
492 default:
493 assert_not_reached();
494 }
495
496 if (arg_offline && !streq_ptr(argv[optind], "security"))
497 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
498 "Option --offline= is only supported for security right now.");
499
500 if (arg_json_format_flags != JSON_FORMAT_OFF && !STRPTR_IN_SET(argv[optind], "security", "inspect-elf"))
501 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
502 "Option --json= is only supported for security and inspect-elf right now.");
503
504 if (arg_threshold != 100 && !streq_ptr(argv[optind], "security"))
505 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
506 "Option --threshold= is only supported for security right now.");
507
508 if (arg_scope == LOOKUP_SCOPE_GLOBAL &&
509 !STR_IN_SET(argv[optind] ?: "time", "dot", "unit-paths", "verify"))
510 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
511 "Option --global only makes sense with verbs dot, unit-paths, verify.");
512
513 if (streq_ptr(argv[optind], "cat-config") && arg_scope == LOOKUP_SCOPE_USER)
514 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
515 "Option --user is not supported for cat-config right now.");
516
517 if (arg_security_policy && !streq_ptr(argv[optind], "security"))
518 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
519 "Option --security-policy= is only supported for security.");
520
521 if ((arg_root || arg_image) && (!STRPTR_IN_SET(argv[optind], "cat-config", "verify", "condition")) &&
522 (!(streq_ptr(argv[optind], "security") && arg_offline)))
523 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
524 "Options --root= and --image= are only supported for cat-config, verify, condition and security when used with --offline= right now.");
525
526 /* Having both an image and a root is not supported by the code */
527 if (arg_root && arg_image)
528 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Please specify either --root= or --image=, the combination of both is not supported.");
529
530 if (arg_unit && !streq_ptr(argv[optind], "condition"))
531 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Option --unit= is only supported for condition");
532
533 if (streq_ptr(argv[optind], "condition") && !arg_unit && optind >= argc - 1)
534 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Too few arguments for condition");
535
536 if (streq_ptr(argv[optind], "condition") && arg_unit && optind < argc - 1)
537 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No conditions can be passed if --unit= is used.");
538
539 return 1; /* work to do */
540 }
541
542 static int run(int argc, char *argv[]) {
543 _cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL;
544 _cleanup_(umount_and_rmdir_and_freep) char *unlink_dir = NULL;
545
546 static const Verb verbs[] = {
547 { "help", VERB_ANY, VERB_ANY, 0, help },
548 { "time", VERB_ANY, 1, VERB_DEFAULT, verb_time },
549 { "blame", VERB_ANY, 1, 0, verb_blame },
550 { "critical-chain", VERB_ANY, VERB_ANY, 0, verb_critical_chain },
551 { "plot", VERB_ANY, 1, 0, verb_plot },
552 { "dot", VERB_ANY, VERB_ANY, 0, verb_dot },
553 /* ↓ The following seven verbs are deprecated, from here … ↓ */
554 { "log-level", VERB_ANY, 2, 0, verb_log_control },
555 { "log-target", VERB_ANY, 2, 0, verb_log_control },
556 { "set-log-level", 2, 2, 0, verb_log_control },
557 { "get-log-level", VERB_ANY, 1, 0, verb_log_control },
558 { "set-log-target", 2, 2, 0, verb_log_control },
559 { "get-log-target", VERB_ANY, 1, 0, verb_log_control },
560 { "service-watchdogs", VERB_ANY, 2, 0, verb_service_watchdogs },
561 /* ↑ … until here ↑ */
562 { "dump", VERB_ANY, VERB_ANY, 0, verb_dump },
563 { "cat-config", 2, VERB_ANY, 0, verb_cat_config },
564 { "unit-files", VERB_ANY, VERB_ANY, 0, verb_unit_files },
565 { "unit-paths", 1, 1, 0, verb_unit_paths },
566 { "exit-status", VERB_ANY, VERB_ANY, 0, verb_exit_status },
567 { "syscall-filter", VERB_ANY, VERB_ANY, 0, verb_syscall_filters },
568 { "capability", VERB_ANY, VERB_ANY, 0, verb_capabilities },
569 { "filesystems", VERB_ANY, VERB_ANY, 0, verb_filesystems },
570 { "condition", VERB_ANY, VERB_ANY, 0, verb_condition },
571 { "compare-versions", 3, 4, 0, verb_compare_versions },
572 { "verify", 2, VERB_ANY, 0, verb_verify },
573 { "calendar", 2, VERB_ANY, 0, verb_calendar },
574 { "timestamp", 2, VERB_ANY, 0, verb_timestamp },
575 { "timespan", 2, VERB_ANY, 0, verb_timespan },
576 { "security", VERB_ANY, VERB_ANY, 0, verb_security },
577 { "inspect-elf", 2, VERB_ANY, 0, verb_elf_inspection },
578 {}
579 };
580
581 int r;
582
583 setlocale(LC_ALL, "");
584 setlocale(LC_NUMERIC, "C"); /* we want to format/parse floats in C style */
585
586 log_setup();
587
588 r = parse_argv(argc, argv);
589 if (r <= 0)
590 return r;
591
592 /* Open up and mount the image */
593 if (arg_image) {
594 assert(!arg_root);
595
596 r = mount_image_privately_interactively(
597 arg_image,
598 DISSECT_IMAGE_GENERIC_ROOT |
599 DISSECT_IMAGE_RELAX_VAR_CHECK |
600 DISSECT_IMAGE_READ_ONLY,
601 &unlink_dir,
602 &loop_device);
603 if (r < 0)
604 return r;
605
606 arg_root = strdup(unlink_dir);
607 if (!arg_root)
608 return log_oom();
609 }
610
611 return dispatch_verb(argc, argv, verbs, NULL);
612 }
613
614 DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);