Verified Commit 6756b736 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

fixup! Bug 40933: Add tor-launcher functionality

Bug 43326: Restrict the changes to LD_LIBRARY_PATH.

We used to set LD_LIBRARY_PATH for the tor daemon before launching the
browser, but this does not work well for some distributions, which
link to the latest version of OpenSSL, whereas we link to the LTS.
To avoid conflicts, we can set a custom LD_LIBRARY_PATH only for the
tor daemon.
parent c454273c
Loading
Loading
Loading
Loading
+9 −0
Changes for toolkit/components/tor-launcher/TorLauncherUtil.sys.mjs: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
 * Tor Launcher Util JS Module
 *************************************************************************/

import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";

const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
@@ -335,6 +337,13 @@ export const TorLauncherUtil = Object.freeze({
    return Services.appinfo.OS === "Android";
  },

  get isLinux() {
    // Use AppConstants for Linux rather then appinfo because we are sure it
    // will catch also various Unix flavors for which unofficial ports might
    // exist (which should work as Linux, as far as we know).
    return AppConstants.platform === "linux";
  },

  get isMac() {
    return Services.appinfo.OS === "Darwin";
  },
+10 −0
Changes for toolkit/components/tor-launcher/TorProcess.sys.mjs: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -125,6 +125,16 @@ export class TorProcess {
        stderr: "stdout",
        workdir: lazy.TorLauncherUtil.getTorFile("pt-startup-dir", false).path,
      };
      if (lazy.TorLauncherUtil.isLinux) {
        let ldLibPath = Services.env.get("LD_LIBRARY_PATH") ?? "";
        if (ldLibPath) {
          ldLibPath = ":" + ldLibPath;
        }
        options.environment = {
          LD_LIBRARY_PATH: this.#exeFile.parent.path + ldLibPath,
        };
        options.environmentAppend = true;
      }
      this.#subprocess = await Subprocess.call(options);
      this.#status = TorProcessStatus.Running;
    } catch (e) {