diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-10 22:48:19 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-10 22:48:19 +0000 |
commit | 04b2603b66c95649cc072a43a7d002cac8b92409 (patch) | |
tree | 8a9b218b313f2f99d02f8967f29186917029c340 | |
parent | ec39287014cd3cc5469ae88f027a7b1f082599aa (diff) | |
download | chromium_src-04b2603b66c95649cc072a43a7d002cac8b92409.zip chromium_src-04b2603b66c95649cc072a43a7d002cac8b92409.tar.gz chromium_src-04b2603b66c95649cc072a43a7d002cac8b92409.tar.bz2 |
Use a struct instead of a union for SandboxInterfaceInfo
BUG=72496
TEST=see bug
Review URL: http://codereview.chromium.org/6483006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74514 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/client_util.h | 4 | ||||
-rw-r--r-- | chrome/common/sandbox_init_wrapper_win.cc | 21 | ||||
-rw-r--r-- | sandbox/src/sandbox_types.h | 4 |
3 files changed, 19 insertions, 10 deletions
diff --git a/chrome/app/client_util.h b/chrome/app/client_util.h index b34eaf6..ae7f2a7 100644 --- a/chrome/app/client_util.h +++ b/chrome/app/client_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-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. @@ -13,7 +13,7 @@ #include <string> namespace sandbox { - union SandboxInterfaceInfo; + struct SandboxInterfaceInfo; } // Implements the common aspects of loading chrome.dll for both chrome and diff --git a/chrome/common/sandbox_init_wrapper_win.cc b/chrome/common/sandbox_init_wrapper_win.cc index 5d4399a..a18632e 100644 --- a/chrome/common/sandbox_init_wrapper_win.cc +++ b/chrome/common/sandbox_init_wrapper_win.cc @@ -1,10 +1,12 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 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 "chrome/common/sandbox_init_wrapper.h" #include "base/command_line.h" +#include "base/logging.h" + #include "chrome/common/chrome_switches.h" void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) { @@ -12,6 +14,9 @@ void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) { broker_services_ = info->broker_services; target_services_ = info->target_services; } + // Both interface pointers cannot be non-zero. A process can either + // be a target or a broker but not both. + DCHECK(!(target_services_ && broker_services_)); } bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, @@ -22,12 +27,16 @@ bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, (process_type == switches::kExtensionProcess) || (process_type == switches::kWorkerProcess) || (process_type == switches::kNaClLoaderProcess) || - (process_type == switches::kUtilityProcess) || - (process_type == switches::kPluginProcess && - command_line.HasSwitch(switches::kSafePlugins))) { + (process_type == switches::kUtilityProcess)) { + // The above five process types must be sandboxed unless --no-sandbox + // is present in the command line. if (!target_services_) return false; - target_services_->Init(); + } else { + // Other process types might or might not be sandboxed. + // TODO(cpu): clean this mess. + if (!target_services_) + return true; } - return true; + return (sandbox::SBOX_ALL_OK == target_services_->Init()); } diff --git a/sandbox/src/sandbox_types.h b/sandbox/src/sandbox_types.h index 3346085..ee9da54 100644 --- a/sandbox/src/sandbox_types.h +++ b/sandbox/src/sandbox_types.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-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. @@ -54,7 +54,7 @@ class TargetServices; class BrokerServices; // Contains the pointer to a target or broker service. -union SandboxInterfaceInfo { +struct SandboxInterfaceInfo { TargetServices* target_services; BrokerServices* broker_services; }; |