Attempt to fix socket path detection
This commit is contained in:
parent
f99d618b33
commit
0cd55f4052
|
@ -309,6 +309,22 @@ type AgentState struct {
|
||||||
func StartUnixAgent(path string, runtimeConfig config.RuntimeConfig) error {
|
func StartUnixAgent(path string, runtimeConfig config.RuntimeConfig) error {
|
||||||
ctx := context.Background()
|
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
|
var keyring crypto.Keyring
|
||||||
if runtimeConfig.UseMemguard {
|
if runtimeConfig.UseMemguard {
|
||||||
keyring = crypto.NewMemguardKeyring(nil)
|
keyring = crypto.NewMemguardKeyring(nil)
|
||||||
|
|
|
@ -105,7 +105,26 @@ func handlePayloadMessage(msg PayloadMessage, appID string) {
|
||||||
case "biometricUnlock":
|
case "biometricUnlock":
|
||||||
logging.Debugf("Biometric unlock requested")
|
logging.Debugf("Biometric unlock requested")
|
||||||
// logging.Debugf("Biometrics authorized: %t", isAuthorized)
|
// logging.Debugf("Biometrics authorized: %t", isAuthorized)
|
||||||
|
|
||||||
|
home, err := os.UserHomeDir()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if runtimeConfig.GoldwardenSocketPath == "" {
|
||||||
|
if _, err := os.Stat(home + "/.goldwarden.sock"); err == nil {
|
||||||
|
runtimeConfig.GoldwardenSocketPath = home + "/.goldwarden.sock"
|
||||||
|
} else if _, err := os.Stat(home + "/.var/app/com.quexten.Goldwarden/data/goldwarden.sock"); err == nil {
|
||||||
|
runtimeConfig.GoldwardenSocketPath = home + "/.var/app/com.quexten.Goldwarden/data/goldwarden.sock"
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = os.Stat("/.flatpak-info"); err == nil {
|
||||||
|
runtimeConfig.GoldwardenSocketPath = home + "/.var/app/com.quexten.Goldwarden/data/goldwarden.sock"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logging.Debugf("Connecting to agent at path %s", runtimeConfig.GoldwardenSocketPath)
|
logging.Debugf("Connecting to agent at path %s", runtimeConfig.GoldwardenSocketPath)
|
||||||
|
|
||||||
result, err := client.NewUnixSocketClient(runtimeConfig).SendToAgent(messages.GetBiometricsKeyRequest{})
|
result, err := client.NewUnixSocketClient(runtimeConfig).SendToAgent(messages.GetBiometricsKeyRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.Errorf("Unable to send message to agent: %s", err.Error())
|
logging.Errorf("Unable to send message to agent: %s", err.Error())
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/quexten/goldwarden/agent/config"
|
"github.com/quexten/goldwarden/agent/config"
|
||||||
"github.com/quexten/goldwarden/ipc/messages"
|
"github.com/quexten/goldwarden/ipc/messages"
|
||||||
|
@ -52,6 +53,26 @@ func (client UnixSocketClient) SendToAgent(request interface{}) (interface{}, er
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client UnixSocketClient) Connect() (UnixSocketConnection, error) {
|
func (client UnixSocketClient) Connect() (UnixSocketConnection, error) {
|
||||||
|
runtimeConfig := client.runtimeConfig
|
||||||
|
home, err := os.UserHomeDir()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if runtimeConfig.SSHAgentSocketPath == "" {
|
||||||
|
if _, err := os.Stat(home + "/.ssh-agent-socket"); err == nil {
|
||||||
|
runtimeConfig.SSHAgentSocketPath = home + "/.ssh-agent-socket"
|
||||||
|
} else if _, err := os.Stat(home + "/.var/app/com.quexten.Goldwarden/data/ssh-auth-sock"); err == nil {
|
||||||
|
runtimeConfig.SSHAgentSocketPath = home + "/.var/app/com.quexten.Goldwarden/data/ssh-auth-sock"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if runtimeConfig.GoldwardenSocketPath == "" {
|
||||||
|
if _, err := os.Stat(home + "/.goldwarden.sock"); err == nil {
|
||||||
|
runtimeConfig.GoldwardenSocketPath = home + "/.goldwarden.sock"
|
||||||
|
} else if _, err := os.Stat(home + "/.var/app/com.quexten.Goldwarden/data/goldwarden.sock"); err == nil {
|
||||||
|
runtimeConfig.GoldwardenSocketPath = home + "/.var/app/com.quexten.Goldwarden/data/goldwarden.sock"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c, err := net.Dial("unix", client.runtimeConfig.GoldwardenSocketPath)
|
c, err := net.Dial("unix", client.runtimeConfig.GoldwardenSocketPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return UnixSocketConnection{}, err
|
return UnixSocketConnection{}, err
|
||||||
|
|
23
main.go
23
main.go
|
@ -36,33 +36,12 @@ func main() {
|
||||||
ConfigDirectory: configPath,
|
ConfigDirectory: configPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
home, err := os.UserHomeDir()
|
_, err := os.Stat("/.flatpak-info")
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if runtimeConfig.SSHAgentSocketPath == "" {
|
|
||||||
if _, err := os.Stat(home + "/.ssh-agent-socket"); err == nil {
|
|
||||||
runtimeConfig.SSHAgentSocketPath = home + "/.ssh-agent-socket"
|
|
||||||
} else if _, err := os.Stat(home + "/.var/app/com.quexten.Goldwarden/data/ssh-auth-sock"); err == nil {
|
|
||||||
runtimeConfig.SSHAgentSocketPath = home + "/.var/app/com.quexten.Goldwarden/data/ssh-auth-sock"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if runtimeConfig.GoldwardenSocketPath == "" {
|
|
||||||
if _, err := os.Stat(home + "/.goldwarden.sock"); err == nil {
|
|
||||||
runtimeConfig.GoldwardenSocketPath = home + "/.goldwarden.sock"
|
|
||||||
} else if _, err := os.Stat(home + "/.var/app/com.quexten.Goldwarden/data/goldwarden.sock"); err == nil {
|
|
||||||
runtimeConfig.GoldwardenSocketPath = home + "/.var/app/com.quexten.Goldwarden/data/goldwarden.sock"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = os.Stat("/.flatpak-info")
|
|
||||||
isFlatpak := err == nil
|
isFlatpak := err == nil
|
||||||
if isFlatpak {
|
if isFlatpak {
|
||||||
userHome, _ := os.UserHomeDir()
|
userHome, _ := os.UserHomeDir()
|
||||||
runtimeConfig.ConfigDirectory = userHome + "/.var/app/com.quexten.Goldwarden/config/goldwarden.json"
|
runtimeConfig.ConfigDirectory = userHome + "/.var/app/com.quexten.Goldwarden/config/goldwarden.json"
|
||||||
runtimeConfig.ConfigDirectory = strings.ReplaceAll(runtimeConfig.ConfigDirectory, "~", userHome)
|
runtimeConfig.ConfigDirectory = strings.ReplaceAll(runtimeConfig.ConfigDirectory, "~", userHome)
|
||||||
runtimeConfig.SSHAgentSocketPath = userHome + "/.var/app/com.quexten.Goldwarden/data/ssh-auth-sock"
|
|
||||||
runtimeConfig.GoldwardenSocketPath = userHome + "/.var/app/com.quexten.Goldwarden/data/goldwarden.sock"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(os.Args) > 1 && (strings.Contains(os.Args[1], "com.8bit.bitwarden.json") || strings.Contains(os.Args[1], "chrome-extension://")) {
|
if len(os.Args) > 1 && (strings.Contains(os.Args[1], "com.8bit.bitwarden.json") || strings.Contains(os.Args[1], "chrome-extension://")) {
|
||||||
|
|
Loading…
Reference in New Issue