Files
palemoon27/ipc/contentproc/plugin-container.cpp
T
roytam1 159e57a025 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1171796: Add sandbox rule for child process NSPR log file on Windows. r=bbondy (1393c5eed4)
- Bug 1171994: Separate RIL I/O interfaces, r=htsai (eb62c398f9)
- Bug 1171994: Store an instance of |RilWorker| for each RIL connection, r=htsai (6f85151cfe)
- Bug 1171464 - Check that socket isn't already closed before closing it, r=kmachulis (05a6ecd79c)
- Bug 1156352: Remove |UnixSocketRawData| from RIL interfaces, r=htsai (4c2c066809)
- Bug 1171994: Use |RilSocket| to handle RIL messages on the RIL worker, r=htsai (cdbc7a3868)
- Bug 1171994: Cleanup JSAPI code of |RilConsumer|, r=htsai (eaf9623f2c)
- Bug 1207539 - Remove !JS_IsRunning(aCx) assertion from RilConsumer::ConnectWorkerToRIL; r=mrbkap (f5d20f6d75)
- missing bit of Bug 1138293 - Use malloc/free/realloc/calloc (3cdb9ee5d6)
- Bug 1140261 - Fix compiler error comparison of unsigned expression >= 0 is always true. r=hchang (f808fc5f09)
- Bug 1158896 - prevent dead code from being generated in lower.py; r=bent (8ebbd3109d)
- Bug 1169382 - Don't generate commented out NS_INTERFACE_CLASS or NS_ABSTRACT_CLASS in IPDL. r=billm (20fc4894c0)
- Bug 1219537 - Simplify a couple of PresContext() gets on nsIFrame/nsStyleContext. r=dholbert (cff7f8aa43)
- Bug 1223258 - Fix -Wunreachable-code warnings in widget. r=masayuki (8682636334)
- bit of Add an nsIGfxInfo function to query monitors. (bug 1175005 partart 1) (36bb03dfb2)
- Bug 1210086 - Fix warnings caused by toolbar buttons in gtk2. r=karl (0e7f0aaba2)
- Bug 1176109 - Don't attach menu popups to menubars on GTK3. r=karlt (1cbdd6798f)
- Bug 1188138 - Prevent default buttons from being drawn twice on GTK3. r=karlt (24d3b48643)
- Bug 1189028 - Draw a toplevel popup behind popup menus on GTK3. r=karlt (6dcb65f4af)
- Bug 1160154 - Decrease padding between icons in the personal toolbar with Gtk3 by using "image-button" css style class. r=karlt (50254fd1ce)
- Bug 1073117 - Fixed Theme issues with GTK 3.14 - GtkButtons - use border style (cde1375eec)
- Bug 1168578 - Use widget state in GTK3 toggles' style context. r=karlt (2889392859)
- Bug 1198613 - Use GTK style padding for dropdown boxes in HTML. r=karlt (5e97b42105)
- Bug 1216582 - [gtk3] Scrollbar buttons not drawn correctly. r=karlt (4a7ca51f14)
- Bug 1174248 - Workaround unico theme engine resizer bug on GTK3. r=karlt (ca55b44a4a)
- Bug 1173907 - Don't use gtk_render_activity for drawing progress chunks on GTK versions above 3.13.7. r=karlt (57e97d2d55)
- Bug 1218008 - Fix progress bar rendering on the Ambiance GTK3 theme. r=karlt (5dcfff5ab5)
- Bug 1171011 - Use only document padding for MOZ_GTK_ENTRY in XUL. r=karlt (3d164c219e)
- Bug 1187385 - Use GTK style padding for entry widgets. r=karlt (f44fffb148)
- Bug 1176929 - Disable Ctrl-K in GtkEntry unless custom key bindings are (46c9b03899)
- Bug 1145916 - [e10s] Defer starting a GTK Print Job during printer enumeration until the next tick. r=karlt (5b8d5d40c2)
- Bug 1120490 - Take the 'GetRotateForLandscape' gfxASurface configuration into account when creating printing surfaces. r=jwatt (b259f7006a)
- Bug 1228216 - Event::GetScreenCoords incorrectly converts the coords to a CSSPoint when the widget is null r=tnikkel (9e58f9f640)
- Bug 1226872 - Stop keeping a copy of the resolution in the root scrollframe. r=roc (c168509f4d)
- Bug 1224015 - Part 1: nsLayoutUtils functions do not account for nsPresShell resolution r=tnikkel (c6a1cca145)
- Bug 1224015 - Part 2: Have nsDisplayResolution items adjust event coordinates for hit testing and dispatching to content r=tnikkel (09fad089ce)
- Bug 1224015 - Part 3: ifdef changes to C++APZ so that they only apply to single process APZ. r=tnikkel (340b30205d)
- Bug 1228597 - Remove the MOZ_SINGLE_PROCESS_APZ define. r=tn (6733cf7b4b)
- Bug 1177406, don't rely on owner to be set only on main thread, r=khuey (a31d3ee5fe)
- Bug 1221822 - Finish the WebGL texture refactor. r=kamidphish,mattwoodrow,bz (9df451d68f)
- bug 1214953 set GDK_VERSION_MIN_REQUIRED/MAX_ALLOWED to specify the GTK/GDK API and suppress irrelevant deprecated warnings r=glandium (e9161dc6f4)
- Bug 1160666 - Allow per-product b2g branding. r=fabrice (8d95dfa1ea)
- Fix due to backport (900ffc0c50)
- Bug 1224490 - Don't set NSS_LIBS in the non-native NSS case. r=mshal We never use the variable in that case. Bug 1224490 - Kill LIBXUL_DIST. r=mshal (bf53e3e930)
- Bug 1175555 - Build flag to exclude hyphenation dictionaries from Android builds. r=nalexander (eb94fae1dd)
- Bug 1141534 - fix mulet nightly mozconfigs; r=bhearsum We don't want uploadsymbols or update-packaging for nightly mulet builds, but these were being set by the underlying browser mozconfigs. (1a9e4cb294)
- Bug 1137000 - Enable SDK building on nightlies; r=glandium (c28e4f9cae)
- Bug 1181040 - Include mozconfig.cache after mozconfig.common.override. r=mshal (610364f8ae)
- bug 1182519 - Put mozconfigs for cross-mac builds in tree. r=mshal (0c3768b90a)
- bug 935237 - add genisoimage+dmg binaries to tooltool manifest, use them in cross-mac mozconfig. r=gps (d0252cb263)
- bug 1203689 - Use tooltool gcc as host compiler for cross-mac builds. r=dustin (2597df48cd)
- Bug 1204068 - Update the clang used for OSX cross compiles to the latest that we use on Linux64; r=ted (0323202013)
- Bug 1204763 - Enable cross compiling the clang plugin for OS X on Linux; r=glandium (2813897f8b)
- Bug 1208787 - Enable static analysis checks by default on OSX cross builds; r=ted (9aa48ddb43)
- bug 543111 - enable Breakpad for cross-mac builds. r=glandium (1a2be876d8)
- bug 1183129 - Remove a dead iOS-related conditional from configure.in. r=glandium (1e81eba818)
- bug 1190522 - Rewrite pkg-dmg as a Python script. r=gps (796e8ef8e1)
- bug 935237 - use libdmg-hfsplus to create DMG files during packaging on Linux. r=gps (d676c7eb8f)
- bug 543111 - add support for alternate dsymutil paths to configure, add to cross-mozconfig. r=glandium (401ec2b3a4)
2023-02-16 10:13:42 +08:00

