[tor-commits] [meek/webextension] Try deleting the registry key before exiting.
dcf at torproject.org
dcf at torproject.org
Thu Mar 7 23:50:17 UTC 2019
commit e80c5b3217914a033bfc2303f5e043a4bdb3488c
Author: David Fifield <david at bamsoftware.com>
Date: Thu Mar 7 15:46:54 2019 -0700
Try deleting the registry key before exiting.
---
meek-client-torbrowser/linux.go | 6 ++++++
meek-client-torbrowser/mac.go | 6 ++++++
meek-client-torbrowser/meek-client-torbrowser.go | 13 ++++++++++++-
meek-client-torbrowser/windows.go | 15 ++++++++-------
4 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/meek-client-torbrowser/linux.go b/meek-client-torbrowser/linux.go
index f728f1d..69ee7b7 100644
--- a/meek-client-torbrowser/linux.go
+++ b/meek-client-torbrowser/linux.go
@@ -29,3 +29,9 @@ func osSpecificCommandSetup(cmd *exec.Cmd) {
func installHelperNativeManifest() error {
return writeNativeManifestToFile(helperNativeManifestDir, helperNativeExecutablePath)
}
+
+func uninstallHelperNativeManifest() error {
+ // Nothing to do here: the host manifest file is written inside the
+ // browser directory, so we assume we don't have to clean it up.
+ return nil
+}
diff --git a/meek-client-torbrowser/mac.go b/meek-client-torbrowser/mac.go
index 995aca5..918a62e 100644
--- a/meek-client-torbrowser/mac.go
+++ b/meek-client-torbrowser/mac.go
@@ -42,3 +42,9 @@ func installHelperNativeManifest() error {
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#Mac_OS_X
return writeNativeManifestToFile(filepath.Join(homeDir, "Mozilla", "NativeMessagingHosts"), helperNativeExecutablePath)
}
+
+func uninstallHelperNativeManifest() error {
+ // Nothing to do here: the host manifest file is written inside the
+ // browser directory, so we assume we don't have to clean it up.
+ return nil
+}
diff --git a/meek-client-torbrowser/meek-client-torbrowser.go b/meek-client-torbrowser/meek-client-torbrowser.go
index 37dcf6e..f482fb3 100644
--- a/meek-client-torbrowser/meek-client-torbrowser.go
+++ b/meek-client-torbrowser/meek-client-torbrowser.go
@@ -15,6 +15,11 @@
// executed as given, except that a --helper option is added that points to the
// port number read from firefox.
//
+// On Windows, this program assumes that is has exclusive control over the
+// HKEY_CURRENT_USER\SOFTWARE\Mozilla\NativeMessagingHosts\meek.http.helper
+// registry key. It creates the key when run and tries to delete it when
+// exiting.
+//
// This program proxies stdin and stdout to and from meek-client, so it is
// actually meek-client that drives the pluggable transport negotiation with
// tor.
@@ -375,7 +380,13 @@ func main() {
log.Print(err)
return
}
- defer logKill(firefoxCmd.Process)
+ defer func() {
+ logKill(firefoxCmd.Process)
+ err := uninstallHelperNativeManifest()
+ if err != nil {
+ log.Printf("uninstalling native host manifest: %v", err)
+ }
+ }()
// Find out the helper's listening address.
addrChan := make(chan string)
diff --git a/meek-client-torbrowser/windows.go b/meek-client-torbrowser/windows.go
index 907d1dc..c5c52a5 100644
--- a/meek-client-torbrowser/windows.go
+++ b/meek-client-torbrowser/windows.go
@@ -22,6 +22,7 @@ const (
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#Windows
helperNativeManifestDir = "TorBrowser/Data/Browser/.mozilla/native-messaging-hosts"
helperNativeExecutablePath = "TorBrowser/Tor/PluggableTransports/meek-http-helper.exe"
+ registryKey = `SOFTWARE\Mozilla\NativeMessagingHosts\`+nativeAppName
)
func osSpecificCommandSetup(cmd *exec.Cmd) {
@@ -39,16 +40,16 @@ func installHelperNativeManifest() error {
return err
}
- // TODO: Find a way to do this without having to write to the registry.
- // https://bugs.torproject.org/29347#comment:9
+ // On Windows we must set a registry key pointing to the host manifest.
+ // We'll attempt to delete the key in uninstallHelperNativeManifest.
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#Windows
- k, _, err := registry.CreateKey(
- registry.CURRENT_USER,
- `SOFTWARE\Mozilla\NativeMessagingHosts\`+nativeAppName,
- registry.WRITE,
- )
+ k, _, err := registry.CreateKey(registry.CURRENT_USER, registryKey, registry.WRITE)
if err != nil {
return err
}
return k.SetStringValue("", absManifestPath)
}
+
+func uninstallHelperNativeManifest() error {
+ return registry.DeleteKey(registry.CURRENT_USER, registryKey)
+}
More information about the tor-commits
mailing list