Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(981)

Side by Side Diff: chrome/common/sandbox_init_wrapper_mac.cc

Issue 1559012: 1. Create a new sandbox type which allows access to Unix sockets in the Mac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | chrome/common/sandbox_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/sandbox_init_wrapper.h" 5 #include "chrome/common/sandbox_init_wrapper.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/common/chrome_switches.h" 8 #include "chrome/common/chrome_switches.h"
9 #include "chrome/common/sandbox_mac.h" 9 #include "chrome/common/sandbox_mac.h"
10 10
11 bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, 11 bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line,
12 const std::string& process_type) { 12 const std::string& process_type) {
13 if (command_line.HasSwitch(switches::kNoSandbox)) 13 if (command_line.HasSwitch(switches::kNoSandbox))
14 return true; 14 return true;
15 15
16 sandbox::SandboxProcessType sandbox_process_type; 16 sandbox::SandboxProcessType sandbox_process_type;
17 FilePath allowed_dir; // Empty by default. 17 FilePath allowed_dir; // Empty by default.
18 18
19 if (process_type.empty()) { 19 if (process_type.empty()) {
20 // Browser process isn't sandboxed. 20 // Browser process isn't sandboxed.
21 return true; 21 return true;
22 } else if (process_type == switches::kRendererProcess) { 22 } else if (process_type == switches::kRendererProcess) {
23 // Renderer process sandbox. 23 // Renderer process sandbox. If --internal_nacl is present then use the
24 sandbox_process_type = sandbox::SANDBOX_TYPE_RENDERER; 24 // version of the renderer sandbox which allows Native Client to use Unix
25 // sockets.
26 // TODO(msneck): Remove the use of Unix sockets from Native Client and
27 // then get rid of the SANDBOX_TYPE_NACL_PLUGIN enum.
28 // See http://code.google.com/p/nativeclient/issues/detail?id=344
29 if (command_line.HasSwitch(switches::kInternalNaCl)) {
30 sandbox_process_type = sandbox::SANDBOX_TYPE_NACL_PLUGIN;
31 } else {
32 sandbox_process_type = sandbox::SANDBOX_TYPE_RENDERER;
33 }
25 } else if (process_type == switches::kExtensionProcess) { 34 } else if (process_type == switches::kExtensionProcess) {
26 // Extension processes are just renderers [they use RenderMain()] with a 35 // Extension processes are just renderers [they use RenderMain()] with a
27 // different set of command line flags. 36 // different set of command line flags.
28 // If we ever get here it means something has changed in regards 37 // If we ever get here it means something has changed in regards
29 // to the extension process mechanics and we should probably reexamine 38 // to the extension process mechanics and we should probably reexamine
30 // how we sandbox extension processes since they are no longer identical 39 // how we sandbox extension processes since they are no longer identical
31 // to renderers. 40 // to renderers.
32 NOTREACHED(); 41 NOTREACHED();
33 return true; 42 return true;
34 } else if (process_type == switches::kUtilityProcess) { 43 } else if (process_type == switches::kUtilityProcess) {
35 // Utility process sandbox. 44 // Utility process sandbox.
36 sandbox_process_type = sandbox::SANDBOX_TYPE_UTILITY; 45 sandbox_process_type = sandbox::SANDBOX_TYPE_UTILITY;
37 allowed_dir = FilePath::FromWStringHack( 46 allowed_dir = FilePath::FromWStringHack(
38 command_line.GetSwitchValue(switches::kUtilityProcessAllowedDir)); 47 command_line.GetSwitchValue(switches::kUtilityProcessAllowedDir));
39 } else if (process_type == switches::kWorkerProcess) { 48 } else if (process_type == switches::kWorkerProcess) {
40 // Worker process sandbox. 49 // Worker process sandbox.
41 sandbox_process_type = sandbox::SANDBOX_TYPE_WORKER; 50 sandbox_process_type = sandbox::SANDBOX_TYPE_WORKER;
42 } else if ((process_type == switches::kNaClLoaderProcess) || 51 } else if (process_type == switches::kNaClLoaderProcess) {
43 (process_type == switches::kPluginProcess) || 52 // Native Client sel_ldr (user untrusted code) sandbox.
53 sandbox_process_type = sandbox::SANDBOX_TYPE_NACL_LOADER;
54 } else if ((process_type == switches::kPluginProcess) ||
44 (process_type == switches::kProfileImportProcess) || 55 (process_type == switches::kProfileImportProcess) ||
45 (process_type == switches::kGpuProcess)) { 56 (process_type == switches::kGpuProcess)) {
46 return true; 57 return true;
47 } else { 58 } else {
48 // Failsafe: If you hit an unreached here, is your new process type in need 59 // Failsafe: If you hit an unreached here, is your new process type in need
49 // of sandboxing? 60 // of sandboxing?
50 NOTREACHED(); 61 NOTREACHED();
51 return true; 62 return true;
52 } 63 }
53 64
54 // Warm up APIs before turning on the sandbox. 65 // Warm up APIs before turning on the sandbox.
55 sandbox::SandboxWarmup(); 66 sandbox::SandboxWarmup();
56 67
57 // Actually sandbox the process. 68 // Actually sandbox the process.
58 return sandbox::EnableSandbox(sandbox_process_type, allowed_dir); 69 return sandbox::EnableSandbox(sandbox_process_type, allowed_dir);
59 } 70 }
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | chrome/common/sandbox_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698