[tor-commits] [meek/master] Unset environment variables Firefox sets on restart.

dcf at torproject.org dcf at torproject.org
Thu Jun 25 20:14:59 UTC 2015


commit 8cd16980da0cd50e5b6e203a4ee5eaa87725184a
Author: David Fifield <david at bamsoftware.com>
Date:   Thu Jun 25 12:57:10 2015 -0700

    Unset environment variables Firefox sets on restart.
    
    These were the cause of the profile error that you saw when restarting
    Tor Browser after an update.
    https://trac.torproject.org/projects/tor/ticket/13247#comment:17
---
 meek-client-torbrowser/meek-client-torbrowser.go |   25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/meek-client-torbrowser/meek-client-torbrowser.go b/meek-client-torbrowser/meek-client-torbrowser.go
index 5785856..605bc85 100644
--- a/meek-client-torbrowser/meek-client-torbrowser.go
+++ b/meek-client-torbrowser/meek-client-torbrowser.go
@@ -148,6 +148,31 @@ func main() {
 	sigChan := make(chan os.Signal, 1)
 	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
 
+	// Unset environment variables that Firefox sets after a restart (as
+	// caused by, for example, an update or the installation of an add-on).
+	// XRE_PROFILE_PATH, in particular, overrides the -profile option that
+	// runFirefox sets, causing Firefox to run with profile.default instead
+	// of profile.meek-http-helper, which conflicts with the profile.default
+	// that is already running. See
+	// https://trac.torproject.org/projects/tor/ticket/13247, particularly
+	// #comment:17 and #comment:18. The environment variable names come from
+	// https://hg.mozilla.org/mozilla-central/file/cfde3603b020/toolkit/xre/nsAppRunner.cpp#l3941
+	var firefoxRestartEnvVars = []string{
+		"XRE_PROFILE_PATH",
+		"XRE_PROFILE_LOCAL_PATH",
+		"XRE_PROFILE_NAME",
+		"XRE_START_OFFLINE",
+		"NO_EM_RESTART",
+		"XUL_APP_FILE",
+		"XRE_BINARY_PATH",
+	}
+	for _, varname := range firefoxRestartEnvVars {
+		err := os.Unsetenv(varname)
+		if err != nil {
+			log.Fatal(err)
+		}
+	}
+
 	// Start firefox.
 	firefoxCmd, stdout, err := runFirefox()
 	if err != nil {



More information about the tor-commits mailing list