From 5e3f33c0760b43a7d75a7f3769d2baf1d4eb429d Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Tue, 19 Sep 2023 22:27:03 +0200 Subject: [PATCH] Fix git push systemauth --- agent/sockets/callingcontext.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/agent/sockets/callingcontext.go b/agent/sockets/callingcontext.go index c21e97d..76d3063 100644 --- a/agent/sockets/callingcontext.go +++ b/agent/sockets/callingcontext.go @@ -25,9 +25,14 @@ func GetCallingContext(connection net.Conn) CallingContext { } pid, _ := creds.PID() process, err := gops.FindProcess(pid) - if process.Executable() == "ssh-keygen" { - process, err = gops.FindProcess(process.PPid()) - pid = process.Pid() + + // git is epheremal and spawns ssh-keygen and ssh so we need to anchor to git + if process.Executable() == "ssh-keygen" || process.Executable() == "ssh" { + p, e := gops.FindProcess(process.PPid()) + if p.Executable() == "git" && e == nil { + process, err = p, e + pid = process.Pid() + } } uid, _ := creds.UserID()