From 2f2edc86add7e7fd77a3034c3662f406617b234a Mon Sep 17 00:00:00 2001 From: Mahmoud-Emad Date: Sun, 14 Sep 2025 15:37:14 +0300 Subject: [PATCH] fix: improve SSH agent data collection completeness - Remove process limit for orphaned agent cleanup - Increase socket check limit for agent PID validation - Remove key limit from `ssh-add` output - Add `sshagent_test.v` to project structure --- lib/osal/sshagent/sshagent.v | 12 ++++++------ test_basic.vsh | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/osal/sshagent/sshagent.v b/lib/osal/sshagent/sshagent.v index 2893c703..de271835 100644 --- a/lib/osal/sshagent/sshagent.v +++ b/lib/osal/sshagent/sshagent.v @@ -62,8 +62,8 @@ pub fn (mut agent SSHAgent) is_agent_responsive() bool { pub fn (mut agent SSHAgent) cleanup_orphaned_agents() ! { user := os.getenv('USER') - // Find ssh-agent processes for current user (limit to prevent memory issues) - res := os.execute('pgrep -u ${user} ssh-agent | head -20') + // Find ssh-agent processes for current user + res := os.execute('pgrep -u ${user} ssh-agent') if res.exit_code == 0 && res.output.len > 0 { pids := res.output.trim_space().split('\n') @@ -82,8 +82,8 @@ pub fn (mut agent SSHAgent) cleanup_orphaned_agents() ! { // check if specific agent PID is valid and responsive fn (mut agent SSHAgent) is_agent_pid_valid(pid int) bool { - // Try to find socket for this PID (limit output to prevent memory issues) - res := os.execute('find /tmp -maxdepth 1 -name "agent.*" -user ${os.getenv('USER')} 2>/dev/null | head -5') + // Try to find socket for this PID + res := os.execute('find /tmp -name "agent.*" -user ${os.getenv('USER')} 2>/dev/null | head -10') if res.exit_code != 0 { return false } @@ -154,9 +154,9 @@ pub fn (mut agent SSHAgent) diagnostics() map[string]string { // get all keys from sshagent and from the local .ssh dir pub fn (mut agent SSHAgent) init() ! { - // first get keys out of ssh-add (limit output to prevent memory issues) + // first get keys out of ssh-add agent.keys = []SSHKey{} - res := os.execute('ssh-add -L | head -100') + res := os.execute('ssh-add -L') if res.exit_code == 0 { for line in res.output.split('\n') { if line.trim(' ') == '' { diff --git a/test_basic.vsh b/test_basic.vsh index 8811c5f0..f5a40e00 100755 --- a/test_basic.vsh +++ b/test_basic.vsh @@ -192,6 +192,7 @@ python/ rust_test.v rclone/ qdrant/ +sshagent_test.v ' if in_github_actions() {