/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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"UtilityProcessChild.h"
#ifdefined(XP_LINUX) && defined(MOZ_SANDBOX) # include "mozilla/Sandbox.h" # include "mozilla/SandboxProfilerObserver.h" #endif
#ifdefined(XP_OPENBSD) && defined(MOZ_SANDBOX) # include "mozilla/SandboxSettings.h" #endif
#ifdefined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS) # include "mozilla/SandboxTestingChild.h" #endif
#include"mozilla/Telemetry.h"
#ifdefined(XP_WIN) # include "mozilla/WinDllServices.h" # include "mozilla/dom/WindowsUtilsChild.h" # include "mozilla/widget/filedialog/WinFileDialogChild.h" #endif
// Initialize the thread manager before starting IPC. Otherwise, messages // may be posted to the main thread and we won't be able to process them. if (NS_WARN_IF(NS_FAILED(nsThreadManager::get().Init()))) { returnfalse;
}
// Now it's safe to start IPC. if (NS_WARN_IF(!aEndpoint.Bind(this))) { returnfalse;
}
// This must be checked before any IPDL message, which may hit sentinel // errors due to parent and content processes having different // versions.
MessageChannel* channel = GetIPCChannel(); if (channel && !channel->SendBuildIDsMatchMessage(aParentBuildID.get())) { // We need to quit this process if the buildID doesn't match the parent's. // This can occur when an update occurred in the background.
ipc::ProcessChild::QuickExit();
}
if (NS_FAILED(NS_InitMinimalXPCOM())) { returnfalse;
}
mSandbox = (SandboxingKind)aSandboxingKind;
// At the moment, only ORB uses JSContext in the // Utility Process and ORB uses GENERIC_UTILITY if (mSandbox == SandboxingKind::GENERIC_UTILITY) { if (!JS_FrontendOnlyInit()) { returnfalse;
} #ifdefined(__OpenBSD__) && defined(MOZ_SANDBOX) // Bug 1823458: delay pledge initialization, otherwise // JS_FrontendOnlyInit triggers sysctl(KERN_PROC_ID) which isnt // permitted with the current pledge.utility config
StartOpenBSDSandbox(GeckoProcessType_Utility, mSandbox); #endif
}
mozilla::ipc::IPCResult UtilityProcessChild::RecvInit( const Maybe<FileDescriptor>& aBrokerFd, constbool& aCanRecordReleaseTelemetry, constbool& aIsReadyForBackgroundProcessing) { // Do this now (before closing WindowServer on macOS) to avoid risking // blocking in GetCurrentProcess() called on that platform
mozilla::ipc::SetThisProcessName("Utility Process");
#ifdefined(MOZ_SANDBOX) # ifdefined(XP_MACOSX) // Close all current connections to the WindowServer. This ensures that the // Activity Monitor will not label the content process as "Not responding" // because it's not running a native event loop. See bug 1384336.
CGSShutdownServerConnections();
# elif defined(XP_LINUX) int fd = -1; if (aBrokerFd.isSome()) {
fd = aBrokerFd.value().ClonePlatformHandle().release();
}
// Wait until all RemoteDecoderManagerParent have closed. // It is still possible some may not have clean up yet, and we might hit // timeout. Our xpcom-shutdown listener should take care of cleaning the // reference of our singleton. // // FIXME: Should move from using AsyncBlockers to proper // nsIAsyncShutdownService once it is not JS, see bug 1760855
mShutdownBlockers.WaitUntilClear(timeout)->Then(
GetCurrentSerialEventTarget(), __func__, [&]() { # ifdef XP_WIN
{
RefPtr<DllServices> dllSvc(DllServices::Get());
dllSvc->DisableFull();
} # endif // defined(XP_WIN)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.