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 @@ sysusers.d5. - If invoked with no arguments, it applies all directives from all files found in the directories + If invoked with no arguments, directives from the configuration files found in the directories specified by sysusers.d5. When invoked with positional arguments, if option is specified, arguments specified on the command line are used instead of the configuration file PATH. Otherwise, just the configuration specified by the command line - arguments is executed. The string - may be specified instead of a filename to instruct - systemd-sysusers 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. + arguments is executed. If the string - 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. 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 , , and , to select the respective subset of operations. - By default, directives from all configuration files are applied. When invoked with - , arguments specified on the command line are - used instead of the configuration file PATH. Otherwise, if one or more - absolute filenames are passed on the command line, only the directives in these files are applied. If - - 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 - tmpfiles.d5 are - searched for a matching file and the file found that has the highest priority is executed. + If invoked with no arguments, directives from the configuration files found in the directories + specified by + tmpfiles.d5. When + invoked with positional arguments, if option + is specified, arguments specified on the command line are used instead of the configuration file + PATH. Otherwise, just the configuration specified by the command line + arguments is executed. If the string - 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. System services (systemd-tmpfiles-setup.service, systemd-tmpfiles-setup-dev-early.service, 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 argument may be: * - '-', meaning stdin. - * - a non-absolute path. In this case are searched. - * - an absolute path. In this case is opened directly. + * - a file name without a path. In this case are searched. + * - a path, either relative or absolute. In this case 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,20 +409,34 @@ 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. */ for (;;) {