summaryrefslogtreecommitdiffstats
path: root/src/analyze/analyze-cat-config.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
commit55944e5e40b1be2afc4855d8d2baf4b73d1876b5 (patch)
tree33f869f55a1b149e9b7c2b7e201867ca5dd52992 /src/analyze/analyze-cat-config.c
parentInitial commit. (diff)
downloadsystemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.tar.xz
systemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.zip
Adding upstream version 255.4.upstream/255.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/analyze/analyze-cat-config.c')
-rw-r--r--src/analyze/analyze-cat-config.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/analyze/analyze-cat-config.c b/src/analyze/analyze-cat-config.c
new file mode 100644
index 0000000..66bbbc1
--- /dev/null
+++ b/src/analyze/analyze-cat-config.c
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "analyze.h"
+#include "analyze-cat-config.h"
+#include "conf-files.h"
+#include "constants.h"
+#include "nulstr-util.h"
+#include "path-util.h"
+#include "pretty-print.h"
+#include "strv.h"
+
+int verb_cat_config(int argc, char *argv[], void *userdata) {
+ char **list;
+ int r;
+
+ pager_open(arg_pager_flags);
+
+ list = strv_skip(argv, 1);
+ STRV_FOREACH(arg, list) {
+ const char *t = NULL;
+
+ if (arg != list)
+ print_separator();
+
+ if (path_is_absolute(*arg)) {
+ NULSTR_FOREACH(dir, CONF_PATHS_NULSTR("")) {
+ t = path_startswith(*arg, dir);
+ if (t)
+ break;
+ }
+
+ if (!t)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Path %s does not start with any known prefix.", *arg);
+ } else
+ t = *arg;
+
+ r = conf_files_cat(arg_root, t, arg_cat_flags);
+ if (r < 0)
+ return r;
+ }
+
+ return EXIT_SUCCESS;
+}