Skip to content

chcon: cover the fd-based traversal; rewrite some comments to describe our own code - #14526

Closed
sylvestre wants to merge 2 commits into
mainfrom
comments-rewrite-chcon-tests
Closed

chcon: cover the fd-based traversal; rewrite some comments to describe our own code#14526
sylvestre wants to merge 2 commits into
mainfrom
comments-rewrite-chcon-tests

Conversation

@sylvestre

@sylvestre sylvestre commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

No description provided.

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.
Copilot AI lite review requested due to automatic review settings September 12, 2026 21:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 chcon tests 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, and df to 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();
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/pr/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/io-errors (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/csplit/csplit-heap is now being skipped but was previously passing.
Congrats! The gnu test tests/seq/seq-epipe is now passing!
Congrats! The gnu test tests/tail/pipe-f is now passing!

@sylvestre sylvestre closed this Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants