feat(libkernel): implement setregid #4595

Merged
jagrat04 merged 1 commit from upstream-pr/4595 into main 2026-10-12 21:06:28 +00:00
jagrat04 commented 2026-10-12 16:27:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-10-12T16:27:29Z.


What

Exports setregid (ROILLZdYZPc) in libkernel, following FreeBSD's sys_setregid and the existing root credential identity model used by setuid, seteuid, setegid and setreuid:

  • Real and effective group ID 0 or -1 (0xffffffffu unchanged) are accepted and change nothing, returning 0.
  • Any other group ID throws std::runtime_error("setregid: unsupported...").
  • Extends GuestCredentials.cpp unit test to cover setregid and setreuid error paths, and updates docs/dev/TechnicalDebt.md.

Closes part of #3558.

Tested

tools/check_conventions.py --base origin/main
Unit test assertions in core/libs/tests/GuestCredentials.cpp

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4832208702 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4595). Originally posted by [jagrat04](https://github.com/jagrat04) on 2026-10-12T16:27:29Z. --- ### What Exports `setregid` (`ROILLZdYZPc`) in libkernel, following FreeBSD's `sys_setregid` and the existing root credential identity model used by `setuid`, `seteuid`, `setegid` and `setreuid`: - Real and effective group ID 0 or -1 (`0xffffffffu` unchanged) are accepted and change nothing, returning 0. - Any other group ID throws `std::runtime_error("setregid: unsupported...")`. - Extends `GuestCredentials.cpp` unit test to cover `setregid` and `setreuid` error paths, and updates `docs/dev/TechnicalDebt.md`. Closes part of #3558. ### Tested tools/check_conventions.py --base origin/main Unit test assertions in core/libs/tests/GuestCredentials.cpp ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current main; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation .md files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-12 16:44:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T16:44:33Z.


Progress report (a60f52e → 057b810)

📈 System libraries: 86.37% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel setregid_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6128593383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4595#issuecomment-6128593383). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T16:44:33Z. --- <!-- progress-report --> ### Progress report (a60f52e → 057b810) 📈 **System libraries**: 86.37% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `setregid_nid_postfix` | </details>
github-actions[bot] commented 2026-10-12 20:09:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T20:09:43Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4734 docs/dev/debt/libkernel.md L63
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6131786363 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4595#issuecomment-6131786363). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T20:09:43Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4734 | `docs/dev/debt/libkernel.md` [L63](https://github.com/boykopovar/AnyPS5/blob/6f438a1c2e23dadf4c00284b4e797d02596f949e/docs/dev/debt/libkernel.md#L63) | | |
adriadam10 commented 2026-10-12 21:06:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T21:06:23Z.


Checked against FreeBSD sys_setregid and the existing setreuid/setegid model: 0 and -1 are accepted and change nothing, other ids throw. Build and ctest pass (guest_credentials), and the test fails to link without the change. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132608804 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4595#issuecomment-6132608804). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T21:06:23Z. --- Checked against FreeBSD `sys_setregid` and the existing `setreuid`/`setegid` model: 0 and -1 are accepted and change nothing, other ids throw. Build and ctest pass (`guest_credentials`), and the test fails to link without the change. Merging.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4595
No description provided.