Bug 1273682 - Build wow_helper on Win x86 and remove sandboxbroker from installer. r=ratty a=ratty
Port
Bug 1035125,
Bug 1110760 and
Bug 1238769.
--- a/suite/app/moz.build
+++ b/suite/app/moz.build
@@ -1,36 +1,43 @@
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# 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/.
-GeckoProgram(CONFIG['MOZ_APP_NAME'], msvcrt='static')
+GeckoProgram(CONFIG['MOZ_APP_NAME'])
USE_LIBS += ['mozglue']
SOURCES += ['nsSuiteApp.cpp']
LOCAL_INCLUDES += [
'!/build',
'/mozilla/toolkit/xre',
'/mozilla/xpcom/base',
'/mozilla/xpcom/build',
]
if CONFIG['OS_ARCH'] == 'WINNT':
RCINCLUDE = 'splash.rc'
DEFINES['MOZ_SUITE'] = True
- DELAYLOAD_DLLS += [
- 'mozglue.dll',
- ]
-
if CONFIG['_MSC_VER']:
# Always enter a Windows program through wmain, whether or not we're
# a console application.
WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
+if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
+ # For sandbox includes and the include dependencies those have
+ LOCAL_INCLUDES += [
+ '/mozilla/security/sandbox/chromium',
+ '/mozilla/security/sandbox/chromium-shim',
+ ]
+
+ USE_LIBS += [
+ 'sandbox_s',
+ ]
+
# Control the default heap size.
# This is the heap returned by GetProcessHeap().
# As we use the CRT heap, the default size is too large and wastes VM.
#
# The default heap size is 1MB on Win32.
# The heap will grow if need be.
#
# Set it to 256k. See bug 127069.
--- a/suite/app/nsSuiteApp.cpp
+++ b/suite/app/nsSuiteApp.cpp
@@ -28,20 +28,24 @@
#include "prprf.h"
#include "prenv.h"
#include "nsCOMPtr.h"
#include "nsIFile.h"
#include "nsStringGlue.h"
#ifdef XP_WIN
+#define XRE_WANT_ENVIRON
// we want a wmain entry point
#include "nsWindowsWMain.cpp"
#define snprintf _snprintf
#define strcasecmp _stricmp
+#ifdef MOZ_SANDBOX
+#include "mozilla/sandboxing/SandboxInitialization.h"
+#endif
#endif
#include "BinaryPath.h"
#include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL
#include "mozilla/Telemetry.h"
#include "mozilla/WindowsDllBlocklist.h"
@@ -109,28 +113,30 @@ static bool IsArg(const char* arg, const
}
XRE_GetFileFromPathType XRE_GetFileFromPath;
XRE_CreateAppDataType XRE_CreateAppData;
XRE_FreeAppDataType XRE_FreeAppData;
XRE_TelemetryAccumulateType XRE_TelemetryAccumulate;
XRE_mainType XRE_main;
XRE_StopLateWriteChecksType XRE_StopLateWriteChecks;
+XRE_XPCShellMainType XRE_XPCShellMain;
static const nsDynamicFunctionLoad kXULFuncs[] = {
{ "XRE_GetFileFromPath", (NSFuncPtr*) &XRE_GetFileFromPath },
{ "XRE_CreateAppData", (NSFuncPtr*) &XRE_CreateAppData },
{ "XRE_FreeAppData", (NSFuncPtr*) &XRE_FreeAppData },
{ "XRE_TelemetryAccumulate", (NSFuncPtr*) &XRE_TelemetryAccumulate },
{ "XRE_main", (NSFuncPtr*) &XRE_main },
{ "XRE_StopLateWriteChecks", (NSFuncPtr*) &XRE_StopLateWriteChecks },
+ { "XRE_XPCShellMain", (NSFuncPtr*) &XRE_XPCShellMain },
{ nullptr, nullptr }
};
-static int do_main(int argc, char* argv[], nsIFile *xreDirectory)
+static int do_main(int argc, char* argv[], char* envp[], nsIFile *xreDirectory)
{
nsCOMPtr<nsIFile> appini;
nsresult rv;
uint32_t mainFlags = 0;
// Allow seamonkey.exe to launch XULRunner apps via -app <application.ini>
// Note that -app must be the *first* argument.
const char *appDataFile = getenv("XUL_APP_FILE");
@@ -157,16 +163,28 @@ static int do_main(int argc, char* argv[
snprintf(appEnv, MAXPATHLEN, "XUL_APP_FILE=%s", argv[2]);
if (putenv(appEnv)) {
Output("Couldn't set %s.\n", appEnv);
return 255;
}
argv[2] = argv[0];
argv += 2;
argc -= 2;
+ } else if (argc > 1 && IsArg(argv[1], "xpcshell")) {
+ for (int i = 1; i < argc; i++) {
+ argv[i] = argv[i + 1];
+ }
+
+ XREShellData shellData;
+#if defined(XP_WIN) && defined(MOZ_SANDBOX)
+ shellData.sandboxBrokerServices =
+ sandboxing::GetInitializedBrokerServices();
+#endif
+
+ return XRE_XPCShellMain(--argc, argv, envp, &shellData);
}
int result;
if (appini) {
nsXREAppData *appData;
rv = XRE_CreateAppData(appini, &appData);
if (NS_FAILED(rv)) {
Output("Couldn't read application.ini");
@@ -189,16 +207,28 @@ static int do_main(int argc, char* argv[
exeFile->GetParent(getter_AddRefs(greDir));
#ifdef XP_MACOSX
greDir->SetNativeLeafName(NS_LITERAL_CSTRING(kOSXResourcesFolder));
#endif
SetStrongPtr(appData.directory, static_cast<nsIFile*>(greDir.get()));
// xreDirectory already has a refcount from NS_NewLocalFile
appData.xreDirectory = xreDirectory;
+#if defined(XP_WIN) && defined(MOZ_SANDBOX)
+ sandbox::BrokerServices* brokerServices =
+ sandboxing::GetInitializedBrokerServices();
+#if defined(MOZ_CONTENT_SANDBOX)
+ if (!brokerServices) {
+ Output("Couldn't initialize the broker services.\n");
+ return 255;
+ }
+#endif
+ appData.sandboxBrokerServices = brokerServices;
+#endif
+
result = XRE_main(argc, argv, &appData, mainFlags);
}
return result;
}
static bool
FileExists(const char *path)
@@ -264,17 +294,17 @@ InitXPCOMGlue(const char *argv0, nsIFile
#else
rv = NS_NewNativeLocalFile(nsDependentCString(exePath), false,
xreDirectory);
#endif
return rv;
}
-int main(int argc, char* argv[])
+int main(int argc, char* argv[], char* envp[])
{
#ifdef XP_MACOSX
TriggerQuirks();
#endif
int gotCounters;
#if defined(XP_UNIX)
struct rusage initialRUsage;
@@ -322,17 +352,17 @@ int main(int argc, char* argv[])
struct rusage newRUsage;
if (!getrusage(RUSAGE_SELF, &newRUsage)) {
XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS,
int(newRUsage.ru_majflt - initialRUsage.ru_majflt));
}
#endif
}
- int result = do_main(argc, argv, xreDirectory);
+ int result = do_main(argc, argv, envp, xreDirectory);
NS_LogTerm();
#ifdef XP_MACOSX
// Allow writes again. While we would like to catch writes from static
// destructors to allow early exits to use _exit, we know that there is
// at least one such write that we don't control (see bug 826029). For
// now we enable writes again and early exits will have to use exit instead
--- a/suite/installer/Makefile.in
+++ b/suite/installer/Makefile.in
@@ -184,16 +184,24 @@ DEFINES += -DMOZ_ICU_DBG_SUFFIX=$(MOZ_IC
DEFINES += -DICU_DATA_FILE=$(ICU_DATA_FILE)
ifdef CLANG_CXX
DEFINES += -DCLANG_CXX
endif
ifdef CLANG_CL
DEFINES += -DCLANG_CL
endif
+ifeq (x86,$(CPU_ARCH))
+ifdef _MSC_VER
+ifndef CLANG_CL
+DEFINES += -DWOW_HELPER
+endif
+endif
+endif
+
ifeq ($(MOZ_PACKAGER_FORMAT),omni)
DEFINES += -DMOZ_OMNIJAR=1
endif
libs::
$(MAKE) -C $(DEPTH)/suite/locales langpack
ifeq (WINNT,$(OS_ARCH))
--- a/suite/installer/package-manifest.in
+++ b/suite/installer/package-manifest.in
@@ -725,17 +725,19 @@
@RESPATH@/chrome/pippki@JAREXT@
@RESPATH@/chrome/pippki.manifest
@RESPATH@/components/pipnss.xpt
@RESPATH@/components/pippki.xpt
; For process sandboxing
#if defined(MOZ_SANDBOX)
#if defined(XP_WIN)
-@BINPATH@/@DLL_PREFIX@sandboxbroker@DLL_SUFFIX@
+#if defined(WOW_HELPER)
+@BINPATH@/wow_helper.exe
+#endif
#endif
#endif
; for Solaris SPARC
#ifdef SOLARIS
bin/libfreebl_32fpu_3.so
bin/libfreebl_32int_3.so
bin/libfreebl_32int64_3.so
--- a/suite/installer/windows/nsis/shared.nsh
+++ b/suite/installer/windows/nsis/shared.nsh
@@ -994,17 +994,16 @@
Push "end"
Push "AccessibleMarshal.dll"
Push "freebl3.dll"
Push "nssckbi.dll"
Push "nspr4.dll"
Push "nssdbm3.dll"
Push "sqlite3.dll"
Push "mozsqlite3.dll"
- Push "sandboxbroker.dll"
Push "xpcom.dll"
Push "crashreporter.exe"
Push "updater.exe"
Push "xpicleanup.exe"
Push "MapiProxy.dll"
Push "MapiProxy_InUse.dll"
Push "mozMapi32.dll"
Push "mozMapi32_InUse.dll"