242 lines
6.9 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* 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/. */
#include "nsXPCOM.h"
#include "nsXULAppAPI.h"
#include "nsAutoPtr.h"
// FIXME/cjones testing
#if !defined(OS_WIN)
#include <unistd.h>
#endif
#ifdef XP_WIN
#include <windows.h>
// we want a wmain entry point
// but we don't want its DLL load protection, because we'll handle it here
#define XRE_DONT_PROTECT_DLL_LOAD
#include "nsWindowsWMain.cpp"
#include "nsSetDllDirectory.h"
#endif
#include "GMPLoader.h"
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
#include "mozilla/sandboxTarget.h"
#include "mozilla/sandboxing/loggingCallbacks.h"
#include "sandbox/win/src/sandbox_factory.h"
#endif
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
#include "mozilla/Sandbox.h"
#include "mozilla/SandboxInfo.h"
#endif
#ifdef MOZ_WIDGET_GONK
# include <sys/time.h>
# include <sys/resource.h>
# include <binder/ProcessState.h>
# ifdef LOGE_IF
# undef LOGE_IF
# endif
# include <android/log.h>
# define LOGE_IF(cond, ...) \
( (CONDITION(cond)) \
? ((void)__android_log_print(ANDROID_LOG_ERROR, \
"Gecko:MozillaRntimeMain", __VA_ARGS__)) \
: (void)0 )
# ifdef MOZ_CONTENT_SANDBOX
# include "mozilla/Sandbox.h"
# endif
#endif // MOZ_WIDGET_GONK
#ifdef MOZ_NUWA_PROCESS
#include <binder/ProcessState.h>
#include "ipc/Nuwa.h"
#endif
#ifdef MOZ_WIDGET_GONK
static void
InitializeBinder(void *aDummy) {
// Change thread priority to 0 only during calling ProcessState::self().
// The priority is registered to binder driver and used for default Binder
// Thread's priority.
// To change the process's priority to small value need's root permission.
int curPrio = getpriority(PRIO_PROCESS, 0);
int err = setpriority(PRIO_PROCESS, 0, 0);
MOZ_ASSERT(!err);
LOGE_IF(err, "setpriority failed. Current process needs root permission.");
android::ProcessState::self()->startThreadPool();
setpriority(PRIO_PROCESS, 0, curPrio);
}
#endif
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
static bool gIsSandboxEnabled = false;
class WinSandboxStarter : public mozilla::gmp::SandboxStarter {
public:
virtual bool Start(const char *aLibPath) override {
if (gIsSandboxEnabled) {
sandbox::SandboxFactory::GetTargetServices()->LowerToken();
}
return true;
}
};
#endif
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
class LinuxSandboxStarter : public mozilla::gmp::SandboxStarter {
LinuxSandboxStarter() { }
public:
static SandboxStarter* Make() {
if (mozilla::SandboxInfo::Get().CanSandboxMedia()) {
return new LinuxSandboxStarter();
} else {
// Sandboxing isn't possible, but the parent has already
// checked that this plugin doesn't require it. (Bug 1074561)
return nullptr;
}
}
virtual bool Start(const char *aLibPath) override {
mozilla::SetMediaPluginSandbox(aLibPath);
return true;
}
};
#endif
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
class MacSandboxStarter : public mozilla::gmp::SandboxStarter {
public:
virtual bool Start(const char *aLibPath) override {
std::string err;
bool rv = mozilla::StartMacSandbox(mInfo, err);
if (!rv) {
fprintf(stderr, "sandbox_init() failed! Error \"%s\"\n", err.c_str());
}
return rv;
}
virtual void SetSandboxInfo(MacSandboxInfo* aSandboxInfo) override {
mInfo = *aSandboxInfo;
}
private:
MacSandboxInfo mInfo;
};
#endif
mozilla::gmp::SandboxStarter*
MakeSandboxStarter()
{
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
return new WinSandboxStarter();
#elif defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
return LinuxSandboxStarter::Make();
#elif defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
return new MacSandboxStarter();
#else
return nullptr;
#endif
}
int
content_process_main(int argc, char* argv[])
{
// Check for the absolute minimum number of args we need to move
// forward here. We expect the last arg to be the child process type.
if (argc < 1) {
return 3;
}
bool isNuwa = false;
for (int i = 1; i < argc; i++) {
isNuwa |= strcmp(argv[i], "-nuwa") == 0;
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
gIsSandboxEnabled |= strcmp(argv[i], "-sandbox") == 0;
#endif
}
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
if (gIsSandboxEnabled) {
sandbox::TargetServices* target_service =
sandbox::SandboxFactory::GetTargetServices();
if (!target_service) {
return 1;
}
sandbox::ResultCode result = target_service->Init();
if (result != sandbox::SBOX_ALL_OK) {
return 2;
}
mozilla::SandboxTarget::Instance()->SetTargetServices(target_service);
mozilla::sandboxing::PrepareForLogging();
}
#endif
XRE_SetProcessType(argv[--argc]);
#ifdef MOZ_NUWA_PROCESS
if (isNuwa) {
PrepareNuwaProcess();
}
#endif
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
// This has to happen while we're still single-threaded, and on
// B2G that means before the Android Binder library is
// initialized. Additional special handling is needed for Nuwa:
// the Nuwa process itself needs to be unsandboxed, and the same
// single-threadedness condition applies to its children; see also
// AfterNuwaFork().
mozilla::SandboxEarlyInit(XRE_GetProcessType(), isNuwa);
#endif
#ifdef MOZ_WIDGET_GONK
// This creates a ThreadPool for binder ipc. A ThreadPool is necessary to
// receive binder calls, though not necessary to send binder calls.
// ProcessState::Self() also needs to be called once on the main thread to
// register the main thread with the binder driver.
#ifdef MOZ_NUWA_PROCESS
if (!isNuwa) {
InitializeBinder(nullptr);
} else {
NuwaAddFinalConstructor(&InitializeBinder, nullptr);
}
#else
InitializeBinder(nullptr);
#endif
#endif
#ifdef XP_WIN
// For plugins, this is done in PluginProcessChild::Init, as we need to
// avoid it for unsupported plugins. See PluginProcessChild::Init for
// the details.
if (XRE_GetProcessType() != GeckoProcessType_Plugin) {
mozilla::SanitizeEnvironmentVariables();
SetDllDirectory(L"");
}
#endif
nsAutoPtr<mozilla::gmp::GMPLoader> loader;
#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK)
// On desktop, the GMPLoader lives in plugin-container, so that its
// code can be covered by an EME/GMP vendor's voucher.
nsAutoPtr<mozilla::gmp::SandboxStarter> starter(MakeSandboxStarter());
if (XRE_GetProcessType() == GeckoProcessType_GMPlugin) {
loader = mozilla::gmp::CreateGMPLoader(starter);
}
#endif
nsresult rv = XRE_InitChildProcess(argc, argv, loader);
NS_ENSURE_SUCCESS(rv, 1);
return 0;
}