mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
bootstrap: Depend on //sandbox directly (see #3935)
This allows us to more accurately duplicate the chrome.exe sandbox initialization logic.
This commit is contained in:
6
BUILD.gn
6
BUILD.gn
@@ -1276,15 +1276,19 @@ if (is_win) {
|
||||
"//chrome/app/delay_load_failure_hook_win.h",
|
||||
"//chrome/common/win/delay_load_failure_support.cc",
|
||||
"//chrome/common/win/delay_load_failure_support.h",
|
||||
"//content/app/sandbox_helper_win.cc",
|
||||
"//content/public/app/sandbox_helper_win.h",
|
||||
]
|
||||
|
||||
bootstrap_deps = [
|
||||
":cef_sandbox",
|
||||
":make_config_header",
|
||||
":make_version_header",
|
||||
"//base",
|
||||
"//build/win:default_exe_manifest",
|
||||
"//chrome/install_static:secondary_module",
|
||||
"//chrome/chrome_elf",
|
||||
"//sandbox",
|
||||
"//sandbox/policy",
|
||||
"//third_party/crashpad/crashpad/handler",
|
||||
]
|
||||
|
||||
|
@@ -26,6 +26,10 @@
|
||||
#include "chrome/app/delay_load_failure_hook_win.h"
|
||||
#include "chrome/chrome_elf/chrome_elf_main.h"
|
||||
#include "chrome/install_static/initialize_from_primary_module.h"
|
||||
#include "content/public/app/sandbox_helper_win.h"
|
||||
#include "sandbox/policy/mojom/sandbox.mojom.h"
|
||||
#include "sandbox/policy/sandbox_type.h"
|
||||
#include "sandbox/win/src/sandbox.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -193,11 +197,12 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
return crashpad_runner::RunAsCrashpadHandler(command_line);
|
||||
}
|
||||
|
||||
// True if this is a sandboxed sub-process. Uses similar logic to
|
||||
// Sandbox::IsProcessSandboxed.
|
||||
// IsUnsandboxedSandboxType() can't be used here because its result can be
|
||||
// gated behind a feature flag, which are not yet initialized.
|
||||
// Match the logic in MainDllLoader::Launch.
|
||||
const bool is_sandboxed =
|
||||
is_subprocess &&
|
||||
base::GetCurrentProcessIntegrityLevel() < base::MEDIUM_INTEGRITY;
|
||||
sandbox::policy::SandboxTypeFromCommandLine(command_line) !=
|
||||
sandbox::mojom::Sandbox::kNoSandbox;
|
||||
|
||||
std::wstring dll_name;
|
||||
base::FilePath exe_path;
|
||||
@@ -326,16 +331,23 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
// Load the client DLL normally.
|
||||
if (HMODULE hModule = ::LoadLibrary(dll_name.c_str())) {
|
||||
if (auto* pFunc = (kProcType)::GetProcAddress(hModule, kProcName)) {
|
||||
// Manage the life span of the sandbox information object. This is
|
||||
// necessary for sandbox support on Windows. See cef_sandbox_win.h for
|
||||
// complete details.
|
||||
CefScopedSandboxInfo scoped_sandbox;
|
||||
void* sandbox_info = scoped_sandbox.sandbox_info();
|
||||
// Initialize the sandbox services.
|
||||
// Match the logic in MainDllLoader::Launch.
|
||||
sandbox::SandboxInterfaceInfo sandbox_info = {nullptr};
|
||||
if (!is_subprocess || is_sandboxed) {
|
||||
// For child processes that are running as --no-sandbox, don't
|
||||
// initialize the sandbox info, otherwise they'll be treated as brokers
|
||||
// (as if they were the browser).
|
||||
content::InitializeSandboxInfo(
|
||||
&sandbox_info, IsExtensionPointDisableSet()
|
||||
? sandbox::MITIGATION_EXTENSION_POINT_DISABLE
|
||||
: 0);
|
||||
}
|
||||
|
||||
#if defined(CEF_BUILD_BOOTSTRAP_CONSOLE)
|
||||
result_code = pFunc(argc, argv, sandbox_info);
|
||||
result_code = pFunc(argc, argv, &sandbox_info);
|
||||
#else
|
||||
result_code = pFunc(hInstance, lpCmdLine, nCmdShow, sandbox_info);
|
||||
result_code = pFunc(hInstance, lpCmdLine, nCmdShow, &sandbox_info);
|
||||
#endif
|
||||
} else {
|
||||
#if DCHECK_IS_ON()
|
||||
|
Reference in New Issue
Block a user