Repository navigation
fix(chgrp,chown): refuse "." spellings resolved onto the shell root (#1259) - #1266
Merged
Merged
Conversation
…1259) GNU's preserve-root failsafe compares the operand's device+inode against "/", so chown -R --preserve-root X . with a cwd that IS the shell root is refused like "/". The failsafe only matched spellings naming the volume root, so ".", "./" and "././" walked the shell tree. Compare the operand's resolved path against "/" resolved through the same operand layer: it names the shell root when one is configured and the current-drive root otherwise, which is the dev+ino parity target. The refusal prints the "(same as '/')" suffix exactly like MSYS. Fixes #1259. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Merged
5 tasks done
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.
Summary
chown -R --preserve-root X .(and./,././, or any operand resolving to the same directory) from a cwd that IS the shell root used to walk the shell tree: the failsafe only matched spellings naming the volume root./. We now resolve the operand to a full path and compare it against/resolved through the same operand layer — which names the shell root when one is configured (__RUBASH_SHELL_ROOT/NIU_ROOT/WINUXSH_ROOT/RUBASH_ROOT) and the current-drive root otherwise. That is the dev+ino parity target.it is dangerous to operate recursively on '<operand>' (same as '/')+use --no-preserve-root to override this failsafe, matching MSYS.chownandchgrp(twinget_preserve_root_matchimplementations), under-R --preserve-rootonly.No new user-visible strings were introduced — the refusal reuses the existing literals — so no i18n catalog change is required.
Fixes #1259.
Test plan
winuxcmd-tests.exe --gtest_filter=chown.*:chgrp.*— 61/61 passedchown_preserve_root_dot_spellings_at_shell_root_are_rejected/chgrp_..._are_rejected(.,./,././at a configured shell root -> refused with(same as '/'))..._dot_below_shell_root_is_not_refused(cwd under shell root walks normally)..._dot_without_shell_root_is_not_refused(unconfigured root, non-root cwd walks normally)//,///,//e/..,/e/..and the rest of the preserve-root battery) all still pass.Generated with Devin