fix(tools): preserve controller command access #5582

Merged
JJenkx merged 4 commits from upstream-pr/5582 into main 2026-10-15 11:23:04 +00:00
JJenkx commented 2026-10-14 00:15:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-14T00:15:38Z.


What

The controller-command helper writes through an atomic replacement. Its temporary file always had mode 0600 and the writer's ownership, so a privileged test helper replacing a game user's command file silently made future controller pulses unreadable to the game.

Retain an existing POSIX command file's permission mode. When the helper runs privileged, also retain its owner and group. Newly created files retain the existing private temporary-file defaults. Windows behavior is unchanged. Document the behavior in the usage guide.

Tested

  • Full Linux and Windows fork CI passes for head 2d14128a29ec, containing main d1670009fbfd: Linux 1,037 passed / 46 skipped; Windows 714 passed / 389 skipped. Expected skips remain unvalidated.
  • All ten controller-command tests pass locally, including sequence rollover, malformed input, button/stick schema and error preservation.
  • Both new regressions fail before the production change: mode 0640 becomes 0600, and an unprivileged subprocess cannot read the command file after privileged replacement. With the fix, the original owner reads the actual replacement file and verifies its command contents and owner/group.
  • Native Astro testing exposed the access failure. Correcting the writer allowed injected input to advance the title screen on the combined integration; this tool change alone does not establish game compatibility.
  • Local conventions and whitespace checks pass.

Checklist

  • Based on current main; no equivalent open helper fix found
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • No silent stubs added
  • No notes, investigation files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none; test-helper access fix
  • GPUs tested: n/a; Python tool change
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4851130949 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5582). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-14T00:15:38Z. --- ### What The controller-command helper writes through an atomic replacement. Its temporary file always had mode 0600 and the writer's ownership, so a privileged test helper replacing a game user's command file silently made future controller pulses unreadable to the game. Retain an existing POSIX command file's permission mode. When the helper runs privileged, also retain its owner and group. Newly created files retain the existing private temporary-file defaults. Windows behavior is unchanged. Document the behavior in the usage guide. ### Tested - [Full Linux and Windows fork CI](https://github.com/JJenkx/AnyPS5/actions/runs/38486851002) passes for head `2d14128a29ec`, containing main `d1670009fbfd`: Linux 1,037 passed / 46 skipped; Windows 714 passed / 389 skipped. Expected skips remain unvalidated. - All ten controller-command tests pass locally, including sequence rollover, malformed input, button/stick schema and error preservation. - Both new regressions fail before the production change: mode 0640 becomes 0600, and an unprivileged subprocess cannot read the command file after privileged replacement. With the fix, the original owner reads the actual replacement file and verifies its command contents and owner/group. - Native Astro testing exposed the access failure. Correcting the writer allowed injected input to advance the title screen on the combined integration; this tool change alone does not establish game compatibility. - Local conventions and whitespace checks pass. ### Checklist - [x] Based on current main; no equivalent open helper fix found - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] No silent stubs added - [x] No notes, investigation files or images added to the repository - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none; test-helper access fix - [x] GPUs tested: n/a; Python tool change - [x] AI-assisted: yes
adriadam10 commented 2026-10-15 11:20:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T11:20:35Z.


Checked on the PR merged onto main: pad_input tests pass, and the mode-retention regression fails when the production change is reverted. The privileged owner/group test needs root and is skipped on my host; the code path (fchown before fchmod on the temp file, then os.replace) reads correctly. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6190841466 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5582#issuecomment-6190841466). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-15T11:20:35Z. --- Checked on the PR merged onto main: `pad_input` tests pass, and the mode-retention regression fails when the production change is reverted. The privileged owner/group test needs root and is skipped on my host; the code path (`fchown` before `fchmod` on the temp file, then `os.replace`) reads correctly. Merging once the full Build is green.
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!5582
No description provided.