cp: better permissions mode handling with umask awareness#10904
cp: better permissions mode handling with umask awareness#10904my4ng wants to merge 6 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: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Merging this PR will improve performance by 50.18%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | cp_archive_balanced_tree[(5, 4, 10)] |
76.8 ms | 62.1 ms | +23.7% |
| ⚡ | Simulation | cp_recursive_wide_tree[(6000, 800)] |
187.8 ms | 156.1 ms | +20.28% |
| ⚡ | Simulation | cp_preserve_metadata[(5, 4, 10)] |
73.7 ms | 59.2 ms | +24.43% |
| ⚡ | Simulation | cp_recursive_balanced_tree[(5, 4, 10)] |
71.4 ms | 56.6 ms | +26.06% |
| ⚡ | Simulation | cp_recursive_deep_tree[(120, 4)] |
13.1 ms | 8.7 ms | +50.18% |
Comparing my4ng:cp_mode (8d082ea) with main (b7e967c)
Footnotes
-
46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
There are some residual problems with |
|
GNU testsuite comparison: |
|
@ChrisDryden I have condensed the tests into two instead of the original 12, so it should be a lot more workable now. |
|
GNU testsuite comparison: |
|
Seems with this even applied on top of 0.8.0 we have issues in AerynOS with Script we used to test it: Using this patch on top of 0.8.0 without your patches restores the 0.6.0 behaviour ... |
|
As a follow-up to the above post, it would appear that the basic takeaway from the above test script that I wrote for the AerynOS uutils-coreutils IF we assume that
Effectively, if the source permissions do not reach the umask bitfilter "cap", the target permissions are the same as the source permissions. There may be different implications for the setuid/setgid/sticky bits. Those have not been accounted for here or in the above script. |
|
I think that proofing with my patch on the current 0.8.0 code, preserve is set on new created folders regardless and therefore umask ignored completely... |
Fix CI-failing checks.
|
@hphilm I have rebased my PR to the main branch, and ran your test script and it behaves as expected: All the directory/file tests still pass. Are you using the latest and complete version of this PR? |
|
GNU testsuite comparison: |
|
I just pulled the PR again and compiled it against 4e68e67. However, I still see the "wrong" permissions on AerynOS: See my changes here: AerynOS/recipes@3b4ce86 |
|
@hphilm Could you please provide the strace for the erring directory copy? |
Fix #9750, #10011, #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 existing dir/files, leave existing mode unchanged except when preserving mode.
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/fileone each for directory and file with rstest.improve performance by eliminating redundant heap allocations (e.g. PathBuf, String), ~25% from benchmark.