diff --git a/configure.in b/configure.in index 6ca3feece95d..82c410bb92a6 100644 --- a/configure.in +++ b/configure.in @@ -3840,6 +3840,7 @@ MOZ_AUDIO_CHANNEL_MANAGER= NSS_NO_LIBPKIX= MOZ_CONTENT_SANDBOX= MOZ_GMP_SANDBOX= +MOZ_SANDBOX=1 JSGC_USE_EXACT_ROOTING=1 JSGC_GENERATIONAL= @@ -6348,11 +6349,19 @@ if test -n "$NSS_NO_LIBPKIX"; then fi AC_SUBST(NSS_NO_LIBPKIX) +dnl ======================================================== +dnl = Sandboxing support +dnl ======================================================== +MOZ_ARG_DISABLE_BOOL(sandbox, +[ --disable-sandbox Disable sandboxing support], + MOZ_SANDBOX=, + MOZ_SANDBOX=1) + dnl ======================================================== dnl = Content process sandboxing dnl ======================================================== if test -n "$gonkdir"; then - MOZ_CONTENT_SANDBOX=1 + MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX fi MOZ_ARG_ENABLE_BOOL(content-sandbox, @@ -6371,17 +6380,17 @@ dnl = Gecko Media Plugin sandboxing dnl ======================================================== case $OS_TARGET in WINNT) - MOZ_GMP_SANDBOX=1 + MOZ_GMP_SANDBOX=$MOZ_SANDBOX ;; Linux) case $CPU_ARCH in x86_64|x86) - MOZ_GMP_SANDBOX=1 + MOZ_GMP_SANDBOX=$MOZ_SANDBOX ;; esac ;; Darwin) - MOZ_GMP_SANDBOX=1 + MOZ_GMP_SANDBOX=$MOZ_SANDBOX ;; esac @@ -6391,6 +6400,17 @@ fi AC_SUBST(MOZ_GMP_SANDBOX) +if test -z "$MOZ_CONTENT_SANDBOX" -a -z "$MOZ_GMP_SANDBOX"; then + MOZ_SANDBOX= +fi + +if test -n "$MOZ_SANDBOX"; then + AC_DEFINE(MOZ_SANDBOX) +fi + +AC_SUBST(MOZ_SANDBOX) + + dnl ======================================================== dnl = dnl = Module specific options diff --git a/content/media/gmp/GMPChild.cpp b/content/media/gmp/GMPChild.cpp index aa117f3e56ed..a76f46a575b7 100644 --- a/content/media/gmp/GMPChild.cpp +++ b/content/media/gmp/GMPChild.cpp @@ -24,7 +24,7 @@ using mozilla::dom::CrashReporterChild; #include // for _exit() #endif -#if defined(XP_WIN) +#if defined(MOZ_SANDBOX) && defined(XP_WIN) #define TARGET_SANDBOX_EXPORTS #include "mozilla/sandboxTarget.h" #elif defined (MOZ_GMP_SANDBOX) @@ -235,7 +235,7 @@ GMPChild::Init(const std::string& aPluginPath, return true; #endif -#if defined(XP_WIN) +#if defined(MOZ_SANDBOX) && defined(XP_WIN) mozilla::SandboxTarget::Instance()->StartSandbox(); #endif diff --git a/ipc/app/moz.build b/ipc/app/moz.build index cbb3db3d517d..b02a7cc9c659 100644 --- a/ipc/app/moz.build +++ b/ipc/app/moz.build @@ -28,7 +28,7 @@ LOCAL_INCLUDES += [ '/xpcom/base', ] -if CONFIG['OS_ARCH'] == 'WINNT': +if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT': # For sandbox includes and the include dependencies those have LOCAL_INCLUDES += [ '/security', diff --git a/ipc/contentproc/plugin-container.cpp b/ipc/contentproc/plugin-container.cpp index 5dc6736a4571..e60373aff21a 100644 --- a/ipc/contentproc/plugin-container.cpp +++ b/ipc/contentproc/plugin-container.cpp @@ -21,7 +21,7 @@ #include "nsSetDllDirectory.h" #endif -#if defined(XP_WIN) +#if defined(XP_WIN) && defined(MOZ_SANDBOX) #include "sandbox/chromium/base/basictypes.h" #include "sandbox/win/src/sandbox.h" #include "sandbox/win/src/sandbox_factory.h" @@ -68,7 +68,7 @@ InitializeBinder(void *aDummy) { } #endif -#if defined(XP_WIN) +#if defined(XP_WIN) && defined(MOZ_SANDBOX) static bool gIsSandboxEnabled = false; void StartSandboxCallback() { @@ -93,7 +93,7 @@ content_process_main(int argc, char* argv[]) bool isNuwa = false; for (int i = 1; i < argc; i++) { isNuwa |= strcmp(argv[i], "-nuwa") == 0; -#if defined(XP_WIN) +#if defined(XP_WIN) && defined(MOZ_SANDBOX) gIsSandboxEnabled |= strcmp(argv[i], "-sandbox") == 0; #endif } @@ -130,6 +130,7 @@ content_process_main(int argc, char* argv[]) SetDllDirectory(L""); } +#ifdef MOZ_SANDBOX if (gIsSandboxEnabled) { sandbox::TargetServices* target_service = sandbox::SandboxFactory::GetTargetServices(); @@ -143,6 +144,7 @@ content_process_main(int argc, char* argv[]) } mozilla::SandboxTarget::Instance()->SetStartSandboxCallback(StartSandboxCallback); } +#endif #endif nsresult rv = XRE_InitChildProcess(argc, argv); diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index c7cfda9def8f..faacb1e5b139 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -126,7 +126,7 @@ GeckoChildProcessHost::GetPathToBinary(FilePath& exePath) if (ShouldHaveDirectoryService()) { MOZ_ASSERT(gGREPath); #ifdef OS_WIN - exePath = FilePath(gGREPath); + exePath = FilePath(char16ptr_t(gGREPath)); #else nsCString path; NS_CopyUnicodeToNative(nsDependentString(gGREPath), path); @@ -781,11 +781,13 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt // shouldSandboxCurrentProcess = true; break; case GeckoProcessType_GMPlugin: +#ifdef MOZ_SANDBOX if (!PR_GetEnv("MOZ_DISABLE_GMP_SANDBOX")) { mSandboxBroker.SetSecurityLevelForGMPlugin(); cmdLine.AppendLooseValue(UTF8ToWide("-sandbox")); shouldSandboxCurrentProcess = true; } +#endif break; case GeckoProcessType_Default: default: @@ -815,7 +817,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt // Process type cmdLine.AppendLooseValue(UTF8ToWide(childProcessType)); -#if defined(XP_WIN) +#if defined(XP_WIN) && defined(MOZ_SANDBOX) if (shouldSandboxCurrentProcess) { mSandboxBroker.LaunchApp(cmdLine.program().c_str(), cmdLine.command_line_string().c_str(), diff --git a/ipc/glue/GeckoChildProcessHost.h b/ipc/glue/GeckoChildProcessHost.h index 885ea4118752..fc3097bc6acb 100644 --- a/ipc/glue/GeckoChildProcessHost.h +++ b/ipc/glue/GeckoChildProcessHost.h @@ -20,7 +20,7 @@ #include "nsXULAppAPI.h" // for GeckoProcessType #include "nsString.h" -#if defined(XP_WIN) +#if defined(XP_WIN) && defined(MOZ_SANDBOX) #include "sandboxBroker.h" #endif @@ -165,7 +165,10 @@ protected: #ifdef XP_WIN void InitWindowsGroupID(); nsString mGroupId; + +#ifdef MOZ_SANDBOX SandboxBroker mSandboxBroker; +#endif #endif // XP_WIN #if defined(OS_POSIX) diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index 092b08649a7f..6b6c7c683260 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -50,7 +50,7 @@ USE_LIBS += [ 'js', ] -if CONFIG['OS_ARCH'] == 'WINNT': +if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT': USE_LIBS += [ 'sandboxbroker', ] diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild index c4f71f1c26b2..560ebafd3fb0 100644 --- a/toolkit/toolkit.mozbuild +++ b/toolkit/toolkit.mozbuild @@ -6,7 +6,7 @@ if CONFIG['LIBXUL_SDK']: error('toolkit.mozbuild is not compatible with --enable-libxul-sdk=') -if CONFIG['MOZ_CONTENT_SANDBOX'] or CONFIG['MOZ_GMP_SANDBOX']: +if CONFIG['MOZ_SANDBOX']: add_tier_dir('sandbox', 'security/sandbox') # Depends on NSS and NSPR, and must be built after sandbox or else B2G emulator