Add sandbox support (issue #524).

- The sandbox is now enabled by default on all platforms. Use the CefSettings.no_sandbox option or the "no-sandbox" command-line flag to disable sandbox support.
- Windows: See cef_sandbox_win.h for requirements to enable sandbox support.
- Windows: If Visual Studio isn't installed in the standard location set the CEF_VCVARS environment variable before running make_distrib.py or automate.py (see msvs_env.bat).
- Linux: For binary distributions a new chrome-sandbox executable with SUID permissions must be placed next to the CEF executable. See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for details on setting up the development environment when building CEF from source code.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1518 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2013-11-15 18:47:02 +00:00
parent 395f443215
commit f5bc72b234
24 changed files with 485 additions and 52 deletions

View File

@@ -109,14 +109,14 @@
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT int cef_execute_process(const struct _cef_main_args_t* args,
struct _cef_app_t* application) {
struct _cef_app_t* application, void* windows_sandbox_info) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: args; type: struct_byref_const
DCHECK(args);
if (!args)
return 0;
// Unverified params: application
// Unverified params: application, windows_sandbox_info
// Translate param: args; type: struct_byref_const
CefMainArgs argsObj;
@@ -126,14 +126,16 @@ CEF_EXPORT int cef_execute_process(const struct _cef_main_args_t* args,
// Execute
int _retval = CefExecuteProcess(
argsObj,
CefAppCToCpp::Wrap(application));
CefAppCToCpp::Wrap(application),
windows_sandbox_info);
// Return type: simple
return _retval;
}
CEF_EXPORT int cef_initialize(const struct _cef_main_args_t* args,
const struct _cef_settings_t* settings, struct _cef_app_t* application) {
const struct _cef_settings_t* settings, struct _cef_app_t* application,
void* windows_sandbox_info) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: args; type: struct_byref_const
@@ -144,7 +146,7 @@ CEF_EXPORT int cef_initialize(const struct _cef_main_args_t* args,
DCHECK(settings);
if (!settings)
return 0;
// Unverified params: application
// Unverified params: application, windows_sandbox_info
// Translate param: args; type: struct_byref_const
CefMainArgs argsObj;
@@ -159,7 +161,8 @@ CEF_EXPORT int cef_initialize(const struct _cef_main_args_t* args,
bool _retval = CefInitialize(
argsObj,
settingsObj,
CefAppCToCpp::Wrap(application));
CefAppCToCpp::Wrap(application),
windows_sandbox_info);
// Return type: bool
return _retval;

View File

@@ -0,0 +1,36 @@
// Copyright 2013 The Chromium Embedded Framework Authors. Portions Copyright
// 2011 the Chromium Authors. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
#include "include/cef_sandbox_win.h"
#include "sandbox/win/src/process_mitigations.h"
#include "sandbox/win/src/sandbox_factory.h"
namespace {
// From content/app/startup_helper_win.cc:
void InitializeSandboxInfo(sandbox::SandboxInterfaceInfo* info) {
info->broker_services = sandbox::SandboxFactory::GetBrokerServices();
if (!info->broker_services) {
info->target_services = sandbox::SandboxFactory::GetTargetServices();
} else {
// Ensure the proper mitigations are enforced for the browser process.
sandbox::ApplyProcessMitigationsToCurrentProcess(
sandbox::MITIGATION_DEP |
sandbox::MITIGATION_DEP_NO_ATL_THUNK);
}
}
} // namespace
void* cef_sandbox_info_create() {
sandbox::SandboxInterfaceInfo* info = new sandbox::SandboxInterfaceInfo();
memset(info, 0, sizeof(sandbox::SandboxInterfaceInfo));
InitializeSandboxInfo(info);
return info;
}
void cef_sandbox_info_destroy(void* sandbox_info) {
delete static_cast<sandbox::SandboxInterfaceInfo*>(sandbox_info);
}

View File

@@ -113,7 +113,7 @@
// GLOBAL METHODS - Body may be edited by hand.
CEF_GLOBAL int CefExecuteProcess(const CefMainArgs& args,
CefRefPtr<CefApp> application) {
CefRefPtr<CefApp> application, void* windows_sandbox_info) {
const char* api_hash = cef_api_hash(0);
if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) {
// The libcef API hash does not match the current header API hash.
@@ -123,19 +123,21 @@ CEF_GLOBAL int CefExecuteProcess(const CefMainArgs& args,
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: application
// Unverified params: application, windows_sandbox_info
// Execute
int _retval = cef_execute_process(
&args,
CefAppCppToC::Wrap(application));
CefAppCppToC::Wrap(application),
windows_sandbox_info);
// Return type: simple
return _retval;
}
CEF_GLOBAL bool CefInitialize(const CefMainArgs& args,
const CefSettings& settings, CefRefPtr<CefApp> application) {
const CefSettings& settings, CefRefPtr<CefApp> application,
void* windows_sandbox_info) {
const char* api_hash = cef_api_hash(0);
if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) {
// The libcef API hash does not match the current header API hash.
@@ -145,13 +147,14 @@ CEF_GLOBAL bool CefInitialize(const CefMainArgs& args,
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: application
// Unverified params: application, windows_sandbox_info
// Execute
int _retval = cef_initialize(
&args,
&settings,
CefAppCppToC::Wrap(application));
CefAppCppToC::Wrap(application),
windows_sandbox_info);
// Return type: bool
return _retval?true:false;