Index | Thread | Search

From:
Caspar Schutijser <caspar@schutijser.com>
Subject:
Tor Browser: remove tor-browser.cfg
To:
ports@openbsd.org
Date:
Thu, 10 Jul 2025 22:29:07 +0200

Download raw body.

Thread
  • Caspar Schutijser:

    Tor Browser: remove tor-browser.cfg

Hi,

Below is a diff that removes removes tor-browser.cfg from the port.
When you start "tor-browser --jsconsole", one of the first messages
on the message console is the following:
    ReferenceError: Components is not defined (tor-browser.cfg:2:50)
        <anonymous> tor-browser.cfg:2
I.e., it errors out right at the beginning of executing tor-browser.cfg.

So whatever purpose this file had in the past, it's clearly not
fulfilling that purpose anymore. That purpose seems to be to
pre-populate a fresh browser profile, but from what I can see, it's
working fine without this code being executed.

My plan is to remove this file from the Tor Browser port.
Anyone with knowledge about this who agrees or disagrees?

Caspar


Index: browser/Makefile
===================================================================
RCS file: /cvs/ports/www/tor-browser/browser/Makefile,v
diff -u -p -r1.173 Makefile
--- browser/Makefile	25 Jun 2025 19:36:56 -0000	1.173
+++ browser/Makefile	10 Jul 2025 20:20:27 -0000
@@ -12,6 +12,7 @@ EXTRACT_SUFX =		.tar.xz
 
 PKGNAME =		${TB_PREFIX}-browser-${TB_VERSION:S/a/alpha/}
 DISTNAME =		src-firefox-tor-browser-128.12.0esr-14.5-1-build1
+REVISION =		0
 
 FIX_EXTRACT_PERMISSIONS	= Yes
 DISTFILES +=		${DISTNAME}.tar.xz \
@@ -140,7 +141,6 @@ post-patch:
 
 BROWSER_DIR = ${PREFIX}/lib/${BROWSER_NAME}
 TRUEBROWSER_DIR = ${TRUEPREFIX}/lib/${BROWSER_NAME}
-BROWSER_CFG = ${BROWSER_DIR}/${BROWSER_NAME}.cfg
 BROWSER_INI = ${BROWSER_DIR}/distribution/distribution.ini
 
 SUBST_VARS +=		TRUEBROWSER_DIR
@@ -153,10 +153,6 @@ post-install:
 	${INSTALL_DATA_DIR} ${BROWSER_DIR}/browser/defaults/profile
 	${INSTALL_DATA} ${FILESDIR}/bookmarks.html \
 	  ${BROWSER_DIR}/browser/defaults/profile
-	# tor-browser JS config file
-	${INSTALL_DATA} ${FILESDIR}/${BROWSER_NAME}.cfg ${BROWSER_CFG}
-	chown ${SHAREOWN}:${SHAREGRP} ${BROWSER_CFG}
-	chmod ${SHAREMODE} ${BROWSER_CFG}
 	# install distribution.ini file
 	${INSTALL_DATA_DIR} ${BROWSER_DIR}/distribution
 	echo "[Global]\nid=OpenBSD\nversion=${OSREV}\n" > ${BROWSER_INI}
Index: browser/files/tor-browser.cfg
===================================================================
RCS file: browser/files/tor-browser.cfg
diff -N browser/files/tor-browser.cfg
--- browser/files/tor-browser.cfg	6 Sep 2023 09:42:29 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,60 +0,0 @@
-// c.f. https://web.archive.org/web/20210530175830/https://mike.kaply.com/2016/05/24/default-profile-directory-doesnt-work-in-firefox-46/
-
-const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/FileUtils.jsm");
-
-var profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
-var certDBFile = profileDir.clone();
-certDBFile.append("cert8.db")
-// If cert8.db isn't there, it's a new profile
-if (!certDBFile.exists()) {
-  var defaultProfileDir = Services.dirsvc.get("GreD", Ci.nsIFile);
-  defaultProfileDir.append("browser");
-  defaultProfileDir.append("defaults");
-  defaultProfileDir.append("profile");
-  try {
-    copyDir(defaultProfileDir, profileDir);
-  } catch (e) {
-    Components.utils.reportError(e);
-  }
-}
- 
-function copyDir(aOriginal, aDestination) {
-  var enumerator = aOriginal.directoryEntries;
-  while (enumerator.hasMoreElements()) {
-    var file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile);
-    if (file.isDirectory()) {
-      var subdir = aDestination.clone();
-      subdir.append(file.leafName);
-      try {
-        subdir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
-        copyDir(file, subdir);
-      } catch (e) {
-        Components.utils.reportError(e);
-      }
-    } else {
-      try {
-        file.copyTo(aDestination, null);
-      } catch (e) {
-        Components.utils.reportError(e);
-      }
-    }
-  }
-}
-
-// OpenBSD: Initialize <ProfD>/torrc to an empty config.
-// The first SAVECONF to the tor control socket will overwrite it.
-
-// mimic the code in tl-util.jsm from tor-launcher
-var dir = Cc["@mozilla.org/file/directory_service;1"].
-           getService(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
-var file = dir.parent.parent;
-file.append("torrc");
-if (!file.exists()) {
-    var stream = Cc["@mozilla.org/network/file-output-stream;1"].
-                 createInstance(Ci.nsIFileOutputStream);
-    stream.init(file, 0x04 | 0x08 | 0x20, 0600, 0);
-    stream.write("#\n", 2);
-    stream.close();
-}
Index: browser/pkg/PLIST
===================================================================
RCS file: /cvs/ports/www/tor-browser/browser/pkg/PLIST,v
diff -u -p -r1.26 PLIST
--- browser/pkg/PLIST	22 Apr 2025 05:58:13 -0000	1.26
+++ browser/pkg/PLIST	10 Jul 2025 20:20:27 -0000
@@ -216,7 +216,6 @@ lib/${BROWSER_NAME}/platform.ini
 lib/${BROWSER_NAME}/removed-files
 @bin lib/${BROWSER_NAME}/${BROWSER_NAME}
 @bin lib/${BROWSER_NAME}/${BROWSER_NAME}-bin
-lib/${BROWSER_NAME}/${BROWSER_NAME}.cfg
 @bin lib/${BROWSER_NAME}/vaapitest
 share/applications/${BROWSER_NAME}.desktop
 share/icons/hicolor/128x128/apps/${BROWSER_NAME}.png