Skip to content

fix: keep Linux helper reexec stable after binary replacement - #21

Closed
Chillizu wants to merge 1 commit into
Xeift:mainfrom
Chillizu:fix/linux-helper-reexec
Closed

Chillizu wants to merge 1 commit into
Xeift:mainfrom
Chillizu:fix/linux-helper-reexec

Conversation

@Chillizu

@Chillizu Chillizu commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • prefer /proc/self/exe when spawning the Linux Landlock helper
  • fall back to current_exe() when procfs is unavailable
  • add coverage for the helper executable selection

Why

If the CatDesk binary is replaced while the process is still running, current_exe() can resolve to the old deleted pathname. The next run_command / background command then fails to spawn the Landlock helper with ENOENT. /proc/self/exe continues to reference the live executable inode, so self-reexec remains available across an atomic binary replacement.

Verification

  • cargo test --release: 219 passed, 0 failed
  • changed Rust file formatted with rustfmt
  • git diff --check: clean

Note: repository-wide cargo fmt --check currently reports an unrelated pre-existing formatting diff in src/browser.rs on main.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when launching the CatDesk helper command in Linux sandboxed environments.
    • The application now more consistently identifies its executable, with a fallback for systems where the preferred path is unavailable.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: c8433f56-20aa-4e86-b38c-853b650bb6e5

📥 Commits

Reviewing files that changed from the base of the PR and between bfac47b and ad77f2e.

📒 Files selected for processing (1)
  • src/linux_sandbox.rs

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The sandbox helper command now resolves its executable from /proc/self/exe when available and falls back to current_exe(). A test verifies the preferred path. Landlock imports are reformatted.

Changes

Helper executable resolution

Layer / File(s) Summary
Executable lookup and validation
src/linux_sandbox.rs
The new helper_executable helper prefers /proc/self/exe and falls back to std::env::current_exe(). helper_command uses the helper, and a test verifies the preferred path. Landlock imports are reordered.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to ad77f

Sandbox helper reexecution now uses the live executable through /proc/self/exe when available, preserving operation after atomic binary replacement while retaining the existing fallback. The change is ready to merge.

Suggested reviewers: xeift

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: keeping Linux helper re-execution stable after binary replacement.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.97.1)

Clippy execution timed out


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.

@Xeift

Xeift commented Sep 15, 2026

Copy link
Copy Markdown
Owner

@Chillizu Yo, sorry for the late response. I've been busy and recently moved back home, so I haven't been able to review PRs in time.

Since we switched from Landlock to Bubblewrap in #14, this fix is no longer needed on main, so I've decided to close this PR. Truly appreciate the contribution!

@Xeift Xeift closed this Sep 15, 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.

2 participants