| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_communication_linux.h" | 5 #include "content/browser/zygote_host/zygote_communication_linux.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 if (ReadSandboxStatus() == -1) { | 99 if (ReadSandboxStatus() == -1) { |
| 100 return -1; | 100 return -1; |
| 101 } | 101 } |
| 102 have_read_sandbox_status_word_ = true; | 102 have_read_sandbox_status_word_ = true; |
| 103 UMA_HISTOGRAM_SPARSE_SLOWLY("Linux.SandboxStatus", sandbox_status_); | 103 UMA_HISTOGRAM_SPARSE_SLOWLY("Linux.SandboxStatus", sandbox_status_); |
| 104 } | 104 } |
| 105 | 105 |
| 106 return HANDLE_EINTR(read(control_fd_, buf, buf_len)); | 106 return HANDLE_EINTR(read(control_fd_, buf, buf_len)); |
| 107 } | 107 } |
| 108 | 108 |
| 109 pid_t ZygoteCommunication::ForkRequest(const std::vector<std::string>& argv, | 109 pid_t ZygoteCommunication::ForkRequest( |
| 110 scoped_ptr<FileDescriptorInfo> mapping, | 110 const std::vector<std::string>& argv, |
| 111 const std::string& process_type) { | 111 std::unique_ptr<FileDescriptorInfo> mapping, |
| 112 const std::string& process_type) { |
| 112 DCHECK(init_); | 113 DCHECK(init_); |
| 113 | 114 |
| 114 base::Pickle pickle; | 115 base::Pickle pickle; |
| 115 int raw_socks[2]; | 116 int raw_socks[2]; |
| 116 PCHECK(0 == socketpair(AF_UNIX, SOCK_SEQPACKET, 0, raw_socks)); | 117 PCHECK(0 == socketpair(AF_UNIX, SOCK_SEQPACKET, 0, raw_socks)); |
| 117 base::ScopedFD my_sock(raw_socks[0]); | 118 base::ScopedFD my_sock(raw_socks[0]); |
| 118 base::ScopedFD peer_sock(raw_socks[1]); | 119 base::ScopedFD peer_sock(raw_socks[1]); |
| 119 CHECK(base::UnixDomainSocket::EnableReceiveProcessId(my_sock.get())); | 120 CHECK(base::UnixDomainSocket::EnableReceiveProcessId(my_sock.get())); |
| 120 | 121 |
| 121 pickle.WriteInt(kZygoteCommandFork); | 122 pickle.WriteInt(kZygoteCommandFork); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 !ZygoteHostImpl::GetInstance()->SandboxCommand().empty() && | 303 !ZygoteHostImpl::GetInstance()->SandboxCommand().empty() && |
| 303 !using_namespace_sandbox; | 304 !using_namespace_sandbox; |
| 304 | 305 |
| 305 // Start up the sandbox host process and get the file descriptor for the | 306 // Start up the sandbox host process and get the file descriptor for the |
| 306 // renderers to talk to it. | 307 // renderers to talk to it. |
| 307 const int sfd = RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); | 308 const int sfd = RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); |
| 308 fds_to_map.push_back(std::make_pair(sfd, GetSandboxFD())); | 309 fds_to_map.push_back(std::make_pair(sfd, GetSandboxFD())); |
| 309 | 310 |
| 310 base::ScopedFD dummy_fd; | 311 base::ScopedFD dummy_fd; |
| 311 if (using_suid_sandbox) { | 312 if (using_suid_sandbox) { |
| 312 scoped_ptr<sandbox::SetuidSandboxHost> sandbox_host( | 313 std::unique_ptr<sandbox::SetuidSandboxHost> sandbox_host( |
| 313 sandbox::SetuidSandboxHost::Create()); | 314 sandbox::SetuidSandboxHost::Create()); |
| 314 sandbox_host->PrependWrapper(&cmd_line); | 315 sandbox_host->PrependWrapper(&cmd_line); |
| 315 sandbox_host->SetupLaunchOptions(&options, &fds_to_map, &dummy_fd); | 316 sandbox_host->SetupLaunchOptions(&options, &fds_to_map, &dummy_fd); |
| 316 sandbox_host->SetupLaunchEnvironment(); | 317 sandbox_host->SetupLaunchEnvironment(); |
| 317 } | 318 } |
| 318 | 319 |
| 319 options.fds_to_remap = &fds_to_map; | 320 options.fds_to_remap = &fds_to_map; |
| 320 base::Process process = | 321 base::Process process = |
| 321 using_namespace_sandbox | 322 using_namespace_sandbox |
| 322 ? sandbox::NamespaceSandbox::LaunchProcess(cmd_line, options) | 323 ? sandbox::NamespaceSandbox::LaunchProcess(cmd_line, options) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 } | 429 } |
| 429 if (ReadSandboxStatus() == -1) { | 430 if (ReadSandboxStatus() == -1) { |
| 430 return 0; | 431 return 0; |
| 431 } | 432 } |
| 432 have_read_sandbox_status_word_ = true; | 433 have_read_sandbox_status_word_ = true; |
| 433 UMA_HISTOGRAM_SPARSE_SLOWLY("Linux.SandboxStatus", sandbox_status_); | 434 UMA_HISTOGRAM_SPARSE_SLOWLY("Linux.SandboxStatus", sandbox_status_); |
| 434 return sandbox_status_; | 435 return sandbox_status_; |
| 435 } | 436 } |
| 436 | 437 |
| 437 } // namespace content | 438 } // namespace content |
| OLD | NEW |