summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-14 22:05:53 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-14 22:05:53 +0000
commit4f99782b60caec061f62def550f0ef16a2d42bd0 (patch)
tree1643090b5459bfe416c1f3619d295340390808ca
parent7c98f742868a5c44ae5586949da15b52918e3f60 (diff)
downloadchromium_src-4f99782b60caec061f62def550f0ef16a2d42bd0.zip
chromium_src-4f99782b60caec061f62def550f0ef16a2d42bd0.tar.gz
chromium_src-4f99782b60caec061f62def550f0ef16a2d42bd0.tar.bz2
WorkerMain contains code to initialize the sandbox on OS X which is disabled due to a typo. The sandbox is in fact enabled in ContentMainImpl::Initialize.
This CL removes the redundant code and adds a CHECK() to ensure that the sandbox has already been initialized. Bug=None Review URL: https://chromiumcodereview.appspot.com/12820006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188209 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/common/sandbox_mac.h2
-rw-r--r--content/common/sandbox_mac.mm9
-rw-r--r--content/worker/worker_main.cc11
3 files changed, 18 insertions, 4 deletions
diff --git a/content/common/sandbox_mac.h b/content/common/sandbox_mac.h
index ea23ce5..b0d88df 100644
--- a/content/common/sandbox_mac.h
+++ b/content/common/sandbox_mac.h
@@ -77,6 +77,8 @@ class CONTENT_EXPORT Sandbox {
static bool EnableSandbox(int sandbox_type,
const base::FilePath& allowed_dir);
+ // Returns true if the sandbox has been enabled for the current process.
+ static bool SandboxIsCurrentlyActive();
// Exposed for testing purposes, used by an accessory function of our tests
// so we can't use FRIEND_TEST.
diff --git a/content/common/sandbox_mac.mm b/content/common/sandbox_mac.mm
index ef229f7..6ae12c2 100644
--- a/content/common/sandbox_mac.mm
+++ b/content/common/sandbox_mac.mm
@@ -39,6 +39,9 @@ extern "C" {
namespace content {
namespace {
+// Is the sandbox currently active.
+bool gSandboxIsActive = false;
+
struct SandboxTypeToResourceIDMapping {
SandboxType sandbox_type;
int sandbox_profile_resource_id;
@@ -573,10 +576,16 @@ bool Sandbox::EnableSandbox(int sandbox_type,
<< " "
<< error_buff;
sandbox_free_error(error_buff);
+ gSandboxIsActive = success;
return success;
}
// static
+bool Sandbox::SandboxIsCurrentlyActive() {
+ return gSandboxIsActive;
+}
+
+// static
base::FilePath Sandbox::GetCanonicalSandboxPath(const base::FilePath& path) {
int fd = HANDLE_EINTR(open(path.value().c_str(), O_RDONLY));
if (fd < 0) {
diff --git a/content/worker/worker_main.cc b/content/worker/worker_main.cc
index f6b2b20..192cc57 100644
--- a/content/worker/worker_main.cc
+++ b/content/worker/worker_main.cc
@@ -18,6 +18,10 @@
#include "sandbox/win/src/sandbox.h"
#endif
+#if defined(OS_MACOSX)
+#include "content/common/sandbox_mac.h"
+#endif
+
namespace content {
// Mainline routine for running as the worker process.
@@ -43,10 +47,9 @@ int WorkerMain(const MainFunctionParams& parameters) {
::GetUserDefaultLCID();
target_services->LowerToken();
-#elif defined(OS_MAC)
- // On OS X, if the sandbox fails to initialize, something has gone terribly
- // wrong and we should die.
- CHECK(InitializeSandbox());
+#elif defined(OS_MACOSX)
+ // Sandbox should already be activated at this point.
+ CHECK(Sandbox::SandboxIsCurrentlyActive());
#elif defined(OS_LINUX)
// On Linux, the sandbox must be initialized early, before any thread is
// created.