diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 07432a1e51..8012d0d5df 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -3082,6 +3082,14 @@ static int parse_line( if (r < 0) return r; + if (!path_is_absolute(i.path)) { + *invalid_config = true; + return log_syntax(NULL, LOG_ERR, fname, line, SYNTHETIC_ERRNO(EBADMSG), + "Path '%s' not absolute.", i.path); + } + + path_simplify(i.path); + switch (i.type) { case CREATE_DIRECTORY: @@ -3153,6 +3161,13 @@ static int parse_line( } path_simplify(i.argument); + + if (laccess(i.argument, F_OK) == -ENOENT) { + /* Silently skip over lines where the source file is missing. */ + log_syntax(NULL, LOG_INFO, fname, line, 0, "Copy source path '%s' does not exist, skipping line.", i.argument); + return 0; + } + break; case CREATE_CHAR_DEVICE: @@ -3231,14 +3246,6 @@ static int parse_line( "Unknown command type '%c'.", (char) i.type); } - if (!path_is_absolute(i.path)) { - *invalid_config = true; - return log_syntax(NULL, LOG_ERR, fname, line, SYNTHETIC_ERRNO(EBADMSG), - "Path '%s' not absolute.", i.path); - } - - path_simplify(i.path); - if (!should_include_path(i.path)) return 0; diff --git a/test/units/testsuite-22.02.sh b/test/units/testsuite-22.02.sh index 0719d68292..49c55f136b 100755 --- a/test/units/testsuite-22.02.sh +++ b/test/units/testsuite-22.02.sh @@ -116,6 +116,8 @@ test "$(stat -c %U:%G:%a /tmp/C/2/f1)" = "daemon:daemon:755" systemd-tmpfiles --create - <