[tbb-commits] [Git][tpo/applications/tor-browser][tor-browser-102.6.0esr-12.5-1] 5 commits: dropme! Partial revert of Bug 13252

Richard Pospesel (@richard) git at gitlab.torproject.org
Tue Jan 10 18:12:54 UTC 2023



Richard Pospesel pushed to branch tor-browser-102.6.0esr-12.5-1 at The Tor Project / Applications / Tor Browser


Commits:
5858c308 by Pier Angelo Vendrame at 2023-01-10T18:10:55+01:00
dropme! Partial revert of Bug 13252

I need to modify Bug 9173. So, I am removing a few changes from 13252
to make both the modifications and the rebase easier.

- - - - -
acdcfcae by Pier Angelo Vendrame at 2023-01-10T18:11:04+01:00
fixup! Bug 2176: Rebrand Firefox to TorBrowser

This commit adds TorProject as the vendor of Tor Browser.
This should be visible both in the Windows binaries, and will be used
to create the profile directory if we disable the portable mode.

- - - - -
5c5e44d0 by Pier Angelo Vendrame at 2023-01-10T18:13:36+01:00
fixup! Bug 9173: Change the default Firefox profile directory to be relative.

Bug 20497: Make it possible to disable portable mode

9173 is the patch that enables portable mode for Tor Browser.
We modified it to make it optional, but it still used to remove a few
important parts that made it compulsory to define a profile directory
in the application.ini (through the mozconfig).

This commit restores these parts, and makes it hopefully possible to
disable portable mode without filling the home directory with TBB
files.
A few parts are then disabled in a following commit, since they are
TBB-legacy behavior, but we might not want them for base-browser and
for privacy-browser.

Also, this commit changes the configure flag from
--with-relative-profile-directory to --with-relative-data-dir, because
the data directories can contain the profile and the local data such as
caches, not only the profile.
Still, we are assuming we are using the same data directory for the
profile and for the caches, which is not the case on Windows (where the
profile is roaming, and the caches are local) and on Linux (where the
profile is in the home, and the cache is in ~/.cache).

- - - - -
458fbecf by Pier Angelo Vendrame at 2023-01-10T18:13:44+01:00
fixup! TB3: Tor Browser's official .mozconfigs.

Change relative-profile-directory with relative-data-dir.

- - - - -
a958edce by Pier Angelo Vendrame at 2023-01-10T18:13:45+01:00
fixup! Bug 13252: Do not store data in the app bundle

Bug 20497: Make it possible to use Tor Browser in non-portable mode

Add back some legacy Tor Browser-specific behaviors that we restored in
9173.

Bug 41535: Remove the old, unused and undocumented "-invisible" macOS CLI flag

- - - - -


6 changed files:

- browser/config/mozconfigs/tor-browser
- browser/confvars.sh
- moz.configure
- toolkit/xre/nsAppRunner.cpp
- toolkit/xre/nsXREDirProvider.cpp
- xpcom/io/nsAppFileLocationProvider.cpp


Changes:

=====================================
browser/config/mozconfigs/tor-browser
=====================================
@@ -1,8 +1,15 @@
 . $topsrcdir/browser/config/mozconfigs/base-browser
 
+export MOZ_APP_BASENAME="TorBrowser"
 mk_add_options MOZ_APP_DISPLAYNAME="Tor Browser"
 
-ac_add_options --with-relative-profile=TorBrowser/Data/Browser
+ac_add_options --with-relative-data-dir=TorBrowser/Data/Browser
+# This is not needed with the relative data directory, but it is when you
+# disable it, otherwise it is "Mozilla" (on Windows and macOS) or ".mozilla" on
+# Unix systems.
+# It is used, for example, for GetProductDirectory.
+# ac_add_options --with-user-appdir=TorProject
+# ac_add_options --with-user-appdir=.torproject
 
 ac_add_options --enable-tor-browser-update
 ac_add_options --enable-verify-mar


