-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chmod: Correct chmod -R on dangling symlink and tests #7618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chmod: Correct chmod -R on dangling symlink and tests #7618
Conversation
6f5a2c1
to
f04bb82
Compare
GNU testsuite comparison:
|
GNU testsuite comparison:
|
tests/by-util/test_chmod.rs
Outdated
.stdout_is("") | ||
.stderr_is(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify this to .no_output()
.
I think your PR is only a partial solution and it breaks some functionality that currently works. Before your changes: $ cargo run -q --features=unix chmod 755 -R dangling_symlink
chmod: cannot operate on dangling symlink 'dangling_symlink'
$ echo $?
1
$ cargo run -q --features=unix chmod 755 -R -P dangling_symlink
chmod: cannot operate on dangling symlink 'dangling_symlink'
$ echo $?
1 After your changes: $ cargo run -q --features=unix chmod 755 -R dangling_symlink
$ echo $?
0
$ cargo run -q --features=unix chmod 755 -R -P dangling_symlink
$ echo $?
0 And what GNU $ chmod 755 -R dangling_symlink
chmod: cannot operate on dangling symlink 'dangling_symlink'
$ echo $?
1
$ chmod 755 -R -P dangling_symlink
$ echo $?
0 |
Ah I did not fully understand the flag interaction mentioned at the bottom of the issue, thank you for the examples. Will fix that up tonight, and add the extra unit test for that failure case |
A couple of different learnings while fully grokking the flag combinations here:
I have added tests for each of these scenarios, plus extended the unit tests for all of the positive and negative unit tests for all the dangling link scenarios. For functionality, I have fixed the original bug, and I have fixed the default traversal flag. I have not yet fixed the
|
GNU testsuite comparison:
|
Because the This PR should be ready to review again! |
GNU testsuite comparison:
|
I created a Lima VM locally to match the SELinux build steps and see what the test failure is. Tried to match the GH workflow as much as possible, but had to install the rust toolchain myself in the VM.
And then after running the test suite, I wasn't able to reproduce the test failure:
Is it possible that this is a test flake? What's the best way to proceed here? |
Great :) And thanks for your PR! |
* Correct chmod -R on dangling symlink and tests * Add tests of arg-level symlink to chmod * Add tests of all symlink flag combos on chmod dangling * Fix no traverse on dangling symlink * Add chmod recursive tests of default symlink method * Add default chmod -H flag tests * Set chmod default traversal method correctly to -H * Fix arg symlink chmod case * Remove extra chmod -H testing --------- Co-authored-by: Clifford Ressel <EMAIL@gmail.com>
Fixes #7214