diff --git a/agent/actions/actions.go b/agent/actions/actions.go index ec8de47..0bb56a6 100644 --- a/agent/actions/actions.go +++ b/agent/actions/actions.go @@ -10,8 +10,10 @@ import ( "github.com/quexten/goldwarden/agent/systemauth" "github.com/quexten/goldwarden/agent/vault" "github.com/quexten/goldwarden/ipc/messages" + "github.com/quexten/goldwarden/logging" ) +var actionsLog = logging.GetLogger("Goldwarden", "Actions") var AgentActionsRegistry = newActionsRegistry() type Action func(messages.IPCMessage, *config.Config, *vault.Vault, *sockets.CallingContext) (messages.IPCMessage, error) diff --git a/agent/actions/ssh.go b/agent/actions/ssh.go index 9372356..a3ae12a 100644 --- a/agent/actions/ssh.go +++ b/agent/actions/ssh.go @@ -11,11 +11,8 @@ import ( "github.com/quexten/goldwarden/agent/systemauth" "github.com/quexten/goldwarden/agent/vault" "github.com/quexten/goldwarden/ipc/messages" - "github.com/quexten/goldwarden/logging" ) -var actionsLog = logging.GetLogger("Goldwarden", "Actions") - func handleAddSSH(msg messages.IPCMessage, cfg *config.Config, vault *vault.Vault, callingContext *sockets.CallingContext) (response messages.IPCMessage, err error) { req := messages.ParsePayload(msg).(messages.CreateSSHKeyRequest) diff --git a/autotype/libportalautotype.go b/autotype/libportalautotype.go index fbd09b2..7812831 100644 --- a/autotype/libportalautotype.go +++ b/autotype/libportalautotype.go @@ -7,13 +7,17 @@ import ( "time" "github.com/godbus/dbus/v5" + "github.com/quexten/goldwarden/logging" ) var globalID = 0 const autoTypeDelay = 1 * time.Millisecond +var log = logging.GetLogger("Goldwarden", "Autotype") + func TypeString(textToType string) { + log.Info("Starting to Type String") bus, err := dbus.SessionBus() if err != nil { panic(err) @@ -23,9 +27,13 @@ func TypeString(textToType string) { obj.AddMatchSignal("org.freedesktop.portal.Request", "Response") globalID++ - obj.Call("org.freedesktop.portal.RemoteDesktop.CreateSession", 0, map[string]dbus.Variant{ + res0 := obj.Call("org.freedesktop.portal.RemoteDesktop.CreateSession", 0, map[string]dbus.Variant{ "session_handle_token": dbus.MakeVariant("u" + fmt.Sprint(globalID)), }) + if res0.Err != nil { + log.Error("Error creating session: %s", res0.Err.Error()) + return + } signals := make(chan *dbus.Signal, 10) bus.Signal(signals) @@ -38,15 +46,24 @@ func TypeString(textToType string) { case message := <-signals: fmt.Println("Message:", message) if state == 0 { + log.Info("Selecting Devices") result := message.Body[1].(map[string]dbus.Variant) resultSessionHandle := result["session_handle"] sessionHandle = dbus.ObjectPath(resultSessionHandle.String()[1 : len(resultSessionHandle.String())-1]) - obj.Call("org.freedesktop.portal.RemoteDesktop.SelectDevices", 0, sessionHandle, map[string]dbus.Variant{}) + res := obj.Call("org.freedesktop.portal.RemoteDesktop.SelectDevices", 0, sessionHandle, map[string]dbus.Variant{}) + if res.Err != nil { + log.Error("Error selecting devices: %s", res.Err.Error()) + } state = 1 } else if state == 1 { - obj.Call("org.freedesktop.portal.RemoteDesktop.Start", 0, sessionHandle, "", map[string]dbus.Variant{}) + log.Info("Starting Session") + res := obj.Call("org.freedesktop.portal.RemoteDesktop.Start", 0, sessionHandle, "", map[string]dbus.Variant{}) + if res.Err != nil { + log.Error("Error starting session: %s", res.Err.Error()) + } state = 2 } else if state == 2 { + log.Info("Performing Typing") state = 3 time.Sleep(200 * time.Millisecond) for _, char := range textToType { @@ -64,6 +81,9 @@ func TypeString(textToType string) { } bus.Close() return + } else { + log.Info("State 3") + return } } } diff --git a/ui/goldwarden.py b/ui/goldwarden.py index 424a59c..7adfbde 100644 --- a/ui/goldwarden.py +++ b/ui/goldwarden.py @@ -133,6 +133,8 @@ def autotype(username, password): env["PASSWORD"] = password restic_cmd = f"{BINARY_PATH} autotype --username {username}" result = subprocess.run(restic_cmd.split(), capture_output=True, text=True, env=env) + print(result.stderr) + print(result.stdout) if result.returncode != 0: raise Exception("Failed to initialize repository, err", result.stderr)