Skip to content

Commit

Permalink
Fix socket path in daemonize
Browse files Browse the repository at this point in the history
  • Loading branch information
quexten committed Feb 21, 2024
1 parent ac9251d commit ab43183
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
16 changes: 0 additions & 16 deletions agent/unixsocketagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 18 additions & 1 deletion cmd/daemonize.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"os"
"syscall"

"github.com/awnumar/memguard"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit ab43183

Please sign in to comment.