f1dd97bb2a9df55fae9b1ca26c829b9f8b290667
- Author
- Marc Cornellà <hello@mcornella.com>
- Committer
- Marc Cornellà <hello@mcornella.com>
- Date
Message
fix(ssh-agent): fix check for running `ssh-agent` process with hidepid /proc (#8492)
Fixes #8492
Diff
1diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
2index c006f141374a120ce434712cfb573cbf7584ac54..47dfef5b064402d1c4c47e37c7f59a8ec1fa618f 100644
3--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
4+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
5@@ -6,9 +6,11 @@ function _start_agent() {
6 if [[ -f "$ssh_env_cache" ]]; then
7 . "$ssh_env_cache" > /dev/null
8
9- {
10- [[ "$USERNAME" = root ]] && command ps ax || command ps x
11- } | command grep ssh-agent | command grep -q $SSH_AGENT_PID && return 0
12+ # Test if $SSH_AUTH_SOCK is visible
13+ zmodload zsh/net/socket
14+ if [[ -S "$SSH_AUTH_SOCK" ]] && zsocket "$SSH_AUTH_SOCK" 2>/dev/null; then
15+ return 0
16+ fi
17 fi
18
19 # Set a maximum lifetime for identities added to ssh-agent