Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: content/browser/zygote_host/zygote_host_impl_linux.cc

Issue 258543006: Change UnixDomainSocket::RecvMsg to return ScopedVector<base::ScopedFD> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and resolve conflicts with r266735 Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/sandbox_ipc_linux.cc ('k') | content/zygote/zygote_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <unistd.h> 11 #include <unistd.h>
12 12
13 #include "base/base_switches.h" 13 #include "base/base_switches.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/environment.h" 15 #include "base/environment.h"
16 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/files/file_enumerator.h" 17 #include "base/files/file_enumerator.h"
18 #include "base/files/scoped_file.h" 18 #include "base/files/scoped_file.h"
19 #include "base/linux_util.h" 19 #include "base/linux_util.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/memory/linked_ptr.h" 21 #include "base/memory/linked_ptr.h"
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "base/memory/scoped_vector.h"
23 #include "base/metrics/histogram.h" 24 #include "base/metrics/histogram.h"
24 #include "base/path_service.h" 25 #include "base/path_service.h"
25 #include "base/posix/eintr_wrapper.h" 26 #include "base/posix/eintr_wrapper.h"
26 #include "base/posix/unix_domain_socket_linux.h" 27 #include "base/posix/unix_domain_socket_linux.h"
27 #include "base/process/launch.h" 28 #include "base/process/launch.h"
28 #include "base/process/memory.h" 29 #include "base/process/memory.h"
29 #include "base/process/process_handle.h" 30 #include "base/process/process_handle.h"
30 #include "base/strings/string_number_conversions.h" 31 #include "base/strings/string_number_conversions.h"
31 #include "base/strings/string_util.h" 32 #include "base/strings/string_util.h"
32 #include "base/strings/utf_string_conversions.h" 33 #include "base/strings/utf_string_conversions.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 base::LaunchProcess(cmd_line.argv(), options, &process); 170 base::LaunchProcess(cmd_line.argv(), options, &process);
170 CHECK(process != -1) << "Failed to launch zygote process"; 171 CHECK(process != -1) << "Failed to launch zygote process";
171 dummy_fd.reset(); 172 dummy_fd.reset();
172 173
173 if (using_suid_sandbox_) { 174 if (using_suid_sandbox_) {
174 // In the SUID sandbox, the real zygote is forked from the sandbox 175 // In the SUID sandbox, the real zygote is forked from the sandbox
175 // and will be executing in another PID namespace. 176 // and will be executing in another PID namespace.
176 // Wait for the zygote to tell us it's running, and receive its PID, 177 // Wait for the zygote to tell us it's running, and receive its PID,
177 // which the kernel will translate to our PID namespace. 178 // which the kernel will translate to our PID namespace.
178 // The sending code is in content/browser/zygote_main_linux.cc. 179 // The sending code is in content/browser/zygote_main_linux.cc.
179 std::vector<int> fds_vec; 180 ScopedVector<base::ScopedFD> fds_vec;
180 const size_t kExpectedLength = sizeof(kZygoteHelloMessage); 181 const size_t kExpectedLength = sizeof(kZygoteHelloMessage);
181 char buf[kExpectedLength]; 182 char buf[kExpectedLength];
182 const ssize_t len = UnixDomainSocket::RecvMsgWithPid( 183 const ssize_t len = UnixDomainSocket::RecvMsgWithPid(
183 fds[0], buf, sizeof(buf), &fds_vec, &pid_); 184 fds[0], buf, sizeof(buf), &fds_vec, &pid_);
184 CHECK_EQ(kExpectedLength, static_cast<size_t>(len)) 185 CHECK_EQ(kExpectedLength, static_cast<size_t>(len))
185 << "Incorrect zygote magic length"; 186 << "Incorrect zygote magic length";
186 CHECK_EQ(0, memcmp(buf, kZygoteHelloMessage, kExpectedLength)) 187 CHECK_EQ(0, memcmp(buf, kZygoteHelloMessage, kExpectedLength))
187 << "Incorrect zygote hello"; 188 << "Incorrect zygote hello";
188 CHECK_EQ(0U, fds_vec.size()) 189 CHECK_EQ(0U, fds_vec.size())
189 << "Zygote hello should not include file descriptors"; 190 << "Zygote hello should not include file descriptors";
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 return RenderSandboxHostLinux::GetInstance()->pid(); 528 return RenderSandboxHostLinux::GetInstance()->pid();
528 } 529 }
529 530
530 int ZygoteHostImpl::GetSandboxStatus() const { 531 int ZygoteHostImpl::GetSandboxStatus() const {
531 if (have_read_sandbox_status_word_) 532 if (have_read_sandbox_status_word_)
532 return sandbox_status_; 533 return sandbox_status_;
533 return 0; 534 return 0;
534 } 535 }
535 536
536 } // namespace content 537 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/sandbox_ipc_linux.cc ('k') | content/zygote/zygote_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698