$OpenBSD: patch-src_components_tl-process_js,v 1.2 2016/12/02 08:18:19 landry Exp $

Let geoip/geoip6 file paths be set by prefs like everything else.  Go
back to old way of munging relative paths, their new way is
effectively a no-op for us anyway.
--- src/components/tl-process.js.orig	Wed Nov  9 04:55:57 2016
+++ src/components/tl-process.js	Fri Nov 18 17:04:27 2016
@@ -309,6 +309,7 @@ TorProcessService.prototype =
   mIsQuitting: false,
   mObsSvc: null,
   mProtocolSvc: null,
+  mTorFileBaseDir: null,
   mTorProcess: null,    // nsIProcess
   mTorProcessStartTime: null, // JS Date.now()
   // mIsUserDataOutsideOfAppDir is true when TorBrowser-Data is used.
@@ -341,6 +342,8 @@ TorProcessService.prototype =
       var exeFile = this._getTorFile("tor", false);
       var torrcFile = this._getTorFile("torrc", true);
       var torrcDefaultsFile = this._getTorFile("torrc-defaults", false);
+      var geoipFile = this._getTorFile("geoip", false);
+      var geoip6File = this._getTorFile("geoip6", false);
       var hashedPassword = this.mProtocolSvc.TorGetPassword(true);
 
       var detailsKey;
@@ -364,18 +367,12 @@ TorProcessService.prototype =
       }
 
 
-      // The geoip and geoip6 files are in the same directory as torrc-defaults.
-      var geoipFile = torrcDefaultsFile.clone();
-      geoipFile.leafName = "geoip";
-
-      var geoip6File = torrcDefaultsFile.clone();
-      geoip6File.leafName = "geoip6";
-
       var args = [];
       if (torrcDefaultsFile)
       {
         args.push("--defaults-torrc");
         args.push(torrcDefaultsFile.path);
+        args.push("--ignore-missing-torrc");
       }
       args.push("-f");
       args.push(torrcFile.path);
@@ -684,10 +681,10 @@ TorProcessService.prototype =
       return null;
 
     let isRelativePath = true;
-    let isUserData = (aTorFileType != "tor") &&
-                     (aTorFileType != "torrc-defaults");
     let prefName = "extensions.torlauncher." + aTorFileType + "_path";
     let path = TorLauncherUtil.getCharPref(prefName);
+    // N.B. On OpenBSD, path will always be set via prefs.js
+    TorLauncherLogger.log(4, "_getTorFile("+aTorFileType+ ") "+prefName+" = "+path);
     if (path)
     {
       let re = (TorLauncherUtil.isWindows) ?  /^[A-Za-z]:\\/ : /^\//;
@@ -768,16 +765,13 @@ TorProcessService.prototype =
       if (isRelativePath)
       {
         // Turn 'path' into an absolute path.
-        if (this._isUserDataOutsideOfAppDir)
+        if (!this.mTorFileBaseDir)
         {
-          let baseDir = isUserData ? this._dataDir : this._appDir;
-          f = baseDir.clone();
+          this.mTorFileBaseDir = Cc["@mozilla.org/file/directory_service;1"]
+                                   .getService(Ci.nsIProperties)
+                                   .get("DefProfRt", Ci.nsIFile);
         }
-        else
-        {
-          f = this._appDir.clone();
-          f.append("TorBrowser");
-        }
+        f = this.mTorFileBaseDir.clone();
         f.appendRelativePath(path);
       }
       else
@@ -805,6 +799,8 @@ TorProcessService.prototype =
       if (f.exists())
       {
         try { f.normalize(); } catch(e) {}
+
+        TorLauncherLogger.log(5,"_getTorFile: "+aTorFileType+" => "+f.path);
 
         return f;
       }
