From 85d9936082bc8a3fc763ff8d3f1f6a6695bfc956 Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Sun, 1 Oct 2023 23:02:32 +0200 Subject: [PATCH] chore(ssh-agent): sock file name --- db/AccessKey.go | 2 +- db/Inventory.go | 23 ----------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/db/AccessKey.go b/db/AccessKey.go index 82522725..543f682d 100644 --- a/db/AccessKey.go +++ b/db/AccessKey.go @@ -98,7 +98,7 @@ func (key *AccessKey) startSshAgent(logger lib.Logger) (lib.SshAgent, error) { Passphrase: []byte(key.SshKey.Passphrase), }, }, - SocketFile: path.Join(util.Config.TmpPath, fmt.Sprintf("ssh-agent-%d-%d.sock", time.Now().Unix(), 0)), + SocketFile: path.Join(util.Config.TmpPath, fmt.Sprintf("ssh-agent-%d-%d.sock", key.ID, time.Now().Unix())), } return sshAgent, sshAgent.Listen() diff --git a/db/Inventory.go b/db/Inventory.go index 8320584f..740b9b41 100644 --- a/db/Inventory.go +++ b/db/Inventory.go @@ -24,29 +24,6 @@ type Inventory struct { Type string `db:"type" json:"type"` } -//func (i *Inventory) StartSshAgent(logger lib.Logger) (lib.SshAgent, error) { -// -// sshAgent := lib.SshAgent{ -// Logger: logger, -// Keys: []lib.SshAgentKey{ -// { -// Key: []byte(i.SSHKey.SshKey.PrivateKey), -// Passphrase: []byte(i.SSHKey.SshKey.Passphrase), -// }, -// }, -// SocketFile: path.Join(util.Config.TmpPath, fmt.Sprintf("ssh-agent-%d-%d.sock", time.Now().Unix(), 0)), -// } -// -// if i.BecomeKeyID != nil { -// sshAgent.Keys = append(sshAgent.Keys, lib.SshAgentKey{ -// Key: []byte(i.BecomeKey.SshKey.PrivateKey), -// Passphrase: []byte(i.BecomeKey.SshKey.Passphrase), -// }) -// } -// -// return sshAgent, sshAgent.Listen() -//} - func FillInventory(d Store, inventory *Inventory) (err error) { if inventory.SSHKeyID != nil { inventory.SSHKey, err = d.GetAccessKey(inventory.ProjectID, *inventory.SSHKeyID)