cp: better permissions mode handling with umask awareness#10904
cp: better permissions mode handling with umask awareness#10904my4ng wants to merge 3 commits intouutils:mainfrom
Conversation
|
GNU testsuite comparison: |
|
Is there any way to split this PR up into something smaller? When its this big it gets pretty hard to review |
|
I'm afraid not. Most changes are actually from the noise of propagating There is a GNU test regression: tests/cp/cp-parents, caused by the second to last test in that file due to created parent dir not having attributes set correctly. Will fix soon. |
|
GNU testsuite comparison: |
|
|
||
| #[test] | ||
| #[cfg(unix)] | ||
| fn test_cp_existing_no_preserve_file() { |
There was a problem hiding this comment.
I'm going to take a closer look at the overall logic later, but do you think it would be possible to use some of the built in integ test utilities for doing chmod and for creating files to condese the amount of code here. Do you think it also would be possible to parametrize the tests a bit more too to make it smaller and easier to read?
There was a problem hiding this comment.
What do you mean by integ test utilities? I think it should be possible to condense the twelve into one with some for loops, but I am not sure how readable or easily usable it becomes when it fails, but I will try it out.
There was a problem hiding this comment.
Also another problem is that there would have to be cleanup in between the various test cases if condensed, which makes it even more complex. I think keep them as separate tests is the best way to go.
|
GNU testsuite comparison: |
Fix #10787, #10862, Supersede #10859.
This PR reworks the permissions mode handling such that its behaviour is in line with GNU's implementation. Specifically:
set umask to !0o077, which means (1) cp can actually create and work with new directories/files which will have 700 permissions mode before their final calculated mode is set. the original umask is kept and passed around for calculation in the case of newly created and non-mode-preserving dir/files. umask is restored to original on exit.
for explicit non-mode-preserving, newly created dir/files, use 777 and 666 modes for calculation respectively.
for newly created dir/files, always set their permission mode to the correct one.
added 12 new tests for the combination of existing/not-existing, no-preserve/default/preserve, dir/file.