tmpfiles: propagate copy errors after opening target
Opening the destination only proves that it exists. If copy_tree_at()
failed for any reason other than an existing destination, report that
copy error.
Reproducer:
name=tmpfiles-copy-bug.$$
src=/tmp/$name.src; dst=/tmp/$name.dst; conf=/tmp/$name.conf
mkdir "$src" "$dst"
printf payload >"$src/file"
chmod 500 "$dst"
printf 'C %s - - - - %s\n' "$dst" "$src" >"$conf"
systemd-tmpfiles --create "$conf"
Before:
exit=0
copied=no
Follow-up for 8f6fb95cd0.
This commit is contained in:
@@ -2238,6 +2238,9 @@ static int copy_files(Context *c, Item *i) {
|
||||
return log_error_errno(errno, "Failed to openat(%s): %m", i->path);
|
||||
}
|
||||
|
||||
if (r < 0 && !IN_SET(r, -EEXIST, -EROFS))
|
||||
return log_error_errno(r, "Failed to copy files to %s: %m", i->path);
|
||||
|
||||
if (fstat(fd, &st) < 0)
|
||||
return log_error_errno(errno, "Failed to fstat(%s): %m", i->path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user