Skip to content

chown, chgrp: decide --from on the file that is changed - #15029

Open
abendrothj wants to merge 1 commit into
uutils:mainfrom
abendrothj:chown-from-by-fd
Open

abendrothj wants to merge 1 commit into
uutils:mainfrom
abendrothj:chown-from-by-fd

Conversation

@abendrothj

@abendrothj abendrothj commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

--from was checked on a stat of the name and the change was then made by name, so a rename landing in between changed a file that never had the required owner.

On Linux, a non-directory operand and every -R entry are now held open with O_PATH when --from is given, checked to be the file that was stat'd and to still pass --from, and changed through that descriptor with fchownat(AT_EMPTY_PATH). A file found replaced is left alone and counts as a failure, which only -v reports, as GNU 9.12 does for operands and under -L/-H. Under -R -P, GNU 9.12 changes the replacement by name; this leaves it alone too, so here it exits 1 where GNU exits 0. Without --from nothing changes.

Unreadable directory operands, -R -H symlink targets, -R -v failure lines, -h with -H/-L, the descriptor walk on other platforms and holding the file without O_PATH are in follow-ups: #15124, #15125, #15126, #15127, #15128, #15129.

Part of #15027

Copilot AI balanced review requested due to automatic review settings October 2, 2026 08:08

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 reached their quota limit.

@codspeed

codspeed Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 22.03%

⚠️ 121 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

ℹ️ 1 benchmark has no flame graph

The flamegraph could not be generated because too much time was spent in runtime internals, making the visualization not useful for performance analysis.

❌ 2 regressed benchmarks
✅ 399 untouched benchmarks
⏩ 54 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation three_39_bit_primes 583.2 ms 846.7 ms -31.12%
❌ Simulation five_38_bit_primes 1.6 s 1.8 s -11.75%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing abendrothj:chown-from-by-fd (4b43201) with main (6292c03)

Open in CodSpeed

Footnotes

  1. 54 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. ↩

Copilot AI balanced review requested due to automatic review settings October 4, 2026 00:23

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 reached their quota limit.

Copilot AI balanced review requested due to automatic review settings October 5, 2026 06:12

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 reached their quota limit.

@sylvestre

Copy link
Copy Markdown
Contributor

this is too large, can we make it smaller?

Copilot AI balanced review requested due to automatic review settings October 6, 2026 07:15

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 reached their quota limit.

@abendrothj

Copy link
Copy Markdown
Contributor Author

Split it up. This PR now only has the core change, three files, +247/-32: on Linux, with --from, the operand and each -R entry are held open with O_PATH, checked to be the file that was stat'd and to still pass --from, and changed through that descriptor with fchownat(AT_EMPTY_PATH). The rest is in follow-ups, each based on the one before: unreadable directory operands (#15124), --from on symlink targets under -R -H (#15125), -v failure lines for -R entries (#15126), -h with -H/-L (#15127), the descriptor walk on the other platforms (#15128), and holding the file without O_PATH (#15129). Until the earlier ones merge, each diff also shows the commits it's based on.

Copilot AI balanced review requested due to automatic review settings October 7, 2026 08:02

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 reached their quota limit.

--from was checked on a stat of the name and the change was then made
by name, so a rename landing in between changed a file that never had
the required owner.

On Linux, hold the file open with O_PATH, check that it is the one that
was stat'd and still passes --from, and change it through that
descriptor with fchownat(AT_EMPTY_PATH). This covers operands and -R
entries. A file found replaced is left alone; as with GNU, that fails
without a message, and -v reports the change that was not made.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 11:38

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 reached their quota limit.

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.

3 participants