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/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 28 matching lines...) Expand all Loading... |
39 #include "content/public/common/content_descriptors.h" | 39 #include "content/public/common/content_descriptors.h" |
40 #include "content/public/common/result_codes.h" | 40 #include "content/public/common/result_codes.h" |
41 #include "content/public/common/sandbox_linux.h" | 41 #include "content/public/common/sandbox_linux.h" |
42 #include "content/public/common/send_zygote_child_ping_linux.h" | 42 #include "content/public/common/send_zygote_child_ping_linux.h" |
43 #include "content/public/common/zygote_fork_delegate_linux.h" | 43 #include "content/public/common/zygote_fork_delegate_linux.h" |
44 #include "ipc/ipc_channel.h" | 44 #include "ipc/ipc_channel.h" |
45 #include "ipc/ipc_switches.h" | 45 #include "ipc/ipc_switches.h" |
46 #include "sandbox/linux/services/credentials.h" | 46 #include "sandbox/linux/services/credentials.h" |
47 #include "sandbox/linux/services/namespace_sandbox.h" | 47 #include "sandbox/linux/services/namespace_sandbox.h" |
48 | 48 |
49 // See http://code.google.com/p/chromium/wiki/LinuxZygote | 49 // See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote
.md |
50 | 50 |
51 namespace content { | 51 namespace content { |
52 | 52 |
53 namespace { | 53 namespace { |
54 | 54 |
55 // NOP function. See below where this handler is installed. | 55 // NOP function. See below where this handler is installed. |
56 void SIGCHLDHandler(int signal) { | 56 void SIGCHLDHandler(int signal) { |
57 } | 57 } |
58 | 58 |
59 int LookUpFd(const base::GlobalDescriptors::Mapping& fd_mapping, uint32_t key) { | 59 int LookUpFd(const base::GlobalDescriptors::Mapping& fd_mapping, uint32_t key) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 extra_fds_(extra_fds), | 101 extra_fds_(extra_fds), |
102 to_reap_() {} | 102 to_reap_() {} |
103 | 103 |
104 Zygote::~Zygote() { | 104 Zygote::~Zygote() { |
105 } | 105 } |
106 | 106 |
107 bool Zygote::ProcessRequests() { | 107 bool Zygote::ProcessRequests() { |
108 // A SOCK_SEQPACKET socket is installed in fd 3. We get commands from the | 108 // A SOCK_SEQPACKET socket is installed in fd 3. We get commands from the |
109 // browser on it. | 109 // browser on it. |
110 // A SOCK_DGRAM is installed in fd 5. This is the sandbox IPC channel. | 110 // A SOCK_DGRAM is installed in fd 5. This is the sandbox IPC channel. |
111 // See http://code.google.com/p/chromium/wiki/LinuxSandboxIPC | 111 // See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_sand
box_ipc.md |
112 | 112 |
113 // We need to accept SIGCHLD, even though our handler is a no-op because | 113 // We need to accept SIGCHLD, even though our handler is a no-op because |
114 // otherwise we cannot wait on children. (According to POSIX 2001.) | 114 // otherwise we cannot wait on children. (According to POSIX 2001.) |
115 struct sigaction action; | 115 struct sigaction action; |
116 memset(&action, 0, sizeof(action)); | 116 memset(&action, 0, sizeof(action)); |
117 action.sa_handler = &SIGCHLDHandler; | 117 action.sa_handler = &SIGCHLDHandler; |
118 PCHECK(sigaction(SIGCHLD, &action, NULL) == 0); | 118 PCHECK(sigaction(SIGCHLD, &action, NULL) == 0); |
119 | 119 |
120 // Block SIGCHLD until a child might be ready to reap. | 120 // Block SIGCHLD until a child might be ready to reap. |
121 sigset_t sigset; | 121 sigset_t sigset; |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) { | 665 bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) { |
666 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != | 666 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != |
667 sizeof(sandbox_flags_)) { | 667 sizeof(sandbox_flags_)) { |
668 PLOG(ERROR) << "write"; | 668 PLOG(ERROR) << "write"; |
669 } | 669 } |
670 | 670 |
671 return false; | 671 return false; |
672 } | 672 } |
673 | 673 |
674 } // namespace content | 674 } // namespace content |
OLD | NEW |