=====================================
browser/confvars.sh
=====================================
@@ -3,7 +3,7 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-MOZ_APP_VENDOR=Mozilla
+MOZ_APP_VENDOR="Tor Project"
 
 BROWSER_CHROME_URL=chrome://browser/content/browser.xhtml
 


=====================================
moz.configure
=====================================
@@ -1026,22 +1026,22 @@ set_define("BASE_BROWSER", True, when="--enable-base-browser")
 
 
 option(
-    "--with-relative-profile",
+    "--with-relative-data-dir",
     nargs=1,
-    help="Sets the directory of the profile, relative to the application directory"
+    help="Sets the data directories to be relative to the application directory"
 )
 
 
- at depends("--with-relative-profile", target)
+ at depends("--with-relative-data-dir", target)
 @imports("json")
-def relative_profile(value, target):
+def relative_data_dir(value, target):
     if value and target.os == "Android":
-        die("--with-relative-profile is not supported on Android")
+        die("--with-relative-data-dir is not supported on Android")
     if value:
         return json.dumps(value[0])
 
 
-set_define("RELATIVE_PROFILE_DIRECTORY", relative_profile)
+set_define("RELATIVE_DATA_DIR", relative_data_dir)
 
 
 # Tor additions.


=====================================
toolkit/xre/nsAppRunner.cpp
=====================================
@@ -4158,14 +4158,6 @@ int XREMain::XRE_mainInit(bool* aExitFlag) {
   if (PR_GetEnv("XRE_MAIN_BREAK")) NS_BREAK();
 #endif
 
-#if defined(XP_MACOSX) && defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
-  bool hideDockIcon = (CheckArg("invisible") == ARG_FOUND);
-  if (hideDockIcon) {
-    ProcessSerialNumber psn = {0, kCurrentProcess};
-    TransformProcessType(&psn, kProcessTransformToBackgroundApplication);
-  }
-#endif
-
   mozilla::startup::IncreaseDescriptorLimits();
 
 #ifdef USE_GLX_TEST
@@ -5222,6 +5214,14 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
     if (CheckArg("test-process-updates")) {
       SaveToEnv("MOZ_TEST_PROCESS_UPDATES=1");
     }
+#  ifndef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
+    nsCOMPtr<nsIFile> exeFile, exeDir;
+    rv = mDirProvider.GetFile(XRE_EXECUTABLE_FILE, &persistent,
+                              getter_AddRefs(exeFile));
+    NS_ENSURE_SUCCESS(rv, 1);
+    rv = exeFile->GetParent(getter_AddRefs(exeDir));
+#  endif
+
 #  ifdef TOR_BROWSER_UPDATE
     nsAutoCString compatVersion(TOR_BROWSER_VERSION_QUOTED);
 #  endif


=====================================
toolkit/xre/nsXREDirProvider.cpp
=====================================
@@ -236,6 +236,11 @@ nsresult nsXREDirProvider::GetUserProfilesRootDir(nsIFile** aResult) {
   nsresult rv = GetUserDataDirectory(getter_AddRefs(file), false);
 
   if (NS_SUCCEEDED(rv)) {
+    // For some reason, we have decided not to append "Profiles" in Tor Browser.
+    // So, let's keep removing it, or we should somehow migrate the profile.
+#if !defined(TOR_BROWSER_VERSION) && (!defined(XP_UNIX) || defined(XP_MACOSX))
+    rv = file->AppendNative("Profiles"_ns);
+#endif
     // We must create the profile directory here if it does not exist.
     nsresult tmp = EnsureDirectoryExists(file);
     if (NS_FAILED(tmp)) {
@@ -251,6 +256,9 @@ nsresult nsXREDirProvider::GetUserProfilesLocalDir(nsIFile** aResult) {
   nsresult rv = GetUserDataDirectory(getter_AddRefs(file), true);
 
   if (NS_SUCCEEDED(rv)) {
+#if !defined(TOR_BROWSER_VERSION) && (!defined(XP_UNIX) || defined(XP_MACOSX))
+    rv = file->AppendNative("Profiles"_ns);
+#endif
     // We must create the profile directory here if it does not exist.
     nsresult tmp = EnsureDirectoryExists(file);
     if (NS_FAILED(tmp)) {
@@ -1366,8 +1374,7 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
     return gDataDirHome->Clone(aFile);
   }
 
-#if defined(RELATIVE_PROFILE_DIRECTORY) || \
-    defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
+#if defined(RELATIVE_DATA_DIR) || defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
 #  ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
   rv = GetTorBrowserUserDataDir(getter_AddRefs(localDir));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1379,10 +1386,10 @@ nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
   }
   rv = singleton->GetAppRootDir(getter_AddRefs(localDir));
   NS_ENSURE_SUCCESS(rv, rv);
-  nsAutoCString profileDir(RELATIVE_PROFILE_DIRECTORY);
+  nsAutoCString profileDir(RELATIVE_DATA_DIR);
   rv = localDir->SetRelativePath(localDir.get(), profileDir);
   NS_ENSURE_SUCCESS(rv, rv);
-#endif
+#  endif
   if (aLocal) {
     rv = localDir->AppendNative("Caches"_ns);
     NS_ENSURE_SUCCESS(rv, rv);
@@ -1555,7 +1562,7 @@ nsresult nsXREDirProvider::GetAppRootDir(nsIFile** aFile) {
 #endif
   while (levelsToRemove-- > 0) {
     rv = file->GetParent(getter_AddRefs(appRootDir));
-  NS_ENSURE_SUCCESS(rv, rv);
+    NS_ENSURE_SUCCESS(rv, rv);
     file = appRootDir;
   }
   return appRootDir->Clone(aFile);
@@ -1612,8 +1619,13 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
   }
 
   nsAutoCString profile;
+  nsAutoCString appName;
+  nsAutoCString vendor;
   if (gAppData->profile) {
     profile = gAppData->profile;
+  } else {
+    appName = gAppData->name;
+    vendor = gAppData->vendor;
   }
 
   nsresult rv = NS_OK;
@@ -1621,12 +1633,27 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
 #if defined(XP_MACOSX)
   if (!profile.IsEmpty()) {
     rv = AppendProfileString(aFile, profile.get());
+#  ifndef RELATIVE_DATA_DIR
+  } else {
+    // Note that MacOS ignores the vendor when creating the profile hierarchy -
+    // all application preferences directories live alongside one another in
+    // ~/Library/Application Support/
+    rv = aFile->AppendNative(appName);
+#  endif
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
 #elif defined(XP_WIN)
   if (!profile.IsEmpty()) {
     rv = AppendProfileString(aFile, profile.get());
+#  ifndef RELATIVE_DATA_DIR
+  } else {
+    if (!vendor.IsEmpty()) {
+      rv = aFile->AppendNative(vendor);
+      NS_ENSURE_SUCCESS(rv, rv);
+    }
+    rv = aFile->AppendNative(appName);
+#  endif
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -1638,21 +1665,48 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) {
   rv = aFile->AppendNative(nsDependentCString("mozilla"));
   NS_ENSURE_SUCCESS(rv, rv);
 #elif defined(XP_UNIX)
+  nsAutoCString folder;
+  // Make it hidden (by starting with "."), except when local (the
+  // profile is already under ~/.cache or XDG_CACHE_HOME).
+#  ifndef RELATIVE_DATA_DIR
+  if (!aLocal) folder.Assign('.');
+#  endif
+
   if (!profile.IsEmpty()) {
     // Skip any leading path characters
     const char* profileStart = profile.get();
     while (*profileStart == '/' || *profileStart == '\\') profileStart++;
 
+#  ifndef RELATIVE_DATA_DIR
     // On the off chance that someone wanted their folder to be hidden don't
     // let it become ".."
-    if (*profileStart == '.') profileStart++;
+    if (*profileStart == '.' && !aLocal) profileStart++;
+#  endif
 
-    // Make it hidden (by starting with ".").
-    nsAutoCString folder(".");
     folder.Append(profileStart);
     ToLowerCase(folder);
 
     rv = AppendProfileString(aFile, folder.BeginReading());
+#  ifndef RELATIVE_DATA_DIR
+  } else {
+    if (!vendor.IsEmpty()) {
+      folder.Append(vendor);
+      ToLowerCase(folder);
+
+      rv = aFile->AppendNative(folder);
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      folder.Truncate();
+    }
+
+    // This can be the case in tests.
+    if (!appName.IsEmpty()) {
+      folder.Append(appName);
+      ToLowerCase(folder);
+
+      rv = aFile->AppendNative(folder);
+    }
+#  endif
   }
   NS_ENSURE_SUCCESS(rv, rv);
 


=====================================
xpcom/io/nsAppFileLocationProvider.cpp
=====================================
@@ -249,8 +249,7 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
   bool exists;
   nsCOMPtr<nsIFile> localDir;
 
-#if defined(RELATIVE_PROFILE_DIRECTORY) || \
-    defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
+#if defined(RELATIVE_DATA_DIR) || defined(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
   nsCOMPtr<nsIProperties> directoryService(
       do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -263,26 +262,24 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
   rv = file->Normalize();
   NS_ENSURE_SUCCESS(rv, rv);
   int levelsToRemove = 1;
-#if defined(XP_MACOSX)
+#  if defined(XP_MACOSX)
   levelsToRemove += 2;
-#endif
+#  endif
   while (levelsToRemove-- > 0) {
     rv = file->GetParent(getter_AddRefs(appRootDir));
     NS_ENSURE_SUCCESS(rv, rv);
     file = appRootDir;
   }
 
-#ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
+#  ifdef TOR_BROWSER_DATA_OUTSIDE_APP_DIR
   rv = TorBrowser_GetUserDataDir(appRootDir, getter_AddRefs(localDir));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = localDir->AppendNative("Browser"_ns);
-#else
+#  else
   localDir = appRootDir;
-  nsAutoCString profileDir(RELATIVE_PROFILE_DIRECTORY);
+  nsAutoCString profileDir(RELATIVE_DATA_DIR);
   rv = localDir->SetRelativePath(localDir.get(), profileDir);
-  NS_ENSURE_SUCCESS(rv, rv);
-#endif
-
+#  endif
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (aLocal) {
@@ -329,6 +326,12 @@ nsresult nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
 #  error dont_know_how_to_get_product_dir_on_your_platform
 #endif
 
+#if !defined(RELATIVE_DATA_DIR) && !defined(TOR_BROWSER_VERSION)
+  rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+#endif
   rv = localDir->Exists(&exists);
 
   if (NS_SUCCEEDED(rv) && !exists) {
@@ -362,6 +365,26 @@ nsresult nsAppFileLocationProvider::GetDefaultUserProfileRoot(
     return rv;
   }
 
+#if defined(MOZ_WIDGET_COCOA) || defined(XP_WIN)
+  // These 3 platforms share this part of the path - do them as one
+#  ifndef TOR_BROWSER_VERSION
+  // Legacy: we do not use "Profiles" on Tor Browser.
+  rv = localDir->AppendRelativeNativePath("Profiles"_ns);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+#  endif
+
+  bool exists;
+  rv = localDir->Exists(&exists);
+  if (NS_SUCCEEDED(rv) && !exists) {
+    rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
+  }
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+#endif
+
   localDir.forget(aLocalFile);
 
   return rv;



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/060e2d7264ba72b12dae5c4b4c0589f9f997d0d6...a958edce34b38d994014cc810375b67594fd18eb

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/060e2d7264ba72b12dae5c4b4c0589f9f997d0d6...a958edce34b38d994014cc810375b67594fd18eb
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20230110/b9997234/attachment-0001.htm>


More information about the tbb-commits mailing list