diff options
-rw-r--r-- | man/systemd-sysusers.xml | 12 | ||||
-rw-r--r-- | man/systemd-tmpfiles.xml | 19 | ||||
-rw-r--r-- | src/basic/conf-files.c | 38 |
3 files changed, 44 insertions, 25 deletions
diff --git a/man/systemd-sysusers.xml b/man/systemd-sysusers.xml index 548ce24e4e..895422779d 100644 --- a/man/systemd-sysusers.xml +++ b/man/systemd-sysusers.xml @@ -40,17 +40,17 @@ <citerefentry><refentrytitle>sysusers.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>. </para> - <para>If invoked with no arguments, it applies all directives from all files found in the directories + <para>If invoked with no arguments, directives from the configuration files found in the directories specified by <citerefentry><refentrytitle>sysusers.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>. When invoked with positional arguments, if option <option>--replace=<replaceable>PATH</replaceable></option> is specified, arguments specified on the command line are used instead of the configuration file <replaceable>PATH</replaceable>. Otherwise, just the configuration specified by the command line - arguments is executed. The string <literal>-</literal> may be specified instead of a filename to instruct - <command>systemd-sysusers</command> to read the configuration from standard input. If the argument is a - relative path, all configuration directories are searched for a matching file and the file found that has - the highest priority is executed. If the argument is an absolute path, that file is used directly without - searching of the configuration directories.</para> + arguments is executed. If the string <literal>-</literal> is specified instead of a filename, the + configuration is read from standard input. If the argument is a file name (without any slashes), all + configuration directories are searched for a matching file and the file found that has the highest + priority is executed. If the argument is a path, that file is used directly without searching the + configuration directories for any other matching file.</para> </refsect1> <refsect1> diff --git a/man/systemd-tmpfiles.xml b/man/systemd-tmpfiles.xml index c30a046f72..3a3924a084 100644 --- a/man/systemd-tmpfiles.xml +++ b/man/systemd-tmpfiles.xml @@ -62,14 +62,17 @@ be invoked with one or more options <option>--create</option>, <option>--remove</option>, and <option>--clean</option>, to select the respective subset of operations.</para> - <para>By default, directives from all configuration files are applied. When invoked with - <option>--replace=<replaceable>PATH</replaceable></option>, arguments specified on the command line are - used instead of the configuration file <replaceable>PATH</replaceable>. Otherwise, if one or more - absolute filenames are passed on the command line, only the directives in these files are applied. If - <literal>-</literal> is specified instead of a filename, directives are read from standard input. If only - the basename of a configuration file is specified, all configuration directories as specified in - <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> are - searched for a matching file and the file found that has the highest priority is executed.</para> + <para>If invoked with no arguments, directives from the configuration files found in the directories + specified by + <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>. When + invoked with positional arguments, if option <option>--replace=<replaceable>PATH</replaceable></option> + is specified, arguments specified on the command line are used instead of the configuration file + <replaceable>PATH</replaceable>. Otherwise, just the configuration specified by the command line + arguments is executed. If the string <literal>-</literal> is specified instead of a filename, the + configuration is read from standard input. If the argument is a file name (without any slashes), all + configuration directories are searched for a matching file and the file found that has the highest + priority is executed. If the argument is a path, that file is used directly without searching the + configuration directories for any other matching file.</para> <para>System services (<filename>systemd-tmpfiles-setup.service</filename>, <filename>systemd-tmpfiles-setup-dev-early.service</filename>, diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index c98e7d0d93..9cb66c099b 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -381,8 +381,10 @@ int conf_files_list_dropins( * * The <fn> argument may be: * - '-', meaning stdin. - * - a non-absolute path. In this case <config_dirs> are searched. - * - an absolute path. In this case <fn> is opened directly. + * - a file name without a path. In this case <config_dirs> are searched. + * - a path, either relative or absolute. In this case <fn> is opened directly. + * + * This method is only suitable for configuration files which have a flat layout without dropins. */ int conf_file_read( const char *root, @@ -397,7 +399,7 @@ int conf_file_read( _cleanup_free_ char *_fn = NULL; unsigned v = 0; FILE *f; - int r; + int r = 0; assert(fn); @@ -407,19 +409,33 @@ int conf_file_read( log_debug("Reading config from stdin%s", special_glyph(SPECIAL_GLYPH_ELLIPSIS)); + } else if (is_path(fn)) { + r = path_make_absolute_cwd(fn, &_fn); + if (r < 0) + return log_error_errno(r, "Failed to make path absolute: %m"); + fn = _fn; + + f = _f = fopen(fn, "re"); + if (!_f) + r = -errno; + else + log_debug("Reading config file \"%s\"%s", fn, special_glyph(SPECIAL_GLYPH_ELLIPSIS)); + } else { r = search_and_fopen(fn, "re", root, config_dirs, &_f, &_fn); - if (r == -ENOENT && ignore_enoent) { - log_debug_errno(r, "Failed to open \"%s\", ignoring: %m", fn); - return 0; /* No error, but nothing happened. */ + if (r >= 0) { + f = _f; + fn = _fn; + log_debug("Reading config file \"%s\"%s", fn, special_glyph(SPECIAL_GLYPH_ELLIPSIS)); } - if (r < 0) - return log_error_errno(r, "Failed to read '%s': %m", fn); + } - f = _f; - fn = _fn; - log_debug("Reading config file \"%s\"%s", fn, special_glyph(SPECIAL_GLYPH_ELLIPSIS)); + if (r == -ENOENT && ignore_enoent) { + log_debug_errno(r, "Failed to open \"%s\", ignoring: %m", fn); + return 0; /* No error, but nothing happened. */ } + if (r < 0) + return log_error_errno(r, "Failed to read '%s': %m", fn); r = 1; /* We entered the part where we may modify state. */ |