1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "SocketProcessImpl.h"
8 #include "base/command_line.h"
9 #include "base/shared_memory.h"
10 #include "base/string_util.h"
11 #include "mozilla/BackgroundHangMonitor.h"
12 #include "mozilla/Preferences.h"
13 #include "mozilla/GeckoArgs.h"
14 #include "mozilla/ipc/ProcessUtils.h"
15 #include "mozilla/ipc/IOThreadChild.h"
17 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
18 # include "mozilla/sandboxTarget.h"
19 #elif defined(__OpenBSD__) && defined(MOZ_SANDBOX)
20 # include "mozilla/SandboxSettings.h"
25 # include <unistd.h> // For sleep().
28 using mozilla::ipc::IOThreadChild
;
33 LazyLogModule
gSocketProcessLog("socketprocess");
35 SocketProcessImpl::~SocketProcessImpl() = default;
37 bool SocketProcessImpl::Init(int aArgc
, char* aArgv
[]) {
39 if (PR_GetEnv("MOZ_DEBUG_SOCKET_PROCESS")) {
40 printf_stderr("\n\nSOCKETPROCESSnSOCKETPROCESS\n debug me @ %d\n\n",
41 base::GetCurrentProcId());
45 #if defined(MOZ_SANDBOX) && defined(XP_WIN)
46 LoadLibraryW(L
"nss3.dll");
47 LoadLibraryW(L
"softokn3.dll");
48 LoadLibraryW(L
"freebl3.dll");
49 LoadLibraryW(L
"ipcclientcerts.dll");
50 LoadLibraryW(L
"winmm.dll");
51 mozilla::SandboxTarget::Instance()->StartSandbox();
52 #elif defined(__OpenBSD__) && defined(MOZ_SANDBOX)
53 PR_LoadLibrary("libnss3.so");
54 PR_LoadLibrary("libsoftokn3.so");
55 PR_LoadLibrary("libfreebl3.so");
56 PR_LoadLibrary("libipcclientcerts.so");
57 StartOpenBSDSandbox(GeckoProcessType_Socket
);
60 Maybe
<const char*> parentBuildID
=
61 geckoargs::sParentBuildID
.Get(aArgc
, aArgv
);
62 if (parentBuildID
.isNothing()) {
66 if (!ProcessChild::InitPrefs(aArgc
, aArgv
)) {
70 return mSocketProcessChild
->Init(TakeInitialEndpoint(), *parentBuildID
);
73 void SocketProcessImpl::CleanUp() { mSocketProcessChild
->CleanUp(); }
76 } // namespace mozilla