analyze: fix printing config when there is no main config file
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 20 Nov 2021 10:42:31 +0000 (11:42 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 11 Jan 2022 17:44:36 +0000 (18:44 +0100)
commit8621f957b6e3a7eed1c5965d332ad1c4c594f26e
tree92506f1b33ecb4d58ed9a17b33e7d916cdba9aab
parent2124893b258ffc23ae034bce388b61fb148c805f
analyze: fix printing config when there is no main config file

Since 8b8024f1c231c166f5c450905c8fd91d11704ae7 and the follow-up commits, the
main config file may be located in /usr or in other paths. But the code in
analyze.c was still assuming that it must be in /etc. Things mostly worked for
our own config files because we usually install a comments-only file in /etc,
but was not correct in the general case.

This fixes in particular 'systemd-analyze cat-config systemd/zram-generator.conf'.
In Fedora we distribute a config file in zram-generator-defaults.rpm that is in
/usr/lib, and 'cat-config' would refuse to show it because
/etc/systemd/zram-generator.conf does not exist.

The main config file is optional, but let's print an informative message
because this is a slightly unusual case.

The file paths that we printed were missing the root prefix.

(cherry picked from commit 0895e87348e5fc02f50498cad5922eb3eb172323)
src/shared/pretty-print.c