Pier Angelo Vendrame pushed to branch tor-browser-148.0a1-16.0-2 at The Tor Project / Applications / Tor Browser Commits: 04a2b859 by Pier Angelo Vendrame at 2026-03-04T15:10:53+01:00 fixup! TB 43107: Disable remoting by default TB 44706: Fix a crash when creating new profiles. Rework the patch to disable remoting at runtime to allow using some of the service's functionalities, while still refusing to create any remoting server/client. - - - - - 3 changed files: - toolkit/components/remote/nsRemoteService.cpp - toolkit/components/remote/nsRemoteService.h - toolkit/xre/nsAppRunner.cpp Changes: ===================================== toolkit/components/remote/nsRemoteService.cpp ===================================== @@ -53,7 +53,8 @@ nsStartupLock::~nsStartupLock() { NS_IMPL_ISUPPORTS(nsRemoteService, nsIObserver, nsIRemoteService) -nsRemoteService::nsRemoteService() : mProgram("mozilla") { +nsRemoteService::nsRemoteService(bool aRemotingEnabled) + : mRemotingEnabled(aRemotingEnabled), mProgram("mozilla") { ToLowerCase(mProgram); } @@ -194,6 +195,10 @@ nsresult nsRemoteService::SendCommandLine(const nsACString& aProfile, return NS_ERROR_FAILURE; } + if (!mRemotingEnabled) { + return NS_ERROR_NOT_AVAILABLE; + } + UniquePtr<nsRemoteClient> client; #ifdef MOZ_WIDGET_GTK # if defined(MOZ_ENABLE_DBUS) @@ -249,7 +254,7 @@ nsresult nsRemoteService::StartClient() { } void nsRemoteService::StartupServer() { - if (mRemoteServer) { + if (mRemoteServer || !mRemotingEnabled) { return; } ===================================== toolkit/components/remote/nsRemoteService.h ===================================== @@ -39,7 +39,7 @@ class nsRemoteService final : public nsIObserver, public nsIRemoteService { NS_DECL_NSIOBSERVER NS_DECL_NSIREMOTESERVICE - nsRemoteService(); + nsRemoteService(bool aRemotingEnabled); void SetProgram(const char* aProgram); void SetProfile(nsACString& aProfile); #ifdef MOZ_WIDGET_GTK @@ -91,6 +91,7 @@ class nsRemoteService final : public nsIObserver, public nsIRemoteService { nsresult SendCommandLine(const nsACString& aProfile, size_t aArgc, const char** aArgv, bool aRaise); + bool mRemotingEnabled; mozilla::UniquePtr<nsRemoteServer> mRemoteServer; nsCString mProgram; nsCString mProfile; ===================================== toolkit/xre/nsAppRunner.cpp ===================================== @@ -314,7 +314,7 @@ static nsIProfileLock* gProfileLock; constinit static RefPtr<nsRemoteService> gRemoteService; constinit static RefPtr<nsStartupLock> gStartupLock; // tor-browser#43107: Disable remoting by default. -bool gDisableRemoting = true; +bool gEnableRemoting = false; #endif int gRestartArgc; @@ -2095,8 +2095,8 @@ nsresult ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport* native) { /* static */ already_AddRefed<nsIRemoteService> GetRemoteService() { AssertIsOnMainThread(); - if (!gRemoteService && !gDisableRemoting) { - gRemoteService = new nsRemoteService(); + if (!gRemoteService) { + gRemoteService = new nsRemoteService(gEnableRemoting); } nsCOMPtr<nsIRemoteService> remoteService = gRemoteService.get(); return remoteService.forget(); @@ -4487,7 +4487,7 @@ int XREMain::XRE_mainInit(bool* aExitFlag) { // The user can still enable remoting if they want to, by adding the // allow-remote parameter to the command line. if (CheckArg("allow-remote") == ARG_FOUND) { - gDisableRemoting = false; + gEnableRemoting = true; } #else // These arguments do nothing in platforms with no remoting support but we @@ -4882,7 +4882,7 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) { #ifdef MOZ_HAS_REMOTE if (gfxPlatform::IsHeadless()) { - gDisableRemoting = true; + gEnableRemoting = false; } #endif @@ -5004,10 +5004,8 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) { } #endif #if defined(MOZ_HAS_REMOTE) - if (!gDisableRemoting) { - // handle --remote now that xpcom is fired up - gRemoteService = new nsRemoteService(); - } + // handle --remote now that xpcom is fired up + gRemoteService = new nsRemoteService(gEnableRemoting); if (gRemoteService) { gRemoteService->SetProgram(gAppData->remotingName); gStartupLock = gRemoteService->LockStartup(); @@ -5092,7 +5090,7 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) { if (NS_SUCCEEDED(rv)) { gRemoteService->SetProfile(profilePath); - if (!gDisableRemoting) { + if (gEnableRemoting) { // Try to remote the entire command line. If this fails, start up // normally. # ifdef MOZ_WIDGET_GTK View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/04a2b859... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/04a2b859... You're receiving this email because of your account on gitlab.torproject.org.
participants (1)
-
Pier Angelo Vendrame (@pierov)