cp: apply the umask to directories created by cp -r - #14576
Open
nagendramohan wants to merge 2 commits into
Open
nagendramohan wants to merge 2 commits into
nagendramohan wants to merge 2 commits into
Conversation
|
GNU testsuite comparison: |
Without a preserve flag, cp -r gave every directory it created the source's mode unmasked, so a 777 source directory became 777 regardless of the umask, while regular files in the same copy were masked correctly. The final permission pass defaulted a freshly-created directory to preserving the source mode. Apply the umask in that defaulted case, as GNU does, while a real preserve (-p/-a) and --no-preserve=mode are unchanged. Fixes uutils#14549 Signed-off-by: nagendramohan <nagendramohan1990@gmail.com>
nagendramohan
force-pushed
the
fix/cp-recursive-dir-umask-14549
branch
from
September 15, 2026 09:39
85226a4 to
a1b323e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Without a preserve flag, cp -r gave every directory it created the source's mode unmasked, so a 777 source directory became 777 regardless of the umask, while regular files in the same copy were masked correctly.
The final permission pass defaulted a freshly-created directory to preserving the source mode. Apply the umask in that defaulted case, as GNU does, while a real preserve (-p/-a) and --no-preserve=mode are unchanged.
Fixes #14549