diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-27 08:55:16 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-27 10:06:24 +0200 |
commit | 46d8646a9fd637b8911ac032cb2a760407221f9a (patch) | |
tree | 875a4e98ce7886c68723b2eb74afd03cc9daf499 /src/basic/conf-files.c | |
parent | sysctl: add --cat-config (diff) | |
download | systemd-46d8646a9fd637b8911ac032cb2a760407221f9a.tar.xz systemd-46d8646a9fd637b8911ac032cb2a760407221f9a.zip |
analyze: add --root option for cat-config
Diffstat (limited to 'src/basic/conf-files.c')
-rw-r--r-- | src/basic/conf-files.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index 29a85c018a..00e4629668 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -294,8 +294,9 @@ int conf_files_list_with_replacement( return 0; } -int conf_files_cat(const char *name) { +int conf_files_cat(const char *root, const char *name) { _cleanup_strv_free_ char **dirs = NULL, **files = NULL; + _cleanup_free_ char *path = NULL; const char *dir; char **t; int r; @@ -307,19 +308,21 @@ int conf_files_cat(const char *name) { return log_error("Failed to build directory list: %m"); } - r = conf_files_list_strv(&files, ".conf", NULL, 0, (const char* const*) dirs); + r = conf_files_list_strv(&files, ".conf", root, 0, (const char* const*) dirs); if (r < 0) return log_error_errno(r, "Failed to query file list: %m"); - name = strjoina("/etc/", name); + path = path_join(root, "/etc", name); + if (!path) + return log_oom(); if (DEBUG_LOGGING) { log_debug("Looking for configuration in:"); - log_debug(" %s", name); + log_debug(" %s", path); STRV_FOREACH(t, dirs) log_debug(" %s/*.conf", *t); } /* show */ - return cat_files(name, files, CAT_FLAGS_MAIN_FILE_OPTIONAL); + return cat_files(path, files, CAT_FLAGS_MAIN_FILE_OPTIONAL); } |