From: Zbigniew Jędrzejewski-Szmek Date: Fri, 9 Feb 2018 11:27:27 +0000 (+0100) Subject: analyze: add unit-paths verb X-Git-Tag: v238~121^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=31a5924ed8627d0f774e8d5574129a796544bf4e;p=thirdparty%2Fsystemd.git analyze: add unit-paths verb --- diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml index 526d5d19192..97a9b2cca78 100644 --- a/man/systemd-analyze.xml +++ b/man/systemd-analyze.xml @@ -91,6 +91,11 @@ OPTIONS dump + + systemd-analyze + OPTIONS + unit-paths + systemd-analyze OPTIONS @@ -188,6 +193,18 @@ state. Its format is subject to change without notice and should not be parsed by applications. + systemd-analyze unit-paths outputs a list of all + directories from which unit files, .d overrides, and + .wants, .requires symlinks may be + loaded. Combine with to retrieve the list for the user + manager instance, and for the global configuration of + user manager instances. Note that this verb prints the list that is compiled into + systemd-analyze itself, and does not comunicate with the + running manager. Use + systemctl [--user] [--global] show -p UnitPath --value + to retrieve the actual list that the manager uses, with any empty directories + omitted. + systemd-analyze log-level prints the current log level of the systemd daemon. If an optional argument LEVEL is provided, then the command changes the current log diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 790c6578b46..0415bb38a17 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1416,6 +1416,21 @@ static int get_or_set_log_target(int argc, char *argv[], void *userdata) { return (argc == 1) ? get_log_target(argc, argv, userdata) : set_log_target(argc, argv, userdata); } +static int dump_unit_paths(int argc, char *argv[], void *userdata) { + _cleanup_lookup_paths_free_ LookupPaths paths = {}; + int r; + char **p; + + r = lookup_paths_init(&paths, arg_scope, 0, NULL); + if (r < 0) + return log_error_errno(r, "lookup_paths_init() failed: %m"); + + STRV_FOREACH(p, paths.search_path) + puts(*p); + + return 0; +} + #if HAVE_SECCOMP static void dump_syscall_filter(const SyscallFilterSet *set) { const char *syscall; @@ -1620,6 +1635,7 @@ static int help(int argc, char *argv[], void *userdata) { " log-level [LEVEL] Get/set logging threshold for manager\n" " log-target [TARGET] Get/set logging target for manager\n" " dump Output state serialization of service manager\n" + " unit-paths List load directories for units\n" " syscall-filter [NAME...] Print list of syscalls in seccomp filter\n" " verify FILE... Check unit files for correctness\n" " calendar SPEC... Validate repetitive calendar time events\n" @@ -1769,6 +1785,12 @@ static int parse_argv(int argc, char *argv[]) { assert_not_reached("Unhandled option code."); } + if (arg_scope == UNIT_FILE_GLOBAL && + !STR_IN_SET(argv[optind] ?: "time", "dot", "unit-paths", "verify")) { + log_error("Option --global only makes sense with verbs dot, unit-paths, verify."); + return -EINVAL; + } + return 1; /* work to do */ } @@ -1789,6 +1811,7 @@ int main(int argc, char *argv[]) { { "set-log-target", 2, 2, 0, set_log_target }, { "get-log-target", VERB_ANY, 1, 0, get_log_target }, { "dump", VERB_ANY, 1, 0, dump }, + { "unit-paths", 1, 1, 0, dump_unit_paths }, { "syscall-filter", VERB_ANY, VERB_ANY, 0, dump_syscall_filters }, { "verify", 2, VERB_ANY, 0, do_verify }, { "calendar", 2, VERB_ANY, 0, test_calendar },