summaryrefslogtreecommitdiff
path: root/src/tmpfiles
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-08-25 17:16:02 +0200
committerLennart Poettering <lennart@poettering.net>2022-08-26 11:11:48 +0200
commitce610af143b2a11011f00c65ea96f7a88453373b (patch)
tree22d6f6ba415c446bd7fe21702d99aad3c3e52857 /src/tmpfiles
parent1a0e065e9f154f46fd68cd45f46310bc7df7a51c (diff)
downloadsystemd-ce610af143b2a11011f00c65ea96f7a88453373b.tar.gz
tmpfiles: in C lines, make missing source graceful error
I don't see where it would ever be a good thing that file copies done via tmpfiles.d/ C lines cause the tmpfiles operation to fail if their source happens to be missing. It's a problem if we can't set up the destination properly (which is the job of systemd-tmpfiles after all), but if the source is simply missing (NB: setting up the source is the job of of the rules writer) this shouldn't be a problem. This is useful for copying stuff into place if it happens to exist. For example, if systemd-stub passes additional data into the initrd's /.extra/ directory, we can copy it into a better place (e.g. /run/) with this, where it will survive the initrd→host transition. This mirrors behaviour of the recently added "^" line modifier which may be used source "w" lines from credentials – there two the behaviour is to simply skip the line if the source is missing.
Diffstat (limited to 'src/tmpfiles')
-rw-r--r--src/tmpfiles/tmpfiles.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 07432a1e51..4bbf9b4ace 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -3153,6 +3153,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: