chcon: cover the fd-based traversal; rewrite some comments to describe our own code - #14526
Closed
sylvestre wants to merge 2 commits into
Closed
chcon: cover the fd-based traversal; rewrite some comments to describe our own code#14526sylvestre wants to merge 2 commits into
sylvestre wants to merge 2 commits into
Conversation
The existing tests pass unchanged whether a directory is labelled before or after its contents, whether a failed descent still relabels the directory, and whether following symlinks reports a cycle. Each of those went wrong while moving off fts and none of them was caught. Lock in the four: post-order labelling, an unreadable directory being reported and left alone, a symlink loop under -L staying quiet, and operands with several path components.
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Pull request overview
Adds regression tests for chcon’s fd-based recursive traversal semantics (SELinux feature) and updates internal comments across several utilities to describe this implementation rather than GNU wording.
Changes:
- Add four new recursive-path
chcontests covering post-order directory relabeling, unreadable directories, symlink loops with-L, and multi-component operands. - Rewrite/clarify comments in
tail,rm,ptx,pathchk,mknod,hostid, anddfto document current code behavior more accurately.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/by-util/test_chcon.rs | Adds new SELinux-backed tests covering fd-walk traversal semantics and operand resolution behaviors. |
| src/uu/tail/src/follow/watch.rs | Refines comments describing truncation handling and --max-unchanged-stats intent. |
| src/uu/rm/src/rm.rs | Clarifies prompting semantics and documents hidden test-only CLI switch rationale. |
| src/uu/ptx/src/ptx.rs | Explains output-width arithmetic constraints relative to GNU-compatible layout. |
| src/uu/pathchk/src/pathchk.rs | Corrects/clarifies empty-operand behavior documentation to match code path. |
| src/uu/mknod/src/mknod.rs | Clarifies device-type parsing behavior (leading-character dispatch). |
| src/uu/hostid/src/hostid.rs | Explains why masking is needed when gethostid value arrives in a c_long. |
| src/uu/df/src/df.rs | Improves commentary for mount entry preference rules. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| cmd.args(&["--recursive", "guest_u:object_r:etc_t:s0:c42"]) | ||
| .arg(dir.plus("noread")) | ||
| .fails() | ||
| .stderr_contains("Reading directory"); |
Comment on lines
+631
to
+641
| dir.set_mode("noread", 0o000); | ||
|
|
||
| let before = get_file_context(dir.plus("noread")).unwrap(); | ||
|
|
||
| cmd.args(&["--recursive", "guest_u:object_r:etc_t:s0:c42"]) | ||
| .arg(dir.plus("noread")) | ||
| .fails() | ||
| .stderr_contains("Reading directory"); | ||
|
|
||
| dir.set_mode("noread", 0o755); | ||
| assert_eq!(get_file_context(dir.plus("noread")).unwrap(), before); |
| .args(&["--recursive", "-L", "guest_u:object_r:etc_t:s0:c42"]) | ||
| .arg(dir.plus("t")) | ||
| .succeeds(); | ||
| result.no_stderr(); |
|
GNU testsuite comparison: |
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.
No description provided.