generators enabled will generally result in some warnings.</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--root=<replaceable>PATH</replaceable></option></term>
+
+ <listitem><para>With <command>cat-files</command>, show config files underneath
+ the specified root path <replaceable>PATH</replaceable>.</para></listitem>
+ </varlistentry>
+
<xi:include href="user-system-options.xml" xpointer="host" />
<xi:include href="user-system-options.xml" xpointer="machine" />
static UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
static bool arg_man = true;
static bool arg_generators = false;
+static const char *arg_root = NULL;
struct boot_times {
usec_t firmware_time;
return -EINVAL;
}
- r = conf_files_cat(*arg);
+ r = conf_files_cat(arg_root, *arg);
if (r < 0)
return r;
}
ARG_VERSION = 0x100,
ARG_ORDER,
ARG_REQUIRE,
+ ARG_ROOT,
ARG_SYSTEM,
ARG_USER,
ARG_GLOBAL,
{ "version", no_argument, NULL, ARG_VERSION },
{ "order", no_argument, NULL, ARG_ORDER },
{ "require", no_argument, NULL, ARG_REQUIRE },
+ { "root", required_argument, NULL, ARG_ROOT },
{ "system", no_argument, NULL, ARG_SYSTEM },
{ "user", no_argument, NULL, ARG_USER },
{ "global", no_argument, NULL, ARG_GLOBAL },
case ARG_VERSION:
return version();
+ case ARG_ROOT:
+ arg_root = optarg;
+ break;
+
case ARG_SYSTEM:
arg_scope = UNIT_FILE_SYSTEM;
break;
return -EINVAL;
}
+ if (arg_root && !streq_ptr(argv[optind], "cat-config")) {
+ log_error("Option --root is only supported for cat-config right now.");
+ return -EINVAL;
+ }
+
return 1; /* work to do */
}
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;
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);
}
const char *replacement,
char ***files,
char **replace_file);
-int conf_files_cat(const char *name);
+int conf_files_cat(const char *root, const char *name);