Skip to content

refactor: rename VMFile to FileWrapper#75

Merged
BlackHole1 merged 1 commit intooomol-lab:mainfrom
ihexon:FileWrapper
Feb 27, 2025
Merged

refactor: rename VMFile to FileWrapper#75
BlackHole1 merged 1 commit intooomol-lab:mainfrom
ihexon:FileWrapper

Conversation

@ihexon
Copy link
Collaborator

@ihexon ihexon commented Feb 27, 2025

No description provided.

@ihexon ihexon requested a review from BlackHole1 as a code owner February 27, 2025 07:30
@BlackHole1 BlackHole1 merged commit 8b2c4c7 into oomol-lab:main Feb 27, 2025
2 checks passed
@ihexon ihexon deleted the FileWrapper branch April 21, 2025 07:44
ihexon added a commit to ihexon/ovm-mac that referenced this pull request Jan 16, 2026
…and security (oomol-lab#75)

This commit completely redesigns the SSH client implementation with better architecture, resource management, and security features.

## Key Changes
### SSH Package Redesign
  - Implement layered architecture: Client -> Session -> Executor
  - Add proper lifecycle management with sync.Once and RWMutex
  - Introduce dedicated config types (ClientConfig, SessionConfig, ExecOptions)
  - Fix race conditions in keepalive loop by using local variable copies
  - Resolve "already closed" connection errors with isErrorIsConnectionAlreadyClosed()
  - Add comprehensive package documentation (doc.go)

### Security Improvements
  - Use shellescape.QuoteCommand() to prevent command injection vulnerabilities
  - Properly escape shell arguments in command execution

 ### Resource Management
  - Add automatic keepalive with configurable intervals (default: 5s)
  - Implement proper defer-based cleanup for all resources
  - Fix pipe management: close writers (not readers) to signal EOF correctly
  - Add WaitGroup-based I/O synchronization to prevent goroutine leaks

### Terminal Handling (pkg/system/terminal.go)
  - Fix signal handler leak by adding defer signal.Stop(ch)
  - Improve terminal state management with wrapper types
  - Add terminal type and size auto-detection
  - Enhance PTY resize handling with proper context cancellation

### API Changes
  - Migrate from old monolithic ssh.Cfg to layered Client/Session/Executor
  - Remove manual cleanup callbacks in favor of defer-based patterns
  - cmd/attach.go: Refactor to use new SSH API with proper PTY/non-PTY handling
  - pkg/server/exec.go: Fix resource management by closing client in goroutine
  - pkg/vmconfig: Update SSH key generation and connection probing

### Dependencies
  - Add al.essio.dev/pkg/shellescape for safe command escaping
  - Add github.com/google/shlex for command parsing
  - Add github.com/mattn/go-isatty for reliable terminal detection

### Miscellaneous
  - Improve server mode logging with String() method
  - Update libkrun bindings (libkrun_v2.go replaces libkrun.go)
  - Remove unused install_name_tool.sh script line

## Testing
  - Verified attach command works in both PTY and non-PTY modes
  - Confirmed REST API exec functionality
  - Tested SSH connection probing during VM startup
  - Validated proper resource cleanup under various scenarios
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