diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 5c520ac068..72781a49b7 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -2249,8 +2249,8 @@ static int copy_files(Context *c, Item *i) { if (fstat(fd, &st) < 0) return log_error_errno(errno, "Failed to fstat(%s): %m", i->path); - if (stat(i->argument, &a) < 0) - return log_error_errno(errno, "Failed to stat(%s): %m", i->argument); + if (lstat(i->argument, &a) < 0) + return log_error_errno(errno, "Failed to lstat(%s): %m", i->argument); if (((st.st_mode ^ a.st_mode) & S_IFMT) != 0) { log_debug("Can't copy to %s, file exists already and is of different type", i->path); diff --git a/test/units/TEST-22-TMPFILES.03.sh b/test/units/TEST-22-TMPFILES.03.sh index c36f8f8790..390932ec97 100755 --- a/test/units/TEST-22-TMPFILES.03.sh +++ b/test/units/TEST-22-TMPFILES.03.sh @@ -209,6 +209,15 @@ test ! -e /tmp/C-copy-failure-dst/file chmod 755 /tmp/C-copy-failure-dst rm -rf /tmp/C-copy-failure-src /tmp/C-copy-failure-dst +rm -f /tmp/C-copy-link-src /tmp/C-copy-link-dst +ln -s missing-target /tmp/C-copy-link-src +systemd-tmpfiles --create - <