Fix socket path in daemonize

This commit is contained in:
Bernd Schoolmann 2024-02-21 06:42:10 +01:00
parent ac9251d0f4
commit ab431835d4
No known key found for this signature in database
2 changed files with 18 additions and 17 deletions

View File

@ -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)

View File

@ -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)
}