summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-02-09 12:27:27 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-02-09 12:27:27 +0100
commit31a5924ed8627d0f774e8d5574129a796544bf4e (patch)
tree0a7d51d13d90f41c799d6859f6efc9432a3ea720
parent28b35ef23a0ac5be4c451c41797109de5333300f (diff)
downloadsystemd-31a5924ed8627d0f774e8d5574129a796544bf4e.tar.gz
analyze: add unit-paths verb
-rw-r--r--man/systemd-analyze.xml17
-rw-r--r--src/analyze/analyze.c23
2 files changed, 40 insertions, 0 deletions
diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml
index 526d5d1919..97a9b2cca7 100644
--- a/man/systemd-analyze.xml
+++ b/man/systemd-analyze.xml
@@ -94,6 +94,11 @@
<cmdsynopsis>
<command>systemd-analyze</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
+ <arg choice="plain">unit-paths</arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>systemd-analyze</command>
+ <arg choice="opt" rep="repeat">OPTIONS</arg>
<arg choice="plain">log-level</arg>
<arg choice="opt"><replaceable>LEVEL</replaceable></arg>
</cmdsynopsis>
@@ -188,6 +193,18 @@
state. Its format is subject to change without notice and should
not be parsed by applications.</para>
+ <para><command>systemd-analyze unit-paths</command> outputs a list of all
+ directories from which unit files, <filename>.d</filename> overrides, and
+ <filename>.wants</filename>, <filename>.requires</filename> symlinks may be
+ loaded. Combine with <option>--user</option> to retrieve the list for the user
+ manager instance, and <option>--global</option> for the global configuration of
+ user manager instances. Note that this verb prints the list that is compiled into
+ <command>systemd-analyze</command> itself, and does not comunicate with the
+ running manager. Use
+ <programlisting>systemctl [--user] [--global] show -p UnitPath --value</programlisting>
+ to retrieve the actual list that the manager uses, with any empty directories
+ omitted.</para>
+
<para><command>systemd-analyze log-level</command>
prints the current log level of the <command>systemd</command> daemon.
If an optional argument <replaceable>LEVEL</replaceable> is provided, then the command changes the current log
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 790c6578b4..0415bb38a1 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 },