Skip to content

fix(install): preserve setuid/setgid bits after chown operations - #9150

Closed
naoNao89 wants to merge 1 commit into
uutils:mainfrom
naoNao89:fix-install-setuid
Closed

naoNao89 wants to merge 1 commit into
uutils:mainfrom
naoNao89:fix-install-setuid

Conversation

@naoNao89

@naoNao89 naoNao89 commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

Fixes #9134

install -m4755 failed to set special permission bits because chown strips them for security. Added second chmod call after chown and improved error handling with libc::chmod for proper special bit support. Updated callers to handle io::Error and added localized error messages. and tests included.

@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@naoNao89
naoNao89 force-pushed the fix-install-setuid branch 7 times, most recently from 6d3cf3b to 370c1e7 Compare November 5, 2025 19:16
@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@github-actions

github-actions Bot commented Nov 6, 2025

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@naoNao89 naoNao89 closed this by deleting the head repository Nov 6, 2025
@naoNao89 naoNao89 reopened this Nov 7, 2025
@codspeed

codspeed Bot commented Nov 7, 2025 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 287 untouched benchmarks
⏩ 38 skipped benchmarks1


Comparing naoNao89:fix-install-setuid (c9bbeaf) with main (1e95554)

Open in CodSpeed

Footnotes

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

@github-actions

github-actions Bot commented Nov 7, 2025

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@github-actions

github-actions Bot commented Nov 8, 2025

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/base64 is no longer failing!

@github-actions

github-actions Bot commented Nov 8, 2025

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@naoNao89
naoNao89 force-pushed the fix-install-setuid branch 2 times, most recently from 17ac24b to 246d338 Compare November 8, 2025 23:20
@github-actions

github-actions Bot commented Nov 8, 2025

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@naoNao89
naoNao89 force-pushed the fix-install-setuid branch 5 times, most recently from 959661c to 79b05e6 Compare November 9, 2025 00:04
@github-actions

github-actions Bot commented Nov 9, 2025

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

@naoNao89
naoNao89 force-pushed the fix-install-setuid branch 2 times, most recently from 6ce3a00 to 97a50f9 Compare November 13, 2025 12:18
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@naoNao89 naoNao89 closed this Nov 13, 2025
@naoNao89 naoNao89 reopened this Nov 13, 2025
@naoNao89
naoNao89 force-pushed the fix-install-setuid branch 3 times, most recently from 467ccd5 to 64187bf Compare November 13, 2025 14:01
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@sylvestre

Copy link
Copy Markdown
Contributor

sorry, it needs to be rebased!

@naoNao89
naoNao89 force-pushed the fix-install-setuid branch 3 times, most recently from fce3d31 to b0c02d9 Compare January 3, 2026 08:36
@github-actions

github-actions Bot commented Jan 3, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/shuf/shuf-reservoir. tests/shuf/shuf-reservoir is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@naoNao89

naoNao89 commented Jan 3, 2026

Copy link
Copy Markdown
Contributor Author

the test failures are infrastructure or intermittent issues, not regressions caused by our changes to the install utility.

@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)
Congrats! The gnu test tests/date/date-locale-hour is no longer failing!
Note: The gnu test tests/tail/pipe-f is now being skipped but was previously passing.
Congrats! The gnu test tests/cp/link-heap is now passing!

@naoNao89
naoNao89 force-pushed the fix-install-setuid branch 4 times, most recently from 5ec5fe3 to e3f4d2b Compare February 17, 2026 18:13
@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)
Congrats! The gnu test tests/date/date-locale-hour is no longer failing!
Congrats! The gnu test tests/cp/link-heap is now passing!

Special permission bits were being lost when install chowned files, since
chown inherently strips setuid/setgid bits for security. This change applies
a second chmod after chown to preserve those bits.

The fix:
- Uses libc::chmod for proper special bit support
- Updates error handling with io::Error conversion
- Adds comprehensive test coverage
- Maintains behavior for non-special permissions
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/misc/io-errors. tests/misc/io-errors is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/date/date-locale-hour is no longer failing!
Note: The gnu test tests/pr/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/seq/seq-epipe is now being skipped but was previously passing.
Congrats! The gnu test tests/cp/link-heap is now passing!

@sylvestre

Copy link
Copy Markdown
Contributor

hi, this one can't be merged as it is:

  • it needs a rebase
  • tests/by-util/test_install.rs: this removes several existing tests (symlink race, -U, suffix without backup, comma separated mode...), probably a bad rebase. please restore them
  • tests/by-util/test_install.rs: no -o/-g here, so chown is never called and this doesn't test the fix. please add a test with --owner/--group
  • src/uu/install/src/mode.rs: why the switch to libc::chmod? fs::set_permissions already calls chmod, so this only adds unsafe (and no SAFETY comment)
  • src/uu/install/src/install.rs: install-error-chmod-failed takes $path, not $error, so the path is missing. Also ChmodFailed is returned right after, so the error gets printed twice
  • src/uu/install/src/install.rs: could we only do this when chown actually ran? now it's a second chmod on every install also almost the same block as above, could be dedup
    could you please have a look? otherwise, i will close it, thanks

@naoNao89

Copy link
Copy Markdown
Contributor Author

checked this against current main and it looks like the original issue has already been addressed upstream.

b7e037ff9 removed the unnecessary root chown, and 7c87ab0 (#13629) fixed the ownership/mode ordering.

I also compared the compiled GNU, main, and PR binaries. Main matches GNU on the relevant success and failure paths, while this PR's older implementation can still leave setuid bits set when chown fails.

So there's no useful fix left to carry forward here. I'll close this as superseded. Thanks for the review!

@naoNao89 naoNao89 closed this Nov 18, 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.

setuid bits are not set when using install

2 participants