host: bind /tmp/.wine-<uid> to disk when /tmp is tmpfs #502

Merged
smith-3 merged 1 commit from upstream-pr/502 into main 2026-11-29 18:28:36 +00:00
smith-3 commented 2026-11-29 17:26:42 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by smith-3 on 2026-11-29T17:26:42Z.


Fixes #419.

Summary

On Linux systems where /tmp is mounted as tmpfs, wineserver still creates /tmp/.wine-<uid> under /tmp (it ignores TMPDIR and rejects symlinks), so deleted-but-open tmpmap-* files remain in RAM (shmem) and can exhaust memory during large allocations.

Changes

  • project_tuxbox/host.py:
    • Added path_is_tmpfs() to inspect /proc/self/mounts using longest-prefix mount matching (with octal escape decoding).
    • Added wrap_wine_server_dir() to wrap Linux launches in bwrap --die-with-parent --dev-bind / / --perms 0700 --dir /tmp/.wine-<uid> --bind <prefix>/wine-server /tmp/.wine-<uid> -- whenever /tmp/.wine-<uid> resolves to tmpfs and bwrap succeeds a quick true probe.
    • Falls back cleanly with a status warning when bwrap is unavailable or restricted, and skips wrapping when /tmp/.wine-<uid> is already on a disk-backed filesystem.
  • docs/PROJECTSCARLETT.md: Documented the automatic bwrap bind-mount behavior and manual mode-0700 fallback note.
  • tests/test_host.py: Added WineServerDiskMount unit tests covering /proc/self/mounts longest-prefix detection, bwrap command wrapping with 0o700 directory creation, and disk/no-bwrap fallback behavior.

Verification

  • python -m unittest tests/test_host.py tests/test_cli.py tests/test_repository_hygiene.py — 55 tests OK.
  • Verified bwrap --die-with-parent --dev-bind / / --perms 0700 --dir /tmp/.wine-<uid> --bind <dir> /tmp/.wine-<uid> -- succeeds on Linux (including when nested with unshare --user --map-current-user --net).
<!-- greyfinch-sync:brcly/TuxBox:issue:5553220467 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/502). Originally posted by [smith-3](https://github.com/smith-3) on 2026-11-29T17:26:42Z. --- Fixes #419. ### Summary On Linux systems where `/tmp` is mounted as `tmpfs`, `wineserver` still creates `/tmp/.wine-<uid>` under `/tmp` (it ignores `TMPDIR` and rejects symlinks), so deleted-but-open `tmpmap-*` files remain in RAM (`shmem`) and can exhaust memory during large allocations. ### Changes - **`project_tuxbox/host.py`**: - Added `path_is_tmpfs()` to inspect `/proc/self/mounts` using longest-prefix mount matching (with octal escape decoding). - Added `wrap_wine_server_dir()` to wrap Linux launches in `bwrap --die-with-parent --dev-bind / / --perms 0700 --dir /tmp/.wine-<uid> --bind <prefix>/wine-server /tmp/.wine-<uid> --` whenever `/tmp/.wine-<uid>` resolves to `tmpfs` and `bwrap` succeeds a quick `true` probe. - Falls back cleanly with a status warning when `bwrap` is unavailable or restricted, and skips wrapping when `/tmp/.wine-<uid>` is already on a disk-backed filesystem. - **`docs/PROJECTSCARLETT.md`**: Documented the automatic `bwrap` bind-mount behavior and manual mode-`0700` fallback note. - **`tests/test_host.py`**: Added `WineServerDiskMount` unit tests covering `/proc/self/mounts` longest-prefix detection, `bwrap` command wrapping with `0o700` directory creation, and disk/no-`bwrap` fallback behavior. ### Verification - `python -m unittest tests/test_host.py tests/test_cli.py tests/test_repository_hygiene.py` — 55 tests OK. - Verified `bwrap --die-with-parent --dev-bind / / --perms 0700 --dir /tmp/.wine-<uid> --bind <dir> /tmp/.wine-<uid> --` succeeds on Linux (including when nested with `unshare --user --map-current-user --net`).
copilot-pull-request-reviewer[bot] commented 2026-11-29 17:26:52 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-29T17:26:52Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:brcly/TuxBox:review:6103967123 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/502#pullrequestreview-6103967123). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-29T17:26:52Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
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
brcly/TuxBox!502
No description provided.