| 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/browser/zygote_host_linux.h" | 5 #include "content/browser/zygote_host_linux.h" |
| 6 | 6 |
| 7 #include <sys/socket.h> | 7 #include <sys/socket.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 free(saved_envvar); | 51 free(saved_envvar); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 ZygoteHost::ZygoteHost() | 55 ZygoteHost::ZygoteHost() |
| 56 : control_fd_(-1), | 56 : control_fd_(-1), |
| 57 pid_(-1), | 57 pid_(-1), |
| 58 init_(false), | 58 init_(false), |
| 59 using_suid_sandbox_(false), | 59 using_suid_sandbox_(false), |
| 60 have_read_sandbox_status_word_(false), | 60 have_read_sandbox_status_word_(false), |
| 61 sandbox_status_(0) { | 61 sandbox_status_(0) {} |
| 62 } | |
| 63 | 62 |
| 64 ZygoteHost::~ZygoteHost() { | 63 ZygoteHost::~ZygoteHost() { |
| 65 if (init_) | 64 if (init_) |
| 66 close(control_fd_); | 65 close(control_fd_); |
| 67 } | 66 } |
| 68 | 67 |
| 69 // static | 68 // static |
| 70 ZygoteHost* ZygoteHost::GetInstance() { | 69 ZygoteHost* ZygoteHost::GetInstance() { |
| 71 return Singleton<ZygoteHost>::get(); | 70 return Singleton<ZygoteHost>::get(); |
| 72 } | 71 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 103 // Should this list be obtained from browser_render_process_host.cc? | 102 // Should this list be obtained from browser_render_process_host.cc? |
| 104 static const char* kForwardSwitches[] = { | 103 static const char* kForwardSwitches[] = { |
| 105 switches::kAllowSandboxDebugging, | 104 switches::kAllowSandboxDebugging, |
| 106 switches::kLoggingLevel, | 105 switches::kLoggingLevel, |
| 107 switches::kEnableLogging, // Support, e.g., --enable-logging=stderr. | 106 switches::kEnableLogging, // Support, e.g., --enable-logging=stderr. |
| 108 switches::kV, | 107 switches::kV, |
| 109 switches::kVModule, | 108 switches::kVModule, |
| 110 switches::kRegisterPepperPlugins, | 109 switches::kRegisterPepperPlugins, |
| 111 switches::kDisableSeccompSandbox, | 110 switches::kDisableSeccompSandbox, |
| 112 switches::kEnableSeccompSandbox, | 111 switches::kEnableSeccompSandbox, |
| 112 switches::kNaClLinuxHelper, |
| 113 }; | 113 }; |
| 114 cmd_line.CopySwitchesFrom(browser_command_line, kForwardSwitches, | 114 cmd_line.CopySwitchesFrom(browser_command_line, kForwardSwitches, |
| 115 arraysize(kForwardSwitches)); | 115 arraysize(kForwardSwitches)); |
| 116 | 116 |
| 117 content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( | 117 content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
| 118 &cmd_line, -1); | 118 &cmd_line, -1); |
| 119 | 119 |
| 120 sandbox_binary_ = sandbox_cmd.c_str(); | 120 sandbox_binary_ = sandbox_cmd.c_str(); |
| 121 struct stat st; | 121 struct stat st; |
| 122 | 122 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 sizeof(sandbox_status_))) != | 214 sizeof(sandbox_status_))) != |
| 215 sizeof(sandbox_status_)) { | 215 sizeof(sandbox_status_)) { |
| 216 return -1; | 216 return -1; |
| 217 } | 217 } |
| 218 have_read_sandbox_status_word_ = true; | 218 have_read_sandbox_status_word_ = true; |
| 219 } | 219 } |
| 220 | 220 |
| 221 return HANDLE_EINTR(read(control_fd_, buf, buf_len)); | 221 return HANDLE_EINTR(read(control_fd_, buf, buf_len)); |
| 222 } | 222 } |
| 223 | 223 |
| 224 pid_t ZygoteHost::ForkRenderer( | 224 pid_t ZygoteHost::ForkRequest( |
| 225 const std::vector<std::string>& argv, | 225 const std::vector<std::string>& argv, |
| 226 const base::GlobalDescriptors::Mapping& mapping) { | 226 const base::GlobalDescriptors::Mapping& mapping, |
| 227 const std::string& process_type) { |
| 227 DCHECK(init_); | 228 DCHECK(init_); |
| 228 Pickle pickle; | 229 Pickle pickle; |
| 229 | 230 |
| 230 pickle.WriteInt(kCmdFork); | 231 pickle.WriteInt(kCmdFork); |
| 232 pickle.WriteString(process_type); |
| 231 pickle.WriteInt(argv.size()); | 233 pickle.WriteInt(argv.size()); |
| 232 for (std::vector<std::string>::const_iterator | 234 for (std::vector<std::string>::const_iterator |
| 233 i = argv.begin(); i != argv.end(); ++i) | 235 i = argv.begin(); i != argv.end(); ++i) |
| 234 pickle.WriteString(*i); | 236 pickle.WriteString(*i); |
| 235 | 237 |
| 236 pickle.WriteInt(mapping.size()); | 238 pickle.WriteInt(mapping.size()); |
| 237 | 239 |
| 238 std::vector<int> fds; | 240 std::vector<int> fds; |
| 239 for (base::GlobalDescriptors::Mapping::const_iterator | 241 for (base::GlobalDescriptors::Mapping::const_iterator |
| 240 i = mapping.begin(); i != mapping.end(); ++i) { | 242 i = mapping.begin(); i != mapping.end(); ++i) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { | 364 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { |
| 363 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; | 365 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; |
| 364 return base::TERMINATION_STATUS_NORMAL_TERMINATION; | 366 return base::TERMINATION_STATUS_NORMAL_TERMINATION; |
| 365 } | 367 } |
| 366 | 368 |
| 367 if (exit_code) | 369 if (exit_code) |
| 368 *exit_code = tmp_exit_code; | 370 *exit_code = tmp_exit_code; |
| 369 | 371 |
| 370 return static_cast<base::TerminationStatus>(status); | 372 return static_cast<base::TerminationStatus>(status); |
| 371 } | 373 } |
| OLD | NEW |