1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-18 21:57:48 +03:00

Merge pull request #24459 from poettering/tmpfiles-graceful-copy

tmpfiles: make absent source of "C" copy lines graceful
This commit is contained in:
Lennart Poettering 2022-08-26 15:25:35 +02:00 committed by GitHub
commit bf2cc3865a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View File

@ -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;

View File

@ -116,6 +116,8 @@ test "$(stat -c %U:%G:%a /tmp/C/2/f1)" = "daemon:daemon:755"
systemd-tmpfiles --create - <<EOF
C /tmp/C/3 0755 daemon daemon - /tmp/C/3-origin
C /tmp/C/4 0755 daemon daemon - /tmp/C/definitely-missing
EOF
test "$(stat -c %U:%G:%a /tmp/C/3/f1)" = "root:root:644"
test ! -e /tmp/C/4