goldwarden-vaultwarden-bitw.../cli/agent/ssh/sshsocketwindows.go

40 lines
994 B
Go
Raw Normal View History

2024-02-04 00:08:25 +01:00
//go:build windows
package ssh
import (
2024-02-04 00:24:40 +01:00
"github.com/Microsoft/go-winio"
2024-05-04 01:06:24 +02:00
"github.com/quexten/goldwarden/cli/agent/sockets"
2024-02-04 00:08:25 +01:00
"golang.org/x/crypto/ssh/agent"
)
func (v SSHAgentServer) Serve() {
pipePath := `\\.\pipe\openssh-ssh-agent`
l, err := winio.ListenPipe(pipePath, nil)
if err != nil {
log.Fatal("listen error:", err)
}
defer l.Close()
2024-02-04 00:24:40 +01:00
log.Info("Server listening on named pipe %v\n", pipePath)
2024-02-04 00:08:25 +01:00
for {
conn, err := l.Accept()
if err != nil {
log.Fatal("accept error:", err)
}
callingContext := sockets.GetCallingContext(conn)
log.Info("SSH Agent connection from %s>%s>%s \nby user %s", callingContext.GrandParentProcessName, callingContext.ParentProcessName, callingContext.ProcessName, callingContext.UserName)
log.Info("SSH Agent connection accepted")
go agent.ServeAgent(vaultAgent{
vault: v.vault,
config: v.config,
unlockRequestAction: v.unlockRequestAction,
context: callingContext,
}, conn)
}
}