From 275ba9a3d23c1cf80796574ea4e0491b06d0da48 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sat, 1 Jun 2024 14:32:15 +0200 Subject: [PATCH 1/5] Fix crash on daemon not running --- gui/src/gui/settings.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gui/src/gui/settings.py b/gui/src/gui/settings.py index ab88cd2..fc38fa2 100644 --- a/gui/src/gui/settings.py +++ b/gui/src/gui/settings.py @@ -101,8 +101,7 @@ class GoldwardenSettingsApp(Adw.Application): if status == None: is_daemon_running = goldwarden.is_daemon_running() if not is_daemon_running: - self.status_row.set_subtitle("Daemon not running") - self.vault_status_icon.set_icon("dialog-error", "error") + print("Daemon not running") return logged_in = status["loggedIn"] From a41c91ca6ba40878d2b7f752b3a86cf744809db1 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sat, 1 Jun 2024 14:32:25 +0200 Subject: [PATCH 2/5] Add macos startup scripts --- gui/goldwarden_ui_main.py | 12 ++++++++++-- gui/src/macos/main.py | 13 +++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 gui/src/macos/main.py diff --git a/gui/goldwarden_ui_main.py b/gui/goldwarden_ui_main.py index d6df4d2..e739a28 100755 --- a/gui/goldwarden_ui_main.py +++ b/gui/goldwarden_ui_main.py @@ -1,4 +1,12 @@ #!/usr/bin/env python3 -import src.linux.main as linux_main -linux_main.main() \ No newline at end of file +import platform + +if platform.system() == 'Darwin': + import src.macos.main as macos_main + macos_main.main() +elif platform.system() == 'Linux': + import src.linux.main as linux_main + linux_main.main() +else: + print("Unsupported OS " + platform.system() + "... exiting...") \ No newline at end of file diff --git a/gui/src/macos/main.py b/gui/src/macos/main.py new file mode 100644 index 0000000..02ac8c7 --- /dev/null +++ b/gui/src/macos/main.py @@ -0,0 +1,13 @@ +import sys +import subprocess +import os + +root_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, os.pardir)) + +def main(): + token = "abc" + print("Starting Goldwarden GUI") + if not "--hidden" in sys.argv: + p = subprocess.Popen(["python3", "-m", "src.gui.settings"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=root_path, start_new_session=True) + p.stdin.write(f"{token}\n".encode()) + p.stdin.flush() \ No newline at end of file From 2651a36d3cd56cfcdb88bae59efe8cd33366f991 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sat, 1 Jun 2024 15:18:11 +0200 Subject: [PATCH 3/5] Fix pinentry --- cli/agent/systemauth/pinentry/go-pinentry.go | 10 ++++++++-- cli/agent/systemauth/pinentry/keybase-pinentry.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cli/agent/systemauth/pinentry/go-pinentry.go b/cli/agent/systemauth/pinentry/go-pinentry.go index 673950a..648a7e3 100644 --- a/cli/agent/systemauth/pinentry/go-pinentry.go +++ b/cli/agent/systemauth/pinentry/go-pinentry.go @@ -1,16 +1,22 @@ -//go:build freebsd || linux +//go:build freebsd || linux || darwin package pinentry import ( "errors" + "runtime" "github.com/twpayne/go-pinentry" ) func getPassword(title string, description string) (string, error) { + binaryClientOption := pinentry.WithBinaryNameFromGnuPGAgentConf() + if runtime.GOOS == "darwin" { + binaryClientOption = pinentry.WithBinaryName("pinentry-mac") + } + client, err := pinentry.NewClient( - pinentry.WithBinaryNameFromGnuPGAgentConf(), + binaryClientOption, pinentry.WithGPGTTY(), pinentry.WithTitle(title), pinentry.WithDesc(description), diff --git a/cli/agent/systemauth/pinentry/keybase-pinentry.go b/cli/agent/systemauth/pinentry/keybase-pinentry.go index 0071fdd..a3486de 100644 --- a/cli/agent/systemauth/pinentry/keybase-pinentry.go +++ b/cli/agent/systemauth/pinentry/keybase-pinentry.go @@ -1,4 +1,4 @@ -//go:build windows || darwin +//go:build windows package pinentry From 5af6771460c87802afe6b9025e88636f89777f9e Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sun, 2 Jun 2024 17:17:15 +0200 Subject: [PATCH 4/5] Fix autotype on mac --- gui/src/gui/quickaccess.py | 11 +++++------ gui/src/services/autotype/pyautogui_autotype.py | 5 ++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gui/src/gui/quickaccess.py b/gui/src/gui/quickaccess.py index 4030814..3a08268 100644 --- a/gui/src/gui/quickaccess.py +++ b/gui/src/gui/quickaccess.py @@ -1,10 +1,10 @@ import gi gi.require_version('Gtk', '4.0') gi.require_version('Adw', '1') -gi.require_version('Notify', '0.7') +# gi.require_version('Notify', '0.7') import gc import time -from gi.repository import Gtk, Adw, GLib, Notify, Gdk +from gi.repository import Gtk, Adw, GLib, Gdk from ..services import goldwarden from ..services.autotype import autotype from threading import Thread @@ -12,7 +12,6 @@ from .resource_loader import load_template import sys import os from ..services import totp -Notify.init("Goldwarden") class GoldwardenQuickAccessApp(Adw.Application): def __init__(self, **kwargs): @@ -115,8 +114,8 @@ class GoldwardenQuickAccessApp(Adw.Application): def run_autotype(self, text): def perform_autotype(text): - self.window.hide() - time.sleep(0.1) + GLib.idle_add(self.window.hide) + time.sleep(2) autotype.autotype(text) time.sleep(0.1) os._exit(0) @@ -148,7 +147,7 @@ class GoldwardenQuickAccessApp(Adw.Application): self.filtered_logins = self.filtered_logins[0:7] def render_list(self): - if len(self.filtered_logins) > 1: + if len(self.filtered_logins) > 0: self.results_list.set_visible(True) while self.results_list.get_first_child() != None: self.results_list.remove(self.results_list.get_first_child()) diff --git a/gui/src/services/autotype/pyautogui_autotype.py b/gui/src/services/autotype/pyautogui_autotype.py index 3b8057a..0a9214b 100644 --- a/gui/src/services/autotype/pyautogui_autotype.py +++ b/gui/src/services/autotype/pyautogui_autotype.py @@ -2,4 +2,7 @@ import pyautogui def autotype_pyautogui(text): print("autotypeing with pyautogui") - pyautogui.write(text, interval=0.02) \ No newline at end of file + pyautogui.write(text, interval=0.02) + +if __name__ == "__main__": + autotype_pyautogui("hello world") \ No newline at end of file From 53271c333138ac6569416326ac25706e680cd1e3 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sun, 2 Jun 2024 18:54:15 +0200 Subject: [PATCH 5/5] Implement mac main --- gui/src/macos/main.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/gui/src/macos/main.py b/gui/src/macos/main.py index 02ac8c7..cf8f94e 100644 --- a/gui/src/macos/main.py +++ b/gui/src/macos/main.py @@ -1,13 +1,30 @@ import sys import subprocess import os +import secrets +from src.services import goldwarden +from src.services import pinentry +import time root_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, os.pardir)) def main(): - token = "abc" + token = secrets.token_hex(32) + if not os.environ.get("GOLDWARDEN_DAEMON_AUTH_TOKEN") == None: + token = os.environ["GOLDWARDEN_DAEMON_AUTH_TOKEN"] print("Starting Goldwarden GUI") + goldwarden.run_daemon_background(token) + time.sleep(1) + #pinentry.daemonize() if not "--hidden" in sys.argv: - p = subprocess.Popen(["python3", "-m", "src.gui.settings"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=root_path, start_new_session=True) + p = subprocess.Popen(["python3", "-m", "src.gui.settings"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=root_path, start_new_session=True) p.stdin.write(f"{token}\n".encode()) - p.stdin.flush() \ No newline at end of file + p.stdin.flush() + # print stdout + while True: + line = p.stderr.readline() + if not line: + break + print(line.decode().strip()) + while True: + time.sleep(60) \ No newline at end of file