Skip to content

chown, chgrp: format +ID specs and group-only changes on broken symlinks - #16720

Open
yunusarda-sudo wants to merge 1 commit into
uutils:mainfrom
yunusarda-sudo:fix/chown-verbose-broken-symlink-plus-ids
Open

yunusarda-sudo wants to merge 1 commit into
uutils:mainfrom
yunusarda-sudo:fix/chown-verbose-broken-symlink-plus-ids

Conversation

@yunusarda-sudo

Copy link
Copy Markdown

Fixes #16500

Description

When running chown -v or chgrp -v on a broken symlink, ChownExecutor::traverse reported the failure using self.raw_owner directly and always described it as failing to change "ownership".
This caused two discrepancies with GNU coreutils:

  1. When +UID or :+GID was passed, the leading + was echoed verbatim in the error message (e.g. failed to change ownership of ... to +1000:+1000).
  2. When only the group was modified (or groups_only was set as in chgrp), it printed "failed to change ownership ..." instead of "failed to change group ...".

Changes

  • Implemented target_spec(&self) -> (&'static str, String) in ChownExecutor (src/uucore/src/lib/features/perms.rs) to:
    • Strip leading + from user and group IDs.
    • Return "group" instead of "ownership" when only group is changed or verbosity.groups_only is true.
    • Correctly resolve omitted group to user's login group name/gid if applicable.
  • Unignored test_chown_verbose_broken_symlink_plus_ids in tests/by-util/test_chown.rs.

Strip leading '+' from numeric user/group IDs in verbose diagnostics when
dereferencing a broken symlink fails, and describe group-only modifications
as group changes, matching GNU coreutils.

Fixes uutils#16500

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

1 participant