Chromium Code Reviews| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 switches::kEnableSeccompSandbox, | 111 switches::kEnableSeccompSandbox, |
| 112 switches::kNaClLinuxHelper, | 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; | |
| 122 | 121 |
| 123 if (!sandbox_cmd.empty() && stat(sandbox_binary_.c_str(), &st) == 0) { | 122 if (!sandbox_cmd.empty()) { |
| 124 if (access(sandbox_binary_.c_str(), X_OK) == 0 && | 123 struct stat st; |
| 124 if (stat(sandbox_binary_.c_str(), &st) == 0 && | |
| 125 access(sandbox_binary_.c_str(), X_OK) == 0 && | |
| 125 (st.st_uid == 0) && | 126 (st.st_uid == 0) && |
| 126 (st.st_mode & S_ISUID) && | 127 (st.st_mode & S_ISUID) && |
| 127 (st.st_mode & S_IXOTH)) { | 128 (st.st_mode & S_IXOTH)) { |
| 128 using_suid_sandbox_ = true; | 129 using_suid_sandbox_ = true; |
| 129 cmd_line.PrependWrapper(sandbox_binary_); | 130 cmd_line.PrependWrapper(sandbox_binary_); |
| 130 | 131 |
| 131 SaveSUIDUnsafeEnvironmentVariables(); | 132 SaveSUIDUnsafeEnvironmentVariables(); |
| 132 } else { | 133 } else { |
| 133 LOG(FATAL) << "The SUID sandbox helper binary was found, but is not " | 134 LOG(FATAL) << "The SUID sandbox helper binary was found, but is not " |
|
Lei Zhang
2011/08/09 09:09:45
This message isn't quite right with this CL. If |s
| |
| 134 "configured correctly. Rather than run without sandboxing " | 135 "configured correctly. Rather than run without sandboxing " |
| 135 "I'm aborting now. You need to make sure that " | 136 "I'm aborting now. You need to make sure that " |
| 136 << sandbox_binary_ << " is mode 4755 and owned by root."; | 137 << sandbox_binary_ << " is mode 4755 and owned by root."; |
| 137 } | 138 } |
| 139 } else { | |
| 140 LOG(WARNING) << "Running without the SUID sandbox! See " | |
| 141 "http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment " | |
| 142 "for more information on developing with the sandbox on."; | |
| 138 } | 143 } |
| 139 | 144 |
| 140 // Start up the sandbox host process and get the file descriptor for the | 145 // Start up the sandbox host process and get the file descriptor for the |
| 141 // renderers to talk to it. | 146 // renderers to talk to it. |
| 142 const int sfd = RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); | 147 const int sfd = RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); |
| 143 fds_to_map.push_back(std::make_pair(sfd, 5)); | 148 fds_to_map.push_back(std::make_pair(sfd, 5)); |
| 144 | 149 |
| 145 int dummy_fd = -1; | 150 int dummy_fd = -1; |
| 146 if (using_suid_sandbox_) { | 151 if (using_suid_sandbox_) { |
| 147 dummy_fd = socket(PF_UNIX, SOCK_DGRAM, 0); | 152 dummy_fd = socket(PF_UNIX, SOCK_DGRAM, 0); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { | 370 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { |
| 366 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; | 371 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; |
| 367 return base::TERMINATION_STATUS_NORMAL_TERMINATION; | 372 return base::TERMINATION_STATUS_NORMAL_TERMINATION; |
| 368 } | 373 } |
| 369 | 374 |
| 370 if (exit_code) | 375 if (exit_code) |
| 371 *exit_code = tmp_exit_code; | 376 *exit_code = tmp_exit_code; |
| 372 | 377 |
| 373 return static_cast<base::TerminationStatus>(status); | 378 return static_cast<base::TerminationStatus>(status); |
| 374 } | 379 } |
| OLD | NEW |