diff --git a/src/analyze/analyze-verify-util.c b/src/analyze/analyze-verify-util.c index ce572ce4619..eed997ce45a 100644 --- a/src/analyze/analyze-verify-util.c +++ b/src/analyze/analyze-verify-util.c @@ -232,9 +232,13 @@ static int verify_documentation(Unit *u, bool check_man) { if (check_man && startswith(*p, "man:")) { k = show_man_page(*p + 4, true); if (k != 0) { - if (k < 0) - log_unit_error_errno(u, k, "Can't show %s: %m", *p + 4); - else { + if (k < 0) { + const char *hint = ""; + + if (find_executable("man", /* ret_filename= */ NULL) == -ENOENT) + hint = ", man may not be installed, pass --man=no to skip"; + log_unit_error_errno(u, k, "Can't show %s%s: %m", *p + 4, hint); + } else { log_unit_error(u, "Command 'man %s' failed with code %d", *p + 4, k); k = -ENOEXEC; } diff --git a/test/units/TEST-65-ANALYZE.sh b/test/units/TEST-65-ANALYZE.sh index 05a7b7f0c16..2cf0cb750f5 100755 --- a/test/units/TEST-65-ANALYZE.sh +++ b/test/units/TEST-65-ANALYZE.sh @@ -491,6 +491,19 @@ systemd-analyze verify /tmp/multi-exec-start.service echo 'ExecStart=command-should-not-exist' >>/tmp/multi-exec-start.service (! systemd-analyze verify /tmp/multi-exec-start.service) +# test that a missing man binary is reported as such, and that --man=no skips the check. +cat </tmp/man-documentation.service +[Unit] +Documentation=man:systemd(1) + +[Service] +Type=oneshot +ExecStart=/usr/bin/true +EOF +(! env PATH=/nonexistent "$(command -v systemd-analyze)" verify /tmp/man-documentation.service 2>/tmp/man-documentation.log) +grep "man may not be installed" /tmp/man-documentation.log >/dev/null +env PATH=/nonexistent "$(command -v systemd-analyze)" verify --man=no /tmp/man-documentation.service + # Prevent regression from #20233 where systemd-analyze will return nonzero exit codes on warnings # Unit file with warning "Unknown key name 'foo' in section 'Unit', ignoring"