]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
copy: fix wrong argument passed to S_ISREG() in copy_file_fd_full()
authorFranck Bui <fbui@suse.com>
Mon, 14 Mar 2022 08:30:11 +0000 (09:30 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 14 Mar 2022 15:46:54 +0000 (16:46 +0100)
Follow-up for 2f782044986a30bf73f1fe00209dbd204b3efe33.

src/shared/copy.c

index 09417063562131c4245c91fd052a316d93defc45..cc76465fb1c549d9594a08421cdeb3aa936d3648 100644 (file)
@@ -1214,7 +1214,10 @@ int copy_file_fd_full(
         if (r < 0)
                 return r;
 
-        if (S_ISREG(fdt)) {
+        /* Make sure to copy file attributes only over if target is a regular
+         * file (so that copying a file to /dev/null won't alter the access
+         * mode/ownership of that device node...) */
+        if (S_ISREG(st.st_mode)) {
                 (void) copy_times(fdf, fdt, copy_flags);
                 (void) copy_xattr(fdf, fdt, copy_flags);
         }