diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml
index a3a3ce0e54..e74739498c 100644
--- a/man/systemd-analyze.xml
+++ b/man/systemd-analyze.xml
@@ -297,13 +297,23 @@
-
+
Do not invoke man to verify the existence of
man pages listed in Documentation=.
+
+
+
+ Invoke unit generators, see
+ systemd.generator7.
+ Some generators require root privileges. When run under a
+ normal users, enabling generators will generally result in
+ some warnings.
+
+
diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c
index 375b457ae8..f34c24c53a 100644
--- a/src/analyze/analyze-verify.c
+++ b/src/analyze/analyze-verify.c
@@ -242,7 +242,7 @@ static int verify_unit(Unit *u, bool check_man) {
return r;
}
-int verify_units(char **filenames, UnitFileScope scope, bool check_man) {
+int verify_units(char **filenames, UnitFileScope scope, bool check_man, bool run_generators) {
_cleanup_(sd_bus_error_free) sd_bus_error err = SD_BUS_ERROR_NULL;
_cleanup_free_ char *var = NULL;
Manager *m = NULL;
@@ -253,6 +253,8 @@ int verify_units(char **filenames, UnitFileScope scope, bool check_man) {
Unit *units[strv_length(filenames)];
int i, count = 0;
+ const uint8_t flags = MANAGER_TEST_RUN_ENV_GENERATORS |
+ run_generators * MANAGER_TEST_RUN_GENERATORS;
if (strv_isempty(filenames))
return 0;
@@ -264,7 +266,7 @@ int verify_units(char **filenames, UnitFileScope scope, bool check_man) {
assert_se(set_unit_path(var) >= 0);
- r = manager_new(scope, MANAGER_TEST_RUN_ENV_GENERATORS, &m);
+ r = manager_new(scope, flags, &m);
if (r < 0)
return log_error_errno(r, "Failed to initialize manager: %m");
diff --git a/src/analyze/analyze-verify.h b/src/analyze/analyze-verify.h
index d8204dc69c..d5466ecdf9 100644
--- a/src/analyze/analyze-verify.h
+++ b/src/analyze/analyze-verify.h
@@ -23,4 +23,8 @@
#include "path-lookup.h"
-int verify_units(char **filenames, UnitFileScope scope, bool check_man);
+int verify_units(
+ char **filenames,
+ UnitFileScope scope,
+ bool check_man,
+ bool run_generators);
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index a6a36a3d2e..0e0fb08922 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -79,6 +79,7 @@ static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
static char *arg_host = NULL;
static bool arg_user = false;
static bool arg_man = true;
+static bool arg_generators = false;
struct boot_times {
usec_t firmware_time;
@@ -1413,6 +1414,7 @@ static void help(void) {
" --fuzz=SECONDS Also print also services which finished SECONDS\n"
" earlier than the latest in the branch\n"
" --man[=BOOL] Do [not] check for existence of man pages\n\n"
+ " --generators[=BOOL] Do [not] run unit generators (requires privileges)\n\n"
"Commands:\n"
" time Print time spent in the kernel\n"
" blame Print list of running units ordered by time to init\n"
@@ -1445,6 +1447,7 @@ static int parse_argv(int argc, char *argv[]) {
ARG_FUZZ,
ARG_NO_PAGER,
ARG_MAN,
+ ARG_GENERATORS,
};
static const struct option options[] = {
@@ -1459,6 +1462,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "fuzz", required_argument, NULL, ARG_FUZZ },
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
{ "man", optional_argument, NULL, ARG_MAN },
+ { "generators", optional_argument, NULL, ARG_GENERATORS },
{ "host", required_argument, NULL, 'H' },
{ "machine", required_argument, NULL, 'M' },
{}
@@ -1541,6 +1545,20 @@ static int parse_argv(int argc, char *argv[]) {
break;
+ case ARG_GENERATORS:
+ if (optarg) {
+ r = parse_boolean(optarg);
+ if (r < 0) {
+ log_error("Failed to parse --generators= argument.");
+ return -EINVAL;
+ }
+
+ arg_generators = !!r;
+ } else
+ arg_generators = true;
+
+ break;
+
case '?':
return -EINVAL;
@@ -1566,7 +1584,8 @@ int main(int argc, char *argv[]) {
if (streq_ptr(argv[optind], "verify"))
r = verify_units(argv+optind+1,
arg_user ? UNIT_FILE_USER : UNIT_FILE_SYSTEM,
- arg_man);
+ arg_man,
+ arg_generators);
else {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;