| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/zygote_host_linux.h" | 5 #include "chrome/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> |
| 11 | 11 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 78 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 79 if (browser_command_line.HasSwitch(switches::kZygoteCmdPrefix)) { | 79 if (browser_command_line.HasSwitch(switches::kZygoteCmdPrefix)) { |
| 80 const std::wstring prefix = | 80 const std::wstring prefix = |
| 81 browser_command_line.GetSwitchValue(switches::kZygoteCmdPrefix); | 81 browser_command_line.GetSwitchValue(switches::kZygoteCmdPrefix); |
| 82 cmd_line.PrependWrapper(prefix); | 82 cmd_line.PrependWrapper(prefix); |
| 83 } | 83 } |
| 84 // Append any switches from the browser process that need to be forwarded on | 84 // Append any switches from the browser process that need to be forwarded on |
| 85 // to the zygote/renderers. | 85 // to the zygote/renderers. |
| 86 // Should this list be obtained from browser_render_process_host.cc? | 86 // Should this list be obtained from browser_render_process_host.cc? |
| 87 if (browser_command_line.HasSwitch(switches::kAllowSandboxDebugging)) { | 87 static const char* kForwardSwitches[] = { |
| 88 cmd_line.AppendSwitch(switches::kAllowSandboxDebugging); | 88 switches::kAllowSandboxDebugging, |
| 89 switches::kLoggingLevel, |
| 90 switches::kEnableLogging, // Support, e.g., --enable-logging=stderr. |
| 91 switches::kUserDataDir, // Make logs go to the right file. |
| 92 // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox. |
| 93 switches::kRegisterPepperPlugins, |
| 94 #if defined(USE_SECCOMP_SANDBOX) |
| 95 switches::kDisableSeccompSandbox, |
| 96 #else |
| 97 switches::kEnableSeccompSandbox, |
| 98 #endif |
| 99 NULL |
| 100 }; |
| 101 for (const char** sw = kForwardSwitches; *sw; sw++) { |
| 102 if (browser_command_line.HasSwitch(*sw)) { |
| 103 // Always append with value for those switches which need it; it does no |
| 104 // harm for those which don't. |
| 105 cmd_line.AppendSwitchWithValue(*sw, |
| 106 browser_command_line.GetSwitchValueASCII(*sw)); |
| 107 } |
| 89 } | 108 } |
| 90 if (browser_command_line.HasSwitch(switches::kLoggingLevel)) { | |
| 91 cmd_line.AppendSwitchWithValue(switches::kLoggingLevel, | |
| 92 browser_command_line.GetSwitchValueASCII( | |
| 93 switches::kLoggingLevel)); | |
| 94 } | |
| 95 if (browser_command_line.HasSwitch(switches::kEnableLogging)) { | |
| 96 // Append with value to support --enable-logging=stderr. | |
| 97 cmd_line.AppendSwitchWithValue(switches::kEnableLogging, | |
| 98 browser_command_line.GetSwitchValueASCII( | |
| 99 switches::kEnableLogging)); | |
| 100 } | |
| 101 if (browser_command_line.HasSwitch(switches::kUserDataDir)) { | |
| 102 // Append with value so logs go to the right file. | |
| 103 cmd_line.AppendSwitchWithValue(switches::kUserDataDir, | |
| 104 browser_command_line.GetSwitchValueASCII( | |
| 105 switches::kUserDataDir)); | |
| 106 } | |
| 107 #if defined(USE_SECCOMP_SANDBOX) | |
| 108 if (browser_command_line.HasSwitch(switches::kDisableSeccompSandbox)) | |
| 109 cmd_line.AppendSwitch(switches::kDisableSeccompSandbox); | |
| 110 #else | |
| 111 if (browser_command_line.HasSwitch(switches::kEnableSeccompSandbox)) | |
| 112 cmd_line.AppendSwitch(switches::kEnableSeccompSandbox); | |
| 113 #endif | |
| 114 | 109 |
| 115 sandbox_binary_ = sandbox_cmd.c_str(); | 110 sandbox_binary_ = sandbox_cmd.c_str(); |
| 116 struct stat st; | 111 struct stat st; |
| 117 | 112 |
| 118 if (!sandbox_cmd.empty() && stat(sandbox_binary_.c_str(), &st) == 0) { | 113 if (!sandbox_cmd.empty() && stat(sandbox_binary_.c_str(), &st) == 0) { |
| 119 if (access(sandbox_binary_.c_str(), X_OK) == 0 && | 114 if (access(sandbox_binary_.c_str(), X_OK) == 0 && |
| 120 (st.st_uid == 0) && | 115 (st.st_uid == 0) && |
| 121 (st.st_mode & S_ISUID) && | 116 (st.st_mode & S_ISUID) && |
| 122 (st.st_mode & S_IXOTH)) { | 117 (st.st_mode & S_IXOTH)) { |
| 123 using_suid_sandbox_ = true; | 118 using_suid_sandbox_ = true; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 !read_pickle.ReadBool(&iter, &tmp_child_exited)) { | 339 !read_pickle.ReadBool(&iter, &tmp_child_exited)) { |
| 345 LOG(WARNING) << "Error parsing DidProcessCrash response from zygote."; | 340 LOG(WARNING) << "Error parsing DidProcessCrash response from zygote."; |
| 346 return false; | 341 return false; |
| 347 } | 342 } |
| 348 | 343 |
| 349 if (child_exited) | 344 if (child_exited) |
| 350 *child_exited = tmp_child_exited; | 345 *child_exited = tmp_child_exited; |
| 351 | 346 |
| 352 return did_crash; | 347 return did_crash; |
| 353 } | 348 } |
| OLD | NEW |