launcher: write the Linux run script to /tmp instead of the game directory (#974) #996

Closed
github-bot wants to merge 1 commit from gh-pr/996/head into gh-pr/996/base
Owner

@⁠Jitheswar on GitHub · 2026-10-03 09:36 UTC · original
fix/linux-temporary-run-script → main · +325 −112 · 6 files · 1 commits · closed without merging

Fixes #974.

On Linux the launcher wrote kyty_run.sh next to the emulator binary, which fails when
that directory is read-only.

Changes

  • Move the run-script and terminal-detection code into src/launcher/linux/linuxRunScript.cpp.
  • Create the script with QTemporaryFile as /tmp/kytyps5_run_XXXXXX.sh (user-only
    permissions, unique per launch). /tmp is fixed rather than QDir::tempPath() so the
    path can't contain spaces that terminals which re-parse their command line would split.
  • Emulator arguments stay quoted inside the script, and the terminal receives only
    bash <script>.
  • The script deletes itself on exit. The launcher also deletes it if the process fails to
    start, and removes this user's leftover scripts older than one day on the next launch.
  • Show the "Press any key..." prompt only when stdin is a terminal.
  • Add the launcher_run_script ctest and include it in Linux CI.

Testing

I had rebuild launcher and launcher_run_script_tests (both built successfully) and run ctest --test-dir Build/linux -R '^launcher_run_script$' --output-on-failure. The result was 1/1 passed (launcher_run_script, 0.01 s), with no /tmp/kytyps5_run* files left afterwards. That test makes its fake game folder read-only and checks that the script is created in /tmp and that arguments with spaces, apostrophes and empty values are passed through unchanged

Known limitations

  • If waitForStarted times out, the script stays until the next launch's cleanup.
  • Flatpak or Snap terminals with a private /tmp won't see the script.
  • If the test fails, it can leave its temporary game directory read-only and a script in /tmp.

AI involvement

I used AI tools to draft the code, the test and this description, and an AI review pass
suggested the /tmp approach and the comments. I reviewed the changes, ran the tests
listed above myself, and I'm responsible for the submission.

**@⁠Jitheswar** on GitHub · 2026-10-03 09:36 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/996) `fix/linux-temporary-run-script` → `main` · +325 −112 · 6 files · 1 commits · closed without merging Fixes #974. On Linux the launcher wrote `kyty_run.sh` next to the emulator binary, which fails when that directory is read-only. ### Changes - Move the run-script and terminal-detection code into `src/launcher/linux/linuxRunScript.cpp`. - Create the script with `QTemporaryFile` as `/tmp/kytyps5_run_XXXXXX.sh` (user-only permissions, unique per launch). `/tmp` is fixed rather than `QDir::tempPath()` so the path can't contain spaces that terminals which re-parse their command line would split. - Emulator arguments stay quoted inside the script, and the terminal receives only `bash <script>`. - The script deletes itself on exit. The launcher also deletes it if the process fails to start, and removes this user's leftover scripts older than one day on the next launch. - Show the "Press any key..." prompt only when stdin is a terminal. - Add the `launcher_run_script` ctest and include it in Linux CI. ### Testing I had rebuild launcher and launcher_run_script_tests (both built successfully) and run ctest --test-dir _Build/linux -R '^launcher_run_script$' --output-on-failure. The result was 1/1 passed (launcher_run_script, 0.01 s), with no /tmp/kytyps5_run_* files left afterwards. That test makes its fake game folder read-only and checks that the script is created in /tmp and that arguments with spaces, apostrophes and empty values are passed through unchanged ### Known limitations - If `waitForStarted` times out, the script stays until the next launch's cleanup. - Flatpak or Snap terminals with a private `/tmp` won't see the script. - If the test fails, it can leave its temporary game directory read-only and a script in `/tmp`. ### AI involvement I used AI tools to draft the code, the test and this description, and an AI review pass suggested the `/tmp` approach and the comments. I reviewed the changes, ran the tests listed above myself, and I'm responsible for the submission.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:39:49 +00:00
github-bot closed this pull request 2026-11-26 09:39:49 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-03 09:41 UTC · original

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d938e35c-7d35-41d1-8a5b-60ab28e9a136
📥 Commits

Reviewing files that changed from the base of the PR and between e6cb880adb and 30a6dacd4c.

📒 Files selected for processing (6)
  • .github/workflows/build.yml
  • src/launcher/CMakeLists.txt
  • src/launcher/include/linuxRunScript.h
  • src/launcher/linux/linuxRunScript.cpp
  • src/launcher/src/mainDialog.cpp
  • tests/LauncherRunScriptTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Linux launcher script creation and terminal selection moved into LinuxRunScript::Prepare. The helper creates a temporary Bash script, configures QProcess, and returns failure if script creation or flushing fails. The launcher handles preparation and process-start failures. A standalone test covers script preparation and execution, and the Linux workflow builds and runs that test.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 30a6d

The Linux launcher now writes its run script to a private temporary file instead of the game directory. No concrete merge-blocking risk was found.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 30a6d

Private, uniquely named scripts improve isolation while preserving existing execution authority. No new cross-user attack path was established. Remaining uncertainty concerns filesystem isolation between the launcher and terminal, and cleanup after interrupted launches.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated execution scope remains the launching user's local emulator and terminal processes. The new helper supplies neither an elevated identity nor an external service endpoint. Same-UID interference remains outside the demonstrated file-isolation guarantee.

Security Findings and Attack Paths

  • inferred — The inspected handoff does not establish a newly introduced metadata-to-shell injection path: interpreter and argument quoting match the base, and terminal selection remains separate. Downstream emulator interpretation and the complete provenance of every configuration field were not assessed.

Trust Boundaries and Controls

  • inferred — Unique QTemporaryFile creation and owner-only permissions constrain ordinary cross-user reading and replacement under standard /tmp protection. The file is closed before Bash opens its pathname, so these controls do not establish protection against hostile same-UID replacement or nonstandard filesystem permissions.

Resilience and Maintainability Implications

  • observed — Cleanup covers write failure, normal Bash exit and explicit FailedToStart, but timeout, interruption or terminal startup without script consumption can leave a private script for later age-based recovery. Deletion uses pathnames rather than durable identities. These limitations do not alone demonstrate a security regression over the base's persistent script.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning [#974] requests that kyty_run.sh be generated at build time. LinuxRunScript::Prepare still creates the script at runtime with QTemporaryFile, now under /tmp. This avoids writing beside the emu… Generate or package the run script at build time instead of creating it at runtime.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: Linux run scripts move from the game directory to /tmp.
Description check ✅ Passed The description explains the Linux run-script change, its behavior, testing, and known limitations.
Out of Scope Changes check ✅ Passed The Linux run-script changes, tests, and CI updates all support the launcher behavior addressed by [#974]. No unrelated changes are identified.
Full details: Linked Issues check

Explanation

[#974] requests that kyty_run.sh be generated at build time. LinuxRunScript::Prepare still creates the script at runtime with QTemporaryFile, now under /tmp. This avoids writing beside the emulator but does not meet the build-time generation requirement.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. (2 skipped: 2 unsupported.)

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-03 09:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/996#issuecomment-5967882062) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/996?cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `d938e35c-7d35-41d1-8a5b-60ab28e9a136` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between e6cb880adbfb6a9f7b0f6f47fa6b44c57ff4d3a4 and 30a6dacd4cb38f70d7f1e76b1fe88c2ff64e1e77. </details> <details> <summary>📒 Files selected for processing (6)</summary> * `.github/workflows/build.yml` * `src/launcher/CMakeLists.txt` * `src/launcher/include/linuxRunScript.h` * `src/launcher/linux/linuxRunScript.cpp` * `src/launcher/src/mainDialog.cpp` * `tests/LauncherRunScriptTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough Linux launcher script creation and terminal selection moved into `LinuxRunScript::Prepare`. The helper creates a temporary Bash script, configures `QProcess`, and returns failure if script creation or flushing fails. The launcher handles preparation and process-start failures. A standalone test covers script preparation and execution, and the Linux workflow builds and runs that test. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"30a6dacd4cb38f70d7f1e76b1fe88c2ff64e1e77" --> **Change:** Bug fix · **Severity of issue fixed:** Low <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `30a6d` <!-- final_review_risk_coverage:{"sourceCommitId":"30a6dacd4cb38f70d7f1e76b1fe88c2ff64e1e77","coveredCommitId":"30a6dacd4cb38f70d7f1e76b1fe88c2ff64e1e77","kind":"reviewed"} --> The Linux launcher now writes its run script to a private temporary file instead of the game directory. No concrete merge-blocking risk was found. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🔵 Low_ · up to `30a6d` Private, uniquely named scripts improve isolation while preserving existing execution authority. No new cross-user attack path was established. Remaining uncertainty concerns filesystem isolation between the launcher and terminal, and cleanup after interrupted launches. **Retained concerns** No architecture-level concerns identified. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — The demonstrated execution scope remains the launching user's local emulator and terminal processes. The new helper supplies neither an elevated identity nor an external service endpoint. Same-UID interference remains outside the demonstrated file-isolation guarantee. **Security Findings and Attack Paths** - _inferred_ — The inspected handoff does not establish a newly introduced metadata-to-shell injection path: interpreter and argument quoting match the base, and terminal selection remains separate. Downstream emulator interpretation and the complete provenance of every configuration field were not assessed. **Trust Boundaries and Controls** - _inferred_ — Unique QTemporaryFile creation and owner-only permissions constrain ordinary cross-user reading and replacement under standard /tmp protection. The file is closed before Bash opens its pathname, so these controls do not establish protection against hostile same-UID replacement or nonstandard filesystem permissions. **Resilience and Maintainability Implications** - _observed_ — Cleanup covers write failure, normal Bash exit and explicit FailedToStart, but timeout, interruption or terminal startup without script consumption can leave a private script for later age-based recovery. Deletion uses pathnames rather than durable identities. These limitations do not alone demonstrate a security regression over the base's persistent script. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 3 | ❌ 2</summary> ### ❌ Failed checks (2 warnings) | Check name | Status | Explanation | Resolution | | :-----------------: | :--------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------- | | Linked Issues check | ⚠️ Warning | [`#974`] requests that `kyty_run.sh` be generated at build time. `LinuxRunScript::Prepare` still creates the script at runtime with `QTemporaryFile`, now under `/tmp`. This avoids writing beside the emu… | Generate or package the run script at build time instead of creating it at runtime. | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. (2 skipped: … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (3 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly summarizes the main change: Linux run scripts move from the game directory to /tmp. | | Description check | ✅ Passed | The description explains the Linux run-script change, its behavior, testing, and known limitations. | | Out of Scope Changes check | ✅ Passed | The Linux run-script changes, tests, and CI updates all support the launcher behavior addressed by [`#974`]. No unrelated changes are identified. | </details> <details> <summary>Full details: Linked Issues check</summary> **Explanation** [`#974`] requests that `kyty_run.sh` be generated at build time. `LinuxRunScript::Prepare` still creates the script at runtime with `QTemporaryFile`, now under `/tmp`. This avoids writing beside the emulator but does not meet the build-time generation requirement. </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. (2 skipped: 2 unsupported.) </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=996)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.