Fix copyfile() not preserving source mode with restrictive umask

copyfile() passes the source mode to open(2), which applies the umask,
so a 0644 file copied with umask 0027 ends up 0640.

Apply the source mode with fchmod() after creating the destination.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-09-13 18:53:40 +02:00
1 parent e874608b76
commit b69d8a6013
3 files changed
+34 -1

No files matched your search

+2
View File
@@ -8,6 +8,8 @@ All notable changes to the project are documented in this file.
--------------
### Fixes
- Fix `copyfile()` not preserving the source file mode when the process
umask is more restrictive
- Fix `mkpath()`, and `fmkpath()`, not applying the given mode when the
process umask is more restrictive, e.g., requesting 0755 with umask
0027 silently created a 0750 directory