Skip to content

fix: prevent app hanging when executing sudo commands #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

delorenj
Copy link

@delorenj delorenj commented Jul 3, 2025

Summary

  • Fixes app becoming unresponsive when executing commands requiring sudo password
  • Adds proactive detection and clear error messaging for sudo commands
  • Includes comprehensive test coverage

Problem

When opencode executes a command requiring sudo password, the bash tool spawns the process without stdin connected, causing it to hang indefinitely waiting for password input that can never be provided.

Solution

Added sudo command detection in the bash tool that:

  1. Checks if commands start with sudo
  2. Detects sudo after common command separators (;, &&, ||, |)
  3. Throws a clear error message before execution
  4. Suggests alternative approaches without elevated privileges

Test Coverage

Added comprehensive tests in bash.test.ts:

  • ✅ Rejects commands starting with sudo
  • ✅ Rejects sudo in command chains
  • ✅ Allows commands with "sudo" in non-command context
  • ✅ Snapshot test for error message consistency
  • ✅ Basic bash functionality tests

Related

Fixes #652

🤖 Generated with opencode

actions-user and others added 3 commits July 2, 2025 12:34
- Add detection for sudo commands in bash tool
- Check for sudo at start of command and after common separators (;, &&, ||, |)
- Provide clear error message explaining sudo is not supported
- Add comprehensive test coverage for sudo detection

Fixes sst#652

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <[email protected]>
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.

App becomes unresponsive when executing commands requiring sudo password
2 participants