diff --git a/agent/unixsocketagent.go b/agent/unixsocketagent.go index 85d2325..149f1a5 100644 --- a/agent/unixsocketagent.go +++ b/agent/unixsocketagent.go @@ -309,22 +309,6 @@ type AgentState struct { func StartUnixAgent(path string, runtimeConfig config.RuntimeConfig) error { ctx := context.Background() - home, _ := os.UserHomeDir() - _, err := os.Stat("/.flatpak-info") - isFlatpak := err == nil - if runtimeConfig.GoldwardenSocketPath == "" { - runtimeConfig.GoldwardenSocketPath = home + "/.goldwarden.sock" - if isFlatpak { - runtimeConfig.GoldwardenSocketPath = home + "/.var/app/com.quexten.Goldwarden/data/goldwarden.sock" - } - } - if runtimeConfig.SSHAgentSocketPath == "" { - runtimeConfig.SSHAgentSocketPath = home + "/.ssh-agent-socket" - if isFlatpak { - runtimeConfig.SSHAgentSocketPath = home + "/.var/app/com.quexten.Goldwarden/data/ssh-auth-sock" - } - } - var keyring crypto.Keyring if runtimeConfig.UseMemguard { keyring = crypto.NewMemguardKeyring(nil) diff --git a/cmd/daemonize.go b/cmd/daemonize.go index 8f4b9e9..7b274a1 100644 --- a/cmd/daemonize.go +++ b/cmd/daemonize.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "os" "syscall" "github.com/awnumar/memguard" @@ -42,7 +43,23 @@ var daemonizeCmd = &cobra.Command{ memguard.SafeExit(0) } - err := agent.StartUnixAgent(runtimeConfig.GoldwardenSocketPath, runtimeConfig) + home, _ := os.UserHomeDir() + _, err := os.Stat("/.flatpak-info") + isFlatpak := err == nil + if runtimeConfig.GoldwardenSocketPath == "" { + runtimeConfig.GoldwardenSocketPath = home + "/.goldwarden.sock" + if isFlatpak { + runtimeConfig.GoldwardenSocketPath = home + "/.var/app/com.quexten.Goldwarden/data/goldwarden.sock" + } + } + if runtimeConfig.SSHAgentSocketPath == "" { + runtimeConfig.SSHAgentSocketPath = home + "/.ssh-agent-socket" + if isFlatpak { + runtimeConfig.SSHAgentSocketPath = home + "/.var/app/com.quexten.Goldwarden/data/ssh-auth-sock" + } + } + + err = agent.StartUnixAgent(runtimeConfig.GoldwardenSocketPath, runtimeConfig) if err != nil { panic(err) }