refactor: rename VMFile to FileWrapper#75
Merged
BlackHole1 merged 1 commit intooomol-lab:mainfrom Feb 27, 2025
Merged
Conversation
BlackHole1
approved these changes
Feb 27, 2025
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.