mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
analyze: allow full paths for cat-config
$ systemd-analyze cat-config systemd/logind.conf $ systemd-analyze cat-config /etc/systemd/logind.conf $ systemd-analyze cat-config /usr/lib/systemd/logind.conf are all equvalent, $ systemd-analyze cat-config /var/systemd/logind.conf is an error.
This commit is contained in:
parent
2e1ec10a62
commit
971f6ea551
@ -82,7 +82,7 @@
|
|||||||
<command>systemd-analyze</command>
|
<command>systemd-analyze</command>
|
||||||
<arg choice="opt" rep="repeat">OPTIONS</arg>
|
<arg choice="opt" rep="repeat">OPTIONS</arg>
|
||||||
<arg choice="plain">cat-config</arg>
|
<arg choice="plain">cat-config</arg>
|
||||||
<arg choice="plain" rep="repeat"><replaceable>NAME</replaceable></arg>
|
<arg choice="plain" rep="repeat"><replaceable>NAME</replaceable>|<replaceable>PATH</replaceable></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>systemd-analyze</command>
|
<command>systemd-analyze</command>
|
||||||
@ -190,7 +190,11 @@
|
|||||||
to <command>systemctl cat</command>, but operates on config files.
|
to <command>systemctl cat</command>, but operates on config files.
|
||||||
It will copy the contents of a config file and any drop-ins to standard
|
It will copy the contents of a config file and any drop-ins to standard
|
||||||
output, using the usual systemd set of directories and rules for
|
output, using the usual systemd set of directories and rules for
|
||||||
precedence.</para>
|
precedence. Each argument must be either an absolute path including
|
||||||
|
the prefix (such as <filename>/etc/systemd/logind.conf</filename> or
|
||||||
|
<filename>/usr/lib/systemd/logind.conf</filename>), or a name
|
||||||
|
relative to the prefix (such as <filename>systemd/logind.conf</filename>).
|
||||||
|
</para>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
<title>Showing logind configuration</title>
|
<title>Showing logind configuration</title>
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "bus-unit-util.h"
|
#include "bus-unit-util.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
#include "calendarspec.h"
|
#include "calendarspec.h"
|
||||||
|
#include "def.h"
|
||||||
#include "conf-files.h"
|
#include "conf-files.h"
|
||||||
#include "glob-util.h"
|
#include "glob-util.h"
|
||||||
#include "hashmap.h"
|
#include "hashmap.h"
|
||||||
@ -1322,6 +1323,8 @@ static int cat_config(int argc, char *argv[], void *userdata) {
|
|||||||
(void) pager_open(arg_no_pager, false);
|
(void) pager_open(arg_no_pager, false);
|
||||||
|
|
||||||
STRV_FOREACH(arg, argv + 1) {
|
STRV_FOREACH(arg, argv + 1) {
|
||||||
|
const char *t = NULL;
|
||||||
|
|
||||||
if (arg != argv + 1)
|
if (arg != argv + 1)
|
||||||
printf("%s%*s%s\n\n",
|
printf("%s%*s%s\n\n",
|
||||||
ansi_underline(),
|
ansi_underline(),
|
||||||
@ -1329,11 +1332,22 @@ static int cat_config(int argc, char *argv[], void *userdata) {
|
|||||||
ansi_normal());
|
ansi_normal());
|
||||||
|
|
||||||
if (path_is_absolute(*arg)) {
|
if (path_is_absolute(*arg)) {
|
||||||
log_error("Arguments must be config file names (relative to /etc/");
|
const char *dir;
|
||||||
return -EINVAL;
|
|
||||||
|
NULSTR_FOREACH(dir, CONF_PATHS_NULSTR("")) {
|
||||||
|
t = path_startswith(*arg, dir);
|
||||||
|
if (t)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = conf_files_cat(arg_root, *arg);
|
if (!t) {
|
||||||
|
log_error("Path %s does not start with any known prefix.", *arg);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
t = *arg;
|
||||||
|
|
||||||
|
r = conf_files_cat(arg_root, t);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user