From 854a42fb2e9db1b9eaa381559d7671f2e9b3a0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 26 Apr 2018 13:49:50 +0200 Subject: analyze: add 'cat-config' verb This is used as 'systemd-analyze show-config systemd/logind.conf', which will dump /etc/systemd/system/user@.service /etc/systemd/system/user@.service.d/*.conf /run/systemd/system/user@.service.d/*.conf /usr/local/lib/systemd/system/user@.service.d/*.conf /usr/lib/systemd/system/user@.service.d/*.conf The idea is to make it easy to dump the configuration using the same locations and order that systemd programs use themselves (including masking, in the right order, etc.). This is the generic variant that works with any configuration scheme that follows the same general rules: $ systemd-analyze cat-config systemd/system.conf $ systemd-analyze cat-config systemd/user.conf $ systemd-analyze cat-config systemd/logind.conf $ systemd-analyze cat-config systemd/sleep.conf $ systemd-analyze cat-config systemd/journald.conf $ systemd-analyze cat-config systemd/journal-remote.conf $ systemd-analyze cat-config systemd/journal-upload.conf $ systemd-analyze cat-config systemd/coredump.conf $ systemd-analyze cat-config systemd/resolved.conf $ systemd-analyze cat-config systemd/timesyncd.conf $ systemd-analyze cat-config udev/udev.conf --- src/basic/terminal-util.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/basic/terminal-util.c') diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 5624c03bce..c2b7cd799e 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -1381,13 +1381,18 @@ static int cat_file(const char *filename, bool newline) { return copy_bytes(fd, STDOUT_FILENO, (uint64_t) -1, 0); } -int cat_files(const char *file, char **dropins) { +int cat_files(const char *file, char **dropins, CatFlags flags) { char **path; int r; if (file) { r = cat_file(file, false); - if (r < 0) + if (r == -ENOENT && (flags & CAT_FLAGS_MAIN_FILE_OPTIONAL)) + printf("%s# config file %s not found%s\n", + ansi_highlight_magenta(), + file, + ansi_normal()); + else if (r < 0) return log_warning_errno(r, "Failed to cat %s: %m", file); } -- cgit v1.2.1