From 35a33071137b04fb684e460050b7ce8ca7db2c71 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sun, 28 Apr 2024 19:56:02 +0200 Subject: [PATCH] Fix browser biometric setup --- browserbiometrics/main.go | 66 ++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/browserbiometrics/main.go b/browserbiometrics/main.go index 0207cef..a0dee9a 100644 --- a/browserbiometrics/main.go +++ b/browserbiometrics/main.go @@ -126,21 +126,26 @@ func detectAndInstallBrowsers(startPath string) error { fmt.Printf("Found mozilla-like browser: %s\n", path) fmt.Println("Removing old manifest and proxy script") - err = os.Chown(path+"/com.8bit.bitwarden.json", 7, 7) - if err != nil { - return err + if _, err := os.Stat(path + "/com.8bit.bitwarden.json"); err == nil { + err = os.Chmod(path+"/com.8bit.bitwarden.json", 755) + if err != nil { + return err + } + err = os.Remove(path + "/com.8bit.bitwarden.json") + if err != nil { + return err + } } - err = os.Remove(path + "/com.8bit.bitwarden.json") - if err != nil { - return err - } - err = os.Chown(path+"/goldwarden-proxy.sh", 7, 7) - if err != nil { - return err - } - err = os.Remove(path + "/goldwarden-proxy.sh") - if err != nil { - return err + + if _, err := os.Stat(path + "/goldwarden-proxy.sh"); err == nil { + err = os.Chmod(path+"/goldwarden-proxy.sh", 755) + if err != nil { + return err + } + err = os.Remove(path + "/goldwarden-proxy.sh") + if err != nil { + return err + } } fmt.Println("Writing new manifest") @@ -159,21 +164,26 @@ func detectAndInstallBrowsers(startPath string) error { fmt.Printf("Found chrome-like browser: %s\n", path) fmt.Println("Removing old manifest and proxy script") - err = os.Chown(path+"/com.8bit.bitwarden.json", 7, 7) - if err != nil { - return err + if _, err := os.Stat(path + "/com.8bit.bitwarden.json"); err == nil { + err = os.Chmod(path+"/com.8bit.bitwarden.json", 755) + if err != nil { + return err + } + err = os.Remove(path + "/com.8bit.bitwarden.json") + if err != nil { + return err + } } - err = os.Remove(path + "/com.8bit.bitwarden.json") - if err != nil { - return err - } - err = os.Chown(path+"/goldwarden-proxy.sh", 7, 7) - if err != nil { - return err - } - err = os.Remove(path + "/goldwarden-proxy.sh") - if err != nil { - return err + + if _, err := os.Stat(path + "/goldwarden-proxy.sh"); err == nil { + err = os.Chmod(path+"/goldwarden-proxy.sh", 755) + if err != nil { + return err + } + err = os.Remove(path + "/goldwarden-proxy.sh") + if err != nil { + return err + } } fmt.Println("Writing new manifest")