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

Side by Side Diff: content/zygote/zygote_linux.cc

Issue 2025763002: Use ChannelMojo in Pepper and NaCl processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-utility-channel-mojo
Patch Set: iujbhirtughfbnjrthiubj Created 4 years, 6 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
« no previous file with comments | « content/public/common/zygote_fork_delegate_linux.h ('k') | mojo/edk/system/BUILD.gn » ('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/zygote/zygote_linux.h" 5 #include "content/zygote/zygote_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <poll.h> 9 #include <poll.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 19 matching lines...) Expand all
30 #include "base/process/process.h" 30 #include "base/process/process.h"
31 #include "base/process/process_handle.h" 31 #include "base/process/process_handle.h"
32 #include "base/time/time.h" 32 #include "base/time/time.h"
33 #include "base/trace_event/trace_event.h" 33 #include "base/trace_event/trace_event.h"
34 #include "build/build_config.h" 34 #include "build/build_config.h"
35 #include "content/common/child_process_sandbox_support_impl_linux.h" 35 #include "content/common/child_process_sandbox_support_impl_linux.h"
36 #include "content/common/sandbox_linux/sandbox_linux.h" 36 #include "content/common/sandbox_linux/sandbox_linux.h"
37 #include "content/common/set_process_title.h" 37 #include "content/common/set_process_title.h"
38 #include "content/common/zygote_commands_linux.h" 38 #include "content/common/zygote_commands_linux.h"
39 #include "content/public/common/content_descriptors.h" 39 #include "content/public/common/content_descriptors.h"
40 #include "content/public/common/mojo_channel_switches.h"
40 #include "content/public/common/result_codes.h" 41 #include "content/public/common/result_codes.h"
41 #include "content/public/common/sandbox_linux.h" 42 #include "content/public/common/sandbox_linux.h"
42 #include "content/public/common/send_zygote_child_ping_linux.h" 43 #include "content/public/common/send_zygote_child_ping_linux.h"
43 #include "content/public/common/zygote_fork_delegate_linux.h" 44 #include "content/public/common/zygote_fork_delegate_linux.h"
44 #include "ipc/ipc_channel.h" 45 #include "ipc/ipc_channel.h"
45 #include "ipc/ipc_switches.h" 46 #include "ipc/ipc_switches.h"
46 #include "sandbox/linux/services/credentials.h" 47 #include "sandbox/linux/services/credentials.h"
47 #include "sandbox/linux/services/namespace_sandbox.h" 48 #include "sandbox/linux/services/namespace_sandbox.h"
48 49
49 // See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote .md 50 // See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote .md
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 ++i) { 424 ++i) {
424 if ((*i)->CanHelp(process_type, uma_name, uma_sample, uma_boundary_value)) { 425 if ((*i)->CanHelp(process_type, uma_name, uma_sample, uma_boundary_value)) {
425 helper = *i; 426 helper = *i;
426 break; 427 break;
427 } 428 }
428 } 429 }
429 430
430 base::ScopedFD read_pipe, write_pipe; 431 base::ScopedFD read_pipe, write_pipe;
431 base::ProcessId pid = 0; 432 base::ProcessId pid = 0;
432 if (helper) { 433 if (helper) {
433 int ipc_channel_fd = LookUpFd(fd_mapping, kPrimaryIPCChannel);
434 if (ipc_channel_fd < 0) {
435 DLOG(ERROR) << "Failed to find kPrimaryIPCChannel in FD mapping";
436 return -1;
437 }
438 int mojo_channel_fd = LookUpFd(fd_mapping, kMojoIPCChannel); 434 int mojo_channel_fd = LookUpFd(fd_mapping, kMojoIPCChannel);
439 if (mojo_channel_fd < 0) { 435 if (mojo_channel_fd < 0) {
440 DLOG(ERROR) << "Failed to find kMojoIPCChannel in FD mapping"; 436 DLOG(ERROR) << "Failed to find kMojoIPCChannel in FD mapping";
441 return -1; 437 return -1;
442 } 438 }
439 int ipc_channel_fd = LookUpFd(fd_mapping, kPrimaryIPCChannel);
440 DCHECK_EQ(-1, ipc_channel_fd);
443 std::vector<int> fds; 441 std::vector<int> fds;
444 fds.push_back(ipc_channel_fd); // kBrowserFDIndex 442 fds.push_back(mojo_channel_fd); // kBrowserFDIndex
445 fds.push_back(pid_oracle.get()); // kPIDOracleFDIndex 443 fds.push_back(pid_oracle.get()); // kPIDOracleFDIndex
446 fds.push_back(mojo_channel_fd); // kMojoParentFDIndex
447 pid = helper->Fork(process_type, fds, channel_id); 444 pid = helper->Fork(process_type, fds, channel_id);
448 445
449 // Helpers should never return in the child process. 446 // Helpers should never return in the child process.
450 CHECK_NE(pid, 0); 447 CHECK_NE(pid, 0);
451 } else { 448 } else {
452 CreatePipe(&read_pipe, &write_pipe); 449 CreatePipe(&read_pipe, &write_pipe);
453 if (sandbox_flags_ & kSandboxLinuxPIDNS && 450 if (sandbox_flags_ & kSandboxLinuxPIDNS &&
454 sandbox_flags_ & kSandboxLinuxUserNS) { 451 sandbox_flags_ & kSandboxLinuxUserNS) {
455 pid = sandbox::NamespaceSandbox::ForkInNewPidNamespace( 452 pid = sandbox::NamespaceSandbox::ForkInNewPidNamespace(
456 /*drop_capabilities_in_child=*/true); 453 /*drop_capabilities_in_child=*/true);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 std::string* uma_name, 559 std::string* uma_name,
563 int* uma_sample, 560 int* uma_sample,
564 int* uma_boundary_value) { 561 int* uma_boundary_value) {
565 std::vector<std::string> args; 562 std::vector<std::string> args;
566 int argc = 0; 563 int argc = 0;
567 int numfds = 0; 564 int numfds = 0;
568 base::GlobalDescriptors::Mapping mapping; 565 base::GlobalDescriptors::Mapping mapping;
569 std::string process_type; 566 std::string process_type;
570 std::string channel_id; 567 std::string channel_id;
571 const std::string channel_id_prefix = std::string("--") 568 const std::string channel_id_prefix = std::string("--")
572 + switches::kProcessChannelID + std::string("="); 569 + switches::kMojoChannelToken + std::string("=");
573 570
574 if (!iter.ReadString(&process_type)) 571 if (!iter.ReadString(&process_type))
575 return -1; 572 return -1;
576 if (!iter.ReadInt(&argc)) 573 if (!iter.ReadInt(&argc))
577 return -1; 574 return -1;
578 575
579 for (int i = 0; i < argc; ++i) { 576 for (int i = 0; i < argc; ++i) {
580 std::string arg; 577 std::string arg;
581 if (!iter.ReadString(&arg)) 578 if (!iter.ReadString(&arg))
582 return -1; 579 return -1;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) { 667 bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) {
671 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != 668 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) !=
672 sizeof(sandbox_flags_)) { 669 sizeof(sandbox_flags_)) {
673 PLOG(ERROR) << "write"; 670 PLOG(ERROR) << "write";
674 } 671 }
675 672
676 return false; 673 return false;
677 } 674 }
678 675
679 } // namespace content 676 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/zygote_fork_delegate_linux.h ('k') | mojo/edk/system/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698