Repository navigation
Conversation
--dereference and -h were independent flags and --dereference was tested first, so a later -h was ignored and the link's target was changed. They now override each other like -H/-L/-P. Fixes uutils#15791
This branch has not been deployed
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.
Fixes #15791
chown,chgrpandchmodtake--dereferenceand-h/--no-dereferencefromcommon_args(). The two were independent flags, andconfigure_symlink_and_recursiontests--dereferencefirst. So with--dereference -hboth flags were set,-hwas ignored, and the command followed the symlink and changed its target.-H,-Land-Palready override each other, andchcondoes the same for this pair.--dereferencenow carries.overrides_with(NO_DEREFERENCE). clap applies this in both directions, so the last of the two options wins whichever order they come in.One side effect:
-R --dereference -hused to fail with "-R --dereference requires -H or -L" and is now accepted, because-hwins.-R -h --dereferencestill fails with that message.I added one test per utility (
test_chown_dereference_then_no_dereference, and the same for chgrp and chmod). chown and chgrp use a dangling symlink and the caller's own uid/gid, so no root is needed:--dereference -hmust succeed and-h --dereferencemust fail with "cannot dereference". chmod checks the target's mode after each order. The three tests fail on current main and pass with this change. I also ran the issue's option sequences through the CLI before and after as an unprivileged user.cargo fmt --all -- --check,cargo clippy --all-targets -- -D warningsat the repo root, andcargo test --no-default-features --features "chown chgrp chmod" --test tests -- test_chown:: test_chgrp:: test_chmod::pass. Tested on macOS only.