coreutils
coreutils copied to clipboard
install: create destination file with safer modes before copy
This is a followup PR to #6595.
Regarding the unconditional removal of the destination file problem, before this patch, the destination file is removed unconditionally when copy_file is called. Now a healthy check is added, which only removes the destination file if the source file exists and can be opened to read.
Furthermore, this patch uses std::io::copy with file descriptors to avoid the chmod 644 problem in the original patch. This is verified using strace.
A new test case is added as well.
Ping @mjguzik.
GNU testsuite comparison:
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
sorry but it needs to be rebased
ping @nerdroychan
please reopen when ready