OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/nacl/zygote/nacl_fork_delegate_linux.h" | 5 #include "components/nacl/zygote/nacl_fork_delegate_linux.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <sys/resource.h> | 9 #include <sys/resource.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 nonsfi_mode_ ? nacl::FILE_NACL_HELPER_NONSFI : nacl::FILE_NACL_HELPER, | 192 nonsfi_mode_ ? nacl::FILE_NACL_HELPER_NONSFI : nacl::FILE_NACL_HELPER, |
193 &helper_exe)) { | 193 &helper_exe)) { |
194 status_ = kNaClHelperMissing; | 194 status_ = kNaClHelperMissing; |
195 } else if (use_nacl_bootstrap && | 195 } else if (use_nacl_bootstrap && |
196 !PathService::Get(nacl::FILE_NACL_HELPER_BOOTSTRAP, | 196 !PathService::Get(nacl::FILE_NACL_HELPER_BOOTSTRAP, |
197 &helper_bootstrap_exe)) { | 197 &helper_bootstrap_exe)) { |
198 status_ = kNaClHelperBootstrapMissing; | 198 status_ = kNaClHelperBootstrapMissing; |
199 } else if (RunningOnValgrind()) { | 199 } else if (RunningOnValgrind()) { |
200 status_ = kNaClHelperValgrind; | 200 status_ = kNaClHelperValgrind; |
201 } else { | 201 } else { |
202 CommandLine::StringVector argv_to_launch; | 202 base::CommandLine::StringVector argv_to_launch; |
203 { | 203 { |
204 CommandLine cmd_line(CommandLine::NO_PROGRAM); | 204 base::CommandLine cmd_line(base::CommandLine::NO_PROGRAM); |
205 if (use_nacl_bootstrap) | 205 if (use_nacl_bootstrap) |
206 cmd_line.SetProgram(helper_bootstrap_exe); | 206 cmd_line.SetProgram(helper_bootstrap_exe); |
207 else | 207 else |
208 cmd_line.SetProgram(helper_exe); | 208 cmd_line.SetProgram(helper_exe); |
209 | 209 |
210 // Append any switches that need to be forwarded to the NaCl helper. | 210 // Append any switches that need to be forwarded to the NaCl helper. |
211 static const char* kForwardSwitches[] = { | 211 static const char* kForwardSwitches[] = { |
212 switches::kDisableSeccompFilterSandbox, | 212 switches::kDisableSeccompFilterSandbox, |
213 switches::kEnableNaClDebug, | 213 switches::kEnableNaClDebug, |
214 switches::kNaClDangerousNoSandboxNonSfi, | 214 switches::kNaClDangerousNoSandboxNonSfi, |
215 switches::kNoSandbox, | 215 switches::kNoSandbox, |
216 }; | 216 }; |
217 const CommandLine& current_cmd_line = *CommandLine::ForCurrentProcess(); | 217 const base::CommandLine& current_cmd_line = |
| 218 *base::CommandLine::ForCurrentProcess(); |
218 cmd_line.CopySwitchesFrom(current_cmd_line, kForwardSwitches, | 219 cmd_line.CopySwitchesFrom(current_cmd_line, kForwardSwitches, |
219 arraysize(kForwardSwitches)); | 220 arraysize(kForwardSwitches)); |
220 | 221 |
221 // The command line needs to be tightly controlled to use | 222 // The command line needs to be tightly controlled to use |
222 // |helper_bootstrap_exe|. So from now on, argv_to_launch should be | 223 // |helper_bootstrap_exe|. So from now on, argv_to_launch should be |
223 // modified directly. | 224 // modified directly. |
224 argv_to_launch = cmd_line.argv(); | 225 argv_to_launch = cmd_line.argv(); |
225 } | 226 } |
226 if (use_nacl_bootstrap) { | 227 if (use_nacl_bootstrap) { |
227 // Arguments to the bootstrap helper which need to be at the start | 228 // Arguments to the bootstrap helper which need to be at the start |
228 // of the command line, right after the helper's path. | 229 // of the command line, right after the helper's path. |
229 CommandLine::StringVector bootstrap_prepend; | 230 base::CommandLine::StringVector bootstrap_prepend; |
230 bootstrap_prepend.push_back(helper_exe.value()); | 231 bootstrap_prepend.push_back(helper_exe.value()); |
231 bootstrap_prepend.push_back(kNaClHelperReservedAtZero); | 232 bootstrap_prepend.push_back(kNaClHelperReservedAtZero); |
232 bootstrap_prepend.push_back(kNaClHelperRDebug); | 233 bootstrap_prepend.push_back(kNaClHelperRDebug); |
233 argv_to_launch.insert(argv_to_launch.begin() + 1, | 234 argv_to_launch.insert(argv_to_launch.begin() + 1, |
234 bootstrap_prepend.begin(), | 235 bootstrap_prepend.begin(), |
235 bootstrap_prepend.end()); | 236 bootstrap_prepend.end()); |
236 } | 237 } |
237 | 238 |
238 base::LaunchOptions options; | 239 base::LaunchOptions options; |
239 | 240 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 pass_through_vars.push_back(kNaClVerbosity); | 437 pass_through_vars.push_back(kNaClVerbosity); |
437 pass_through_vars.push_back(sandbox::kSandboxEnvironmentApiRequest); | 438 pass_through_vars.push_back(sandbox::kSandboxEnvironmentApiRequest); |
438 for (size_t i = 0; i < pass_through_vars.size(); ++i) { | 439 for (size_t i = 0; i < pass_through_vars.size(); ++i) { |
439 std::string temp; | 440 std::string temp; |
440 if (env->GetVar(pass_through_vars[i].c_str(), &temp)) | 441 if (env->GetVar(pass_through_vars[i].c_str(), &temp)) |
441 options->environ[pass_through_vars[i]] = temp; | 442 options->environ[pass_through_vars[i]] = temp; |
442 } | 443 } |
443 } | 444 } |
444 | 445 |
445 } // namespace nacl | 446 } // namespace nacl |
OLD | NEW |