Improve browserbiometrics setup
This commit is contained in:
parent
81298aa726
commit
13834283f1
|
@ -10,24 +10,23 @@ import (
|
|||
"github.com/quexten/goldwarden/browserbiometrics/logging"
|
||||
)
|
||||
|
||||
var chromiumPaths = []string{
|
||||
"~/.config/google-chrome/",
|
||||
"~/.config/google-chrome-beta/",
|
||||
"~/.config/google-chrome-unstable/",
|
||||
"~/.config/chromium/",
|
||||
"~/.config/BraveSoftware/Brave-Browser/",
|
||||
"~/.config/thorium/",
|
||||
"~/.config/microsoft-edge-beta/",
|
||||
"~/.config/microsoft-edge-dev/",
|
||||
}
|
||||
var mozillaPaths = []string{"~/.mozilla/", "~/.librewolf/", "~/.waterfox/"}
|
||||
|
||||
const appID = "com.quexten.bw-bio-handler"
|
||||
|
||||
var transportKey []byte
|
||||
|
||||
func Main(rtCfg *config.RuntimeConfig) {
|
||||
if os.Args[1] == "install" {
|
||||
var err error
|
||||
err = detectAndInstallBrowsers(".config")
|
||||
if err != nil {
|
||||
panic("Failed to detect browsers: " + err.Error())
|
||||
}
|
||||
err = detectAndInstallBrowsers(".mozilla")
|
||||
if err != nil {
|
||||
panic("Failed to detect browsers: " + err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
logging.Debugf("Starting browserbiometrics")
|
||||
transportKey = generateTransportKey()
|
||||
logging.Debugf("Generated transport key")
|
||||
|
@ -38,13 +37,57 @@ func Main(rtCfg *config.RuntimeConfig) {
|
|||
|
||||
func DetectAndInstallBrowsers() error {
|
||||
var err error
|
||||
|
||||
// first, ensure the native messaging hosts dirs exist
|
||||
for _, path := range chromiumPaths {
|
||||
path = strings.ReplaceAll(path, "~", os.Getenv("HOME"))
|
||||
_, err = os.Stat(path)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err = os.Stat(path + "NativeMessagingHosts/")
|
||||
if err == nil {
|
||||
fmt.Println("Native messaging host directory already exists: " + path + "NativeMessagingHosts/")
|
||||
continue
|
||||
}
|
||||
err = os.MkdirAll(path+"NativeMessagingHosts/", 0755)
|
||||
if err != nil {
|
||||
fmt.Println("Error creating native messaging host directory: " + err.Error())
|
||||
} else {
|
||||
fmt.Println("Created native messaging host directory: " + path + "NativeMessagingHosts/")
|
||||
}
|
||||
}
|
||||
for _, path := range mozillaPaths {
|
||||
path = strings.ReplaceAll(path, "~", os.Getenv("HOME"))
|
||||
_, err = os.Stat(path)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err = os.Stat(path + "native-messaging-hosts/")
|
||||
if err == nil {
|
||||
fmt.Println("Native messaging host directory already exists: " + path + "native-messaging-hosts/")
|
||||
continue
|
||||
}
|
||||
err = os.MkdirAll(path+"native-messaging-hosts/", 0755)
|
||||
if err != nil {
|
||||
fmt.Println("Error creating native messaging host directory: " + err.Error())
|
||||
} else {
|
||||
fmt.Println("Created native messaging host directory: " + path + "native-messaging-hosts/")
|
||||
}
|
||||
}
|
||||
|
||||
err = detectAndInstallBrowsers(".config")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = detectAndInstallBrowsers(".mozilla")
|
||||
if err != nil {
|
||||
return err
|
||||
for _, path := range mozillaPaths {
|
||||
path = strings.ReplaceAll(path, "~/", "")
|
||||
err = detectAndInstallBrowsers(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue