| 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 "content/browser/zygote_host/zygote_host_impl_linux.h" | 5 #include "content/browser/zygote_host/zygote_host_impl_linux.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "base/strings/string_number_conversions.h" | 31 #include "base/strings/string_number_conversions.h" |
| 32 #include "base/strings/string_util.h" | 32 #include "base/strings/string_util.h" |
| 33 #include "base/strings/utf_string_conversions.h" | 33 #include "base/strings/utf_string_conversions.h" |
| 34 #include "base/time/time.h" | 34 #include "base/time/time.h" |
| 35 #include "content/browser/renderer_host/render_sandbox_host_linux.h" | 35 #include "content/browser/renderer_host/render_sandbox_host_linux.h" |
| 36 #include "content/common/child_process_sandbox_support_impl_linux.h" | 36 #include "content/common/child_process_sandbox_support_impl_linux.h" |
| 37 #include "content/common/zygote_commands_linux.h" | 37 #include "content/common/zygote_commands_linux.h" |
| 38 #include "content/public/browser/content_browser_client.h" | 38 #include "content/public/browser/content_browser_client.h" |
| 39 #include "content/public/common/content_switches.h" | 39 #include "content/public/common/content_switches.h" |
| 40 #include "content/public/common/result_codes.h" | 40 #include "content/public/common/result_codes.h" |
| 41 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" | 41 #include "sandbox/linux/suid/client/setuid_sandbox_host.h" |
| 42 #include "sandbox/linux/suid/common/sandbox.h" | 42 #include "sandbox/linux/suid/common/sandbox.h" |
| 43 #include "ui/base/ui_base_switches.h" | 43 #include "ui/base/ui_base_switches.h" |
| 44 #include "ui/gfx/switches.h" | 44 #include "ui/gfx/switches.h" |
| 45 | 45 |
| 46 #if defined(USE_TCMALLOC) | 46 #if defined(USE_TCMALLOC) |
| 47 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" | 47 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 namespace content { | 50 namespace content { |
| 51 | 51 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // A non empty sandbox_cmd means we want a SUID sandbox. | 144 // A non empty sandbox_cmd means we want a SUID sandbox. |
| 145 using_suid_sandbox_ = !sandbox_cmd.empty(); | 145 using_suid_sandbox_ = !sandbox_cmd.empty(); |
| 146 | 146 |
| 147 // Start up the sandbox host process and get the file descriptor for the | 147 // Start up the sandbox host process and get the file descriptor for the |
| 148 // renderers to talk to it. | 148 // renderers to talk to it. |
| 149 const int sfd = RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); | 149 const int sfd = RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); |
| 150 fds_to_map.push_back(std::make_pair(sfd, GetSandboxFD())); | 150 fds_to_map.push_back(std::make_pair(sfd, GetSandboxFD())); |
| 151 | 151 |
| 152 base::ScopedFD dummy_fd; | 152 base::ScopedFD dummy_fd; |
| 153 if (using_suid_sandbox_) { | 153 if (using_suid_sandbox_) { |
| 154 scoped_ptr<sandbox::SetuidSandboxClient> | 154 scoped_ptr<sandbox::SetuidSandboxHost> |
| 155 sandbox_client(sandbox::SetuidSandboxClient::Create()); | 155 sandbox_host(sandbox::SetuidSandboxHost::Create()); |
| 156 sandbox_client->PrependWrapper(&cmd_line); | 156 sandbox_host->PrependWrapper(&cmd_line); |
| 157 sandbox_client->SetupLaunchOptions(&options, &fds_to_map, &dummy_fd); | 157 sandbox_host->SetupLaunchOptions(&options, &fds_to_map, &dummy_fd); |
| 158 sandbox_client->SetupLaunchEnvironment(); | 158 sandbox_host->SetupLaunchEnvironment(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 options.fds_to_remap = &fds_to_map; | 161 options.fds_to_remap = &fds_to_map; |
| 162 base::Process process = base::LaunchProcess(cmd_line.argv(), options); | 162 base::Process process = base::LaunchProcess(cmd_line.argv(), options); |
| 163 CHECK(process.IsValid()) << "Failed to launch zygote process"; | 163 CHECK(process.IsValid()) << "Failed to launch zygote process"; |
| 164 dummy_fd.reset(); | 164 dummy_fd.reset(); |
| 165 | 165 |
| 166 if (using_suid_sandbox_) { | 166 if (using_suid_sandbox_) { |
| 167 // The SUID sandbox will execute the zygote in a new PID namespace, and | 167 // The SUID sandbox will execute the zygote in a new PID namespace, and |
| 168 // the main zygote process will then fork from there. Watch now our | 168 // the main zygote process will then fork from there. Watch now our |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 return pid_; | 553 return pid_; |
| 554 } | 554 } |
| 555 | 555 |
| 556 int ZygoteHostImpl::GetSandboxStatus() const { | 556 int ZygoteHostImpl::GetSandboxStatus() const { |
| 557 if (have_read_sandbox_status_word_) | 557 if (have_read_sandbox_status_word_) |
| 558 return sandbox_status_; | 558 return sandbox_status_; |
| 559 return 0; | 559 return 0; |
| 560 } | 560 } |
| 561 | 561 |
| 562 } // namespace content | 562 } // namespace content |
| OLD | NEW |