From 789f1b1c70a2d6420186f898ba7e8aae99afc81a Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Mon, 25 Apr 2022 19:55:19 +0200 Subject: [PATCH] Add support for Firefox in a Snap for Ubuntu 22.04 Closes #327 Fixes #325 --- truststore_darwin.go | 2 +- truststore_linux.go | 5 +++-- truststore_nss.go | 7 ++++++- truststore_windows.go | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/truststore_darwin.go b/truststore_darwin.go index b6982ca..83b8fac 100644 --- a/truststore_darwin.go +++ b/truststore_darwin.go @@ -16,7 +16,7 @@ import ( ) var ( - FirefoxProfile = os.Getenv("HOME") + "/Library/Application Support/Firefox/Profiles/*" + FirefoxProfiles = []string{os.Getenv("HOME") + "/Library/Application Support/Firefox/Profiles/*"} CertutilInstallHelp = "brew install nss" NSSBrowsers = "Firefox" ) diff --git a/truststore_linux.go b/truststore_linux.go index 9410ccf..2c4e5a3 100644 --- a/truststore_linux.go +++ b/truststore_linux.go @@ -15,8 +15,9 @@ import ( ) var ( - FirefoxProfile = os.Getenv("HOME") + "/.mozilla/firefox/*" - NSSBrowsers = "Firefox and/or Chrome/Chromium" + FirefoxProfiles = []string{os.Getenv("HOME") + "/.mozilla/firefox/*", + os.Getenv("HOME") + "/snap/firefox/common/.mozilla/firefox/*"} + NSSBrowsers = "Firefox and/or Chrome/Chromium" SystemTrustFilename string SystemTrustCommand []string diff --git a/truststore_nss.go b/truststore_nss.go index a82f0dc..ad8d662 100644 --- a/truststore_nss.go +++ b/truststore_nss.go @@ -27,6 +27,7 @@ var ( "/usr/bin/firefox", "/usr/bin/firefox-nightly", "/usr/bin/firefox-developer-edition", + "/snap/firefox", "/Applications/Firefox.app", "/Applications/FirefoxDeveloperEdition.app", "/Applications/Firefox Developer Edition.app", @@ -128,8 +129,12 @@ func execCertutil(cmd *exec.Cmd) ([]byte, error) { } func (m *mkcert) forEachNSSProfile(f func(profile string)) (found int) { - profiles, _ := filepath.Glob(FirefoxProfile) + var profiles []string profiles = append(profiles, nssDBs...) + for _, ff := range FirefoxProfiles { + pp, _ := filepath.Glob(ff) + profiles = append(profiles, pp...) + } for _, profile := range profiles { if stat, err := os.Stat(profile); err != nil || !stat.IsDir() { continue diff --git a/truststore_windows.go b/truststore_windows.go index 805e1b0..a4c9fcb 100644 --- a/truststore_windows.go +++ b/truststore_windows.go @@ -17,7 +17,7 @@ import ( ) var ( - FirefoxProfile = os.Getenv("USERPROFILE") + "\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles" + FirefoxProfiles = []string{os.Getenv("USERPROFILE") + "\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles"} CertutilInstallHelp = "" // certutil unsupported on Windows NSSBrowsers = "Firefox" )