OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/common/sandbox_init_mac.h" | 5 #include "content/common/sandbox_init_mac.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/common/sandbox_mac.h" | 10 #include "content/common/sandbox_mac.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 bool GetSandboxTypeFromCommandLine(int* sandbox_type, | 28 bool GetSandboxTypeFromCommandLine(int* sandbox_type, |
29 base::FilePath* allowed_dir) { | 29 base::FilePath* allowed_dir) { |
30 DCHECK(sandbox_type); | 30 DCHECK(sandbox_type); |
31 DCHECK(allowed_dir); | 31 DCHECK(allowed_dir); |
32 | 32 |
33 *sandbox_type = -1; | 33 *sandbox_type = -1; |
34 *allowed_dir = base::FilePath(); // Empty by default. | 34 *allowed_dir = base::FilePath(); // Empty by default. |
35 | 35 |
36 const base::CommandLine& command_line = | 36 const base::CommandLine& command_line = |
37 *base::CommandLine::ForCurrentProcess(); | 37 *base::CommandLine::ForCurrentProcess(); |
| 38 std::string process_type = |
| 39 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 40 |
38 if (command_line.HasSwitch(switches::kNoSandbox)) | 41 if (command_line.HasSwitch(switches::kNoSandbox)) |
39 return false; | 42 return false; |
40 if (command_line.HasSwitch(switches::kV2SandboxedEnabled)) | 43 if (command_line.HasSwitch(switches::kV2SandboxedEnabled)) { |
41 CHECK(sandbox::Seatbelt::IsSandboxed()); | 44 CHECK(sandbox::Seatbelt::IsSandboxed()); |
| 45 if (process_type == switches::kRendererProcess) { |
| 46 Sandbox::LaunchServicesNotAvailable(); |
| 47 } |
| 48 // Do not enable the sandbox if V2 is already enabled. |
| 49 return false; |
| 50 } |
42 | 51 |
43 std::string process_type = | |
44 command_line.GetSwitchValueASCII(switches::kProcessType); | |
45 if (process_type.empty()) { | 52 if (process_type.empty()) { |
46 // Browser process isn't sandboxed. | 53 // Browser process isn't sandboxed. |
47 return false; | 54 return false; |
48 } else if (process_type == switches::kRendererProcess) { | 55 } else if (process_type == switches::kRendererProcess) { |
49 *sandbox_type = SANDBOX_TYPE_RENDERER; | 56 *sandbox_type = SANDBOX_TYPE_RENDERER; |
50 } else if (process_type == switches::kUtilityProcess) { | 57 } else if (process_type == switches::kUtilityProcess) { |
51 // Utility process sandbox. | 58 // Utility process sandbox. |
52 *sandbox_type = SANDBOX_TYPE_UTILITY; | 59 *sandbox_type = SANDBOX_TYPE_UTILITY; |
53 *allowed_dir = | 60 *allowed_dir = |
54 command_line.GetSwitchValuePath(switches::kUtilityProcessAllowedDir); | 61 command_line.GetSwitchValuePath(switches::kUtilityProcessAllowedDir); |
(...skipping 16 matching lines...) Expand all Loading... |
71 | 78 |
72 bool InitializeSandbox() { | 79 bool InitializeSandbox() { |
73 int sandbox_type = 0; | 80 int sandbox_type = 0; |
74 base::FilePath allowed_dir; | 81 base::FilePath allowed_dir; |
75 if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir)) | 82 if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir)) |
76 return true; | 83 return true; |
77 return InitializeSandbox(sandbox_type, allowed_dir); | 84 return InitializeSandbox(sandbox_type, allowed_dir); |
78 } | 85 } |
79 | 86 |
80 } // namespace content | 87 } // namespace content |
OLD | NEW |