]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/analyze/analyze.c
Merge pull request #24742 from keszybz/hwdb-252
[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 "bus-error.h"
41 #include "bus-locator.h"
42 #include "bus-map-properties.h"
43 #include "bus-unit-util.h"
44 #include "calendarspec.h"
45 #include "cap-list.h"
46 #include "capability-util.h"
47 #include "conf-files.h"
48 #include "copy.h"
49 #include "def.h"
50 #include "exit-status.h"
51 #include "extract-word.h"
52 #include "fd-util.h"
53 #include "fileio.h"
54 #include "filesystems.h"
55 #include "format-table.h"
56 #include "glob-util.h"
57 #include "hashmap.h"
58 #include "locale-util.h"
59 #include "log.h"
60 #include "main-func.h"
61 #include "mount-util.h"
62 #include "nulstr-util.h"
63 #include "pager.h"
64 #include "parse-argument.h"
65 #include "parse-util.h"
66 #include "path-util.h"
67 #include "pretty-print.h"
68 #include "rm-rf.h"
69 #if HAVE_SECCOMP
70 # include "seccomp-util.h"
71 #endif
72 #include "sort-util.h"
73 #include "special.h"
74 #include "stat-util.h"
75 #include "string-table.h"
76 #include "strv.h"
77 #include "strxcpyx.h"
78 #include "terminal-util.h"
79 #include "time-util.h"
80 #include "tmpfile-util.h"
81 #include "unit-name.h"
82 #include "util.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 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 "\nSee the %s for details.\n",
245 program_invocation_short_name,
246 ansi_highlight(),
247 ansi_normal(),
248 dot_link,
249 link);
250
251 /* When updating this list, including descriptions, apply changes to
252 * shell-completion/bash/systemd-analyze and shell-completion/zsh/_systemd-analyze too. */
253
254 return 0;
255 }
256
257 static int parse_argv(int argc, char *argv[]) {
258 enum {
259 ARG_VERSION = 0x100,
260 ARG_ORDER,
261 ARG_REQUIRE,
262 ARG_ROOT,
263 ARG_IMAGE,
264 ARG_SYSTEM,
265 ARG_USER,
266 ARG_GLOBAL,
267 ARG_DOT_FROM_PATTERN,
268 ARG_DOT_TO_PATTERN,
269 ARG_FUZZ,
270 ARG_NO_PAGER,
271 ARG_MAN,
272 ARG_GENERATORS,
273 ARG_ITERATIONS,
274 ARG_BASE_TIME,
275 ARG_RECURSIVE_ERRORS,
276 ARG_OFFLINE,
277 ARG_THRESHOLD,
278 ARG_SECURITY_POLICY,
279 ARG_JSON,
280 ARG_PROFILE,
281 };
282
283 static const struct option options[] = {
284 { "help", no_argument, NULL, 'h' },
285 { "version", no_argument, NULL, ARG_VERSION },
286 { "quiet", no_argument, NULL, 'q' },
287 { "order", no_argument, NULL, ARG_ORDER },
288 { "require", no_argument, NULL, ARG_REQUIRE },
289 { "root", required_argument, NULL, ARG_ROOT },
290 { "image", required_argument, NULL, ARG_IMAGE },
291 { "recursive-errors", required_argument, NULL, ARG_RECURSIVE_ERRORS },
292 { "offline", required_argument, NULL, ARG_OFFLINE },
293 { "threshold", required_argument, NULL, ARG_THRESHOLD },
294 { "security-policy", required_argument, NULL, ARG_SECURITY_POLICY },
295 { "system", no_argument, NULL, ARG_SYSTEM },
296 { "user", no_argument, NULL, ARG_USER },
297 { "global", no_argument, NULL, ARG_GLOBAL },
298 { "from-pattern", required_argument, NULL, ARG_DOT_FROM_PATTERN },
299 { "to-pattern", required_argument, NULL, ARG_DOT_TO_PATTERN },
300 { "fuzz", required_argument, NULL, ARG_FUZZ },
301 { "no-pager", no_argument, NULL, ARG_NO_PAGER },
302 { "man", optional_argument, NULL, ARG_MAN },
303 { "generators", optional_argument, NULL, ARG_GENERATORS },
304 { "host", required_argument, NULL, 'H' },
305 { "machine", required_argument, NULL, 'M' },
306 { "iterations", required_argument, NULL, ARG_ITERATIONS },
307 { "base-time", required_argument, NULL, ARG_BASE_TIME },
308 { "unit", required_argument, NULL, 'U' },
309 { "json", required_argument, NULL, ARG_JSON },
310 { "profile", required_argument, NULL, ARG_PROFILE },
311 {}
312 };
313
314 int r, c;
315
316 assert(argc >= 0);
317 assert(argv);
318
319 while ((c = getopt_long(argc, argv, "hH:M:U:", options, NULL)) >= 0)
320 switch (c) {
321
322 case 'h':
323 return help(0, NULL, NULL);
324
325 case ARG_VERSION:
326 return version();
327
328 case 'q':
329 arg_quiet = true;
330 break;
331
332 case ARG_RECURSIVE_ERRORS:
333 if (streq(optarg, "help")) {
334 DUMP_STRING_TABLE(recursive_errors, RecursiveErrors, _RECURSIVE_ERRORS_MAX);
335 return 0;
336 }
337 r = recursive_errors_from_string(optarg);
338 if (r < 0)
339 return log_error_errno(r, "Unknown mode passed to --recursive-errors='%s'.", optarg);
340
341 arg_recursive_errors = r;
342 break;
343
344 case ARG_ROOT:
345 r = parse_path_argument(optarg, /* suppress_root= */ true, &arg_root);
346 if (r < 0)
347 return r;
348 break;
349
350 case ARG_IMAGE:
351 r = parse_path_argument(optarg, /* suppress_root= */ false, &arg_image);
352 if (r < 0)
353 return r;
354 break;
355
356 case ARG_SYSTEM:
357 arg_scope = LOOKUP_SCOPE_SYSTEM;
358 break;
359
360 case ARG_USER:
361 arg_scope = LOOKUP_SCOPE_USER;
362 break;
363
364 case ARG_GLOBAL:
365 arg_scope = LOOKUP_SCOPE_GLOBAL;
366 break;
367
368 case ARG_ORDER:
369 arg_dot = DEP_ORDER;
370 break;
371
372 case ARG_REQUIRE:
373 arg_dot = DEP_REQUIRE;
374 break;
375
376 case ARG_DOT_FROM_PATTERN:
377 if (strv_extend(&arg_dot_from_patterns, optarg) < 0)
378 return log_oom();
379
380 break;
381
382 case ARG_DOT_TO_PATTERN:
383 if (strv_extend(&arg_dot_to_patterns, optarg) < 0)
384 return log_oom();
385
386 break;
387
388 case ARG_FUZZ:
389 r = parse_sec(optarg, &arg_fuzz);
390 if (r < 0)
391 return r;
392 break;
393
394 case ARG_NO_PAGER:
395 arg_pager_flags |= PAGER_DISABLE;
396 break;
397
398 case 'H':
399 arg_transport = BUS_TRANSPORT_REMOTE;
400 arg_host = optarg;
401 break;
402
403 case 'M':
404 arg_transport = BUS_TRANSPORT_MACHINE;
405 arg_host = optarg;
406 break;
407
408 case ARG_MAN:
409 r = parse_boolean_argument("--man", optarg, &arg_man);
410 if (r < 0)
411 return r;
412 break;
413
414 case ARG_GENERATORS:
415 r = parse_boolean_argument("--generators", optarg, &arg_generators);
416 if (r < 0)
417 return r;
418 break;
419
420 case ARG_OFFLINE:
421 r = parse_boolean_argument("--offline", optarg, &arg_offline);
422 if (r < 0)
423 return r;
424 break;
425
426 case ARG_THRESHOLD:
427 r = safe_atou(optarg, &arg_threshold);
428 if (r < 0 || arg_threshold > 100)
429 return log_error_errno(r < 0 ? r : SYNTHETIC_ERRNO(EINVAL), "Failed to parse threshold: %s", optarg);
430
431 break;
432
433 case ARG_SECURITY_POLICY:
434 r = parse_path_argument(optarg, /* suppress_root= */ false, &arg_security_policy);
435 if (r < 0)
436 return r;
437 break;
438
439 case ARG_JSON:
440 r = parse_json_argument(optarg, &arg_json_format_flags);
441 if (r <= 0)
442 return r;
443 break;
444
445 case ARG_ITERATIONS:
446 r = safe_atou(optarg, &arg_iterations);
447 if (r < 0)
448 return log_error_errno(r, "Failed to parse iterations: %s", optarg);
449
450 break;
451
452 case ARG_BASE_TIME:
453 r = parse_timestamp(optarg, &arg_base_time);
454 if (r < 0)
455 return log_error_errno(r, "Failed to parse --base-time= parameter: %s", optarg);
456
457 break;
458
459 case ARG_PROFILE:
460 if (isempty(optarg))
461 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Profile file name is empty");
462
463 if (is_path(optarg)) {
464 r = parse_path_argument(optarg, /* suppress_root= */ false, &arg_profile);
465 if (r < 0)
466 return r;
467 if (!endswith(arg_profile, ".conf"))
468 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Profile file name must end with .conf: %s", arg_profile);
469 } else {
470 r = free_and_strdup(&arg_profile, optarg);
471 if (r < 0)
472 return log_oom();
473 }
474
475 break;
476
477 case 'U': {
478 _cleanup_free_ char *mangled = NULL;
479
480 r = unit_name_mangle(optarg, UNIT_NAME_MANGLE_WARN, &mangled);
481 if (r < 0)
482 return log_error_errno(r, "Failed to mangle unit name %s: %m", optarg);
483
484 free_and_replace(arg_unit, mangled);
485 break;
486 }
487 case '?':
488 return -EINVAL;
489
490 default:
491 assert_not_reached();
492 }
493
494 if (arg_offline && !streq_ptr(argv[optind], "security"))
495 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
496 "Option --offline= is only supported for security right now.");
497
498 if (arg_json_format_flags != JSON_FORMAT_OFF && !STRPTR_IN_SET(argv[optind], "security", "inspect-elf"))
499 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
500 "Option --json= is only supported for security and inspect-elf right now.");
501
502 if (arg_threshold != 100 && !streq_ptr(argv[optind], "security"))
503 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
504 "Option --threshold= is only supported for security right now.");
505
506 if (arg_scope == LOOKUP_SCOPE_GLOBAL &&
507 !STR_IN_SET(argv[optind] ?: "time", "dot", "unit-paths", "verify"))
508 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
509 "Option --global only makes sense with verbs dot, unit-paths, verify.");
510
511 if (streq_ptr(argv[optind], "cat-config") && arg_scope == LOOKUP_SCOPE_USER)
512 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
513 "Option --user is not supported for cat-config right now.");
514
515 if (arg_security_policy && !streq_ptr(argv[optind], "security"))
516 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
517 "Option --security-policy= is only supported for security.");
518
519 if ((arg_root || arg_image) && (!STRPTR_IN_SET(argv[optind], "cat-config", "verify", "condition")) &&
520 (!(streq_ptr(argv[optind], "security") && arg_offline)))
521 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
522 "Options --root= and --image= are only supported for cat-config, verify, condition and security when used with --offline= right now.");
523
524 /* Having both an image and a root is not supported by the code */
525 if (arg_root && arg_image)
526 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Please specify either --root= or --image=, the combination of both is not supported.");
527
528 if (arg_unit && !streq_ptr(argv[optind], "condition"))
529 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Option --unit= is only supported for condition");
530
531 if (streq_ptr(argv[optind], "condition") && !arg_unit && optind >= argc - 1)
532 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Too few arguments for condition");
533
534 if (streq_ptr(argv[optind], "condition") && arg_unit && optind < argc - 1)
535 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No conditions can be passed if --unit= is used.");
536
537 return 1; /* work to do */
538 }
539
540 static int run(int argc, char *argv[]) {
541 _cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL;
542 _cleanup_(umount_and_rmdir_and_freep) char *unlink_dir = NULL;
543
544 static const Verb verbs[] = {
545 { "help", VERB_ANY, VERB_ANY, 0, help },
546 { "time", VERB_ANY, 1, VERB_DEFAULT, verb_time },
547 { "blame", VERB_ANY, 1, 0, verb_blame },
548 { "critical-chain", VERB_ANY, VERB_ANY, 0, verb_critical_chain },
549 { "plot", VERB_ANY, 1, 0, verb_plot },
550 { "dot", VERB_ANY, VERB_ANY, 0, verb_dot },
551 /* ↓ The following seven verbs are deprecated, from here … ↓ */
552 { "log-level", VERB_ANY, 2, 0, verb_log_control },
553 { "log-target", VERB_ANY, 2, 0, verb_log_control },
554 { "set-log-level", 2, 2, 0, verb_log_control },
555 { "get-log-level", VERB_ANY, 1, 0, verb_log_control },
556 { "set-log-target", 2, 2, 0, verb_log_control },
557 { "get-log-target", VERB_ANY, 1, 0, verb_log_control },
558 { "service-watchdogs", VERB_ANY, 2, 0, verb_service_watchdogs },
559 /* ↑ … until here ↑ */
560 { "dump", VERB_ANY, 1, 0, verb_dump },
561 { "cat-config", 2, VERB_ANY, 0, verb_cat_config },
562 { "unit-files", VERB_ANY, VERB_ANY, 0, verb_unit_files },
563 { "unit-paths", 1, 1, 0, verb_unit_paths },
564 { "exit-status", VERB_ANY, VERB_ANY, 0, verb_exit_status },
565 { "syscall-filter", VERB_ANY, VERB_ANY, 0, verb_syscall_filters },
566 { "capability", VERB_ANY, VERB_ANY, 0, verb_capabilities },
567 { "filesystems", VERB_ANY, VERB_ANY, 0, verb_filesystems },
568 { "condition", VERB_ANY, VERB_ANY, 0, verb_condition },
569 { "compare-versions", 3, 4, 0, verb_compare_versions },
570 { "verify", 2, VERB_ANY, 0, verb_verify },
571 { "calendar", 2, VERB_ANY, 0, verb_calendar },
572 { "timestamp", 2, VERB_ANY, 0, verb_timestamp },
573 { "timespan", 2, VERB_ANY, 0, verb_timespan },
574 { "security", VERB_ANY, VERB_ANY, 0, verb_security },
575 { "inspect-elf", 2, VERB_ANY, 0, verb_elf_inspection },
576 {}
577 };
578
579 int r;
580
581 setlocale(LC_ALL, "");
582 setlocale(LC_NUMERIC, "C"); /* we want to format/parse floats in C style */
583
584 log_setup();
585
586 r = parse_argv(argc, argv);
587 if (r <= 0)
588 return r;
589
590 /* Open up and mount the image */
591 if (arg_image) {
592 assert(!arg_root);
593
594 r = mount_image_privately_interactively(
595 arg_image,
596 DISSECT_IMAGE_GENERIC_ROOT |
597 DISSECT_IMAGE_RELAX_VAR_CHECK |
598 DISSECT_IMAGE_READ_ONLY,
599 &unlink_dir,
600 &loop_device);
601 if (r < 0)
602 return r;
603
604 arg_root = strdup(unlink_dir);
605 if (!arg_root)
606 return log_oom();
607 }
608
609 return dispatch_verb(argc, argv, verbs, NULL);
610 }
611
612 DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);