Skip to content

chown: print parsed IDs and use 'group' when only group is specified (#16500) - #16611

Open
Rajpal14 wants to merge 5 commits into
uutils:mainfrom
Rajpal14:fix/16500-chown-verbose-broken-symlink-plus-id
Open

Rajpal14 wants to merge 5 commits into
uutils:mainfrom
Rajpal14:fix/16500-chown-verbose-broken-symlink-plus-id

Conversation

@Rajpal14

@Rajpal14 Rajpal14 commented Nov 17, 2026 •

Copy link
Copy Markdown

Fixes #16500.

Problem

When chown -v encountered a broken symlink that cannot be dereferenced, traverse() in perms.rs echoed self.raw_owner verbatim and hardcoded "failed to change ownership" even when only a group was specified:

  • chown -v +1000 ghost printed failed to change ownership of 'ghost' to +1000 (GNU prints 1000).
  • chown -v :+1000 ghost printed failed to change ownership of 'ghost' to :+1000 (GNU prints failed to change group of 'ghost' to 1000).

Solution

  • Extracted format_target_ownership(&self) -> (&'static str, String) in src/uucore/src/lib/features/perms.rs to format destination owner/group without a leading + when a numeric ID specification is used.
  • Formats the action as "group" when only a group is specified (or when groups_only is set).
  • Handles both : and . as user/group separators without breaking dotted usernames (john.doe).
  • Un-ignored and extended test_chown_verbose_broken_symlink_plus_ids in tests/by-util/test_chown.rs.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 08:31

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Comment thread src/uucore/src/lib/features/perms.rs Resolved
Copilot AI balanced review requested due to automatic review settings November 17, 2026 09:30

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Comment thread src/uucore/src/lib/features/perms.rs Resolved
Comment thread src/uucore/src/lib/features/perms.rs Resolved
Copilot AI balanced review requested due to automatic review settings November 17, 2026 09:57

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.49 MB (+108 KB, +0.07%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)

@sylvestre

Copy link
Copy Markdown
Contributor

rustfmt is sad :)
could you please run cargo fmt?

Diff in /home/runner/work/coreutils/coreutils/src/uucore/src/lib/features/perms.rs:285:
             }
         }

-        let action = if self.verbosity.groups_only
-            || (self.dest_uid.is_none() && self.dest_gid.is_some())
-        {
-            "group"
-        } else {
-            "ownership"
-        };
+        let action =
+            if self.verbosity.groups_only || (self.dest_uid.is_none() && self.dest_gid.is_some()) {
+                "group"
+            } else {
+                "ownership"
+            };

         // Handle both ':' and '.' as user/group separators (e.g. "user:group" or "user.group").
         let dest = if let Some((u, g)) = self

Comment thread src/uucore/src/lib/features/perms.rs Resolved
Comment thread src/uucore/src/lib/features/perms.rs Resolved
Comment thread src/uucore/src/lib/features/perms.rs Resolved
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/env/env0-from is no longer failing!

Copilot AI balanced review requested due to automatic review settings November 18, 2026 04:18

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@Rajpal14
Rajpal14 requested a lite review from Copilot November 18, 2026 04:20

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.

Copilot review overview

No open issues 🎉

Review effort: Lite

Copilot AI lite review requested due to automatic review settings November 18, 2026 12:00
@Rajpal14

Rajpal14 commented Nov 18, 2026 •

Copy link
Copy Markdown
Author

Hi @sylvestre, I've addressed all the feedback:

  • BOM removed from both perms.rs and test_chown.rs
  • resolve_part now takes u32 directly - call sites use .map(|id|
  • Dotted username bug fixed - . separator is only tried when dest_gid is set, so john.doe style usernames are not affected
  • cargo fmt applied - the action= block is now formatted as rustfmt expects

Thank you for the thorough review! Please let me know if anything else needs adjusting.

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.

Copilot review overview

3 open issues

Review effort: Lite

Comment thread src/uucore/src/lib/features/perms.rs Resolved
Comment thread src/uucore/src/lib/features/perms.rs Resolved
Comment thread tests/by-util/test_chown.rs Resolved
@Rajpal14
Rajpal14 requested review from sylvestre and an adaptive review from Copilot November 18, 2026 12:26

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.

Comment thread src/uucore/src/lib/features/perms.rs Resolved
Comment thread src/uucore/src/lib/features/perms.rs Resolved
Comment thread src/uucore/src/lib/features/perms.rs Resolved
@codspeed

codspeed Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning, 1 note

⚠️ 121 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

✅ 413 untouched benchmarks
⏩ 70 skipped benchmarks1


Comparing Rajpal14:fix/16500-chown-verbose-broken-symlink-plus-id (ec7e925) with main (293a724)2

Open in CodSpeed

Footnotes

  1. 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (ff000c2) during the generation of this report, so 293a724 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Rajpal14 and others added 3 commits November 19, 2026 21:59
… in format_target_ownership

Address two review comments from @sylvestre:

- Extract a small resolve_part(spec, id) helper to eliminate four identical
  `if spec.starts_with('+') { id } else { spec }` blocks.
- Handle '.' as a user/group separator in addition to ':' so that
  `chown -v +1000.+1000 ghost` correctly prints`1000:1000` instead of
  dropping the group.
- Add a test case for the dot-separator form in test_chown_verbose_broken_symlink_plus_ids.
…t signature

Address three review comments from @sylvestre:

- Remove UTF-8 BOM that was inadvertently added to perms.rs and test_chown.rs.
- Change resolve_part to take u32 instead of Option<u32> and use it as
  self.dest_uid.map(|id| resolve_part(u, id)).unwrap_or_default() so the
  call sites are cleaner (suggested at line 302).
- Only attempt to split on '.' when dest_gid is set, so that dotted user
  names like 'john.doe' (a real user with no group) are not incorrectly
  split at the dot (bug reported at line 300).
- Add a colon-separator test case (+UID:GID) alongside the dot-separator
  case in test_chown_verbose_broken_symlink_plus_ids.
Fix rustfmt formatting as requested by @sylvestre: reformat the
action= conditional to fit on fewer lines per rustfmt style.
@sylvestre
sylvestre force-pushed the fix/16500-chown-verbose-broken-symlink-plus-id branch from ec7e925 to a12cfbb Compare November 19, 2026 20:59
Copilot AI adaptive review requested due to automatic review settings November 19, 2026 20:59

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
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.

chown -v: +ID spec echoed verbatim on a broken symlink

3 participants