From: Franck Bui Date: Mon, 14 Mar 2022 08:30:11 +0000 (+0100) Subject: copy: fix wrong argument passed to S_ISREG() in copy_file_fd_full() X-Git-Tag: v251-rc1~155 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=43c893e73e461dd2df6fddbbd1808bb178adf833;p=thirdparty%2Fsystemd.git copy: fix wrong argument passed to S_ISREG() in copy_file_fd_full() Follow-up for 2f782044986a30bf73f1fe00209dbd204b3efe33. --- diff --git a/src/shared/copy.c b/src/shared/copy.c index 09417063562..cc76465fb1c 100644 --- a/src/shared/copy.c +++ b/src/shared/copy.c @@ -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); }