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/common/child_process_sandbox_support_impl_linux.h" | 5 #include "content/common/child_process_sandbox_support_impl_linux.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 data_length = std::min(data_length, *output_length); | 174 data_length = std::min(data_length, *output_length); |
175 ssize_t n = HANDLE_EINTR(pread(fd, output, data_length, data_offset)); | 175 ssize_t n = HANDLE_EINTR(pread(fd, output, data_length, data_offset)); |
176 if (n != base::checked_cast<ssize_t>(data_length)) | 176 if (n != base::checked_cast<ssize_t>(data_length)) |
177 return false; | 177 return false; |
178 } | 178 } |
179 *output_length = data_length; | 179 *output_length = data_length; |
180 | 180 |
181 return true; | 181 return true; |
182 } | 182 } |
183 | 183 |
| 184 bool SendRealPidToZygote(int fd, base::ProcessId* out_pid) { |
| 185 Pickle request; |
| 186 request.WriteInt(LinuxSandbox::METHOD_GET_REAL_PID); |
| 187 request.WriteBool(out_pid != NULL); |
| 188 |
| 189 uint8_t buf[512]; |
| 190 const ssize_t n = UnixDomainSocket::SendRecvMsgWithFD( |
| 191 GetSandboxFD(), buf, sizeof(buf), NULL, request, fd); |
| 192 if (n < 0) |
| 193 return false; |
| 194 |
| 195 Pickle reply(reinterpret_cast<char*>(buf), n); |
| 196 PickleIterator iter(reply); |
| 197 int real_pid; |
| 198 if (!iter.ReadInt(&real_pid)) |
| 199 return false; |
| 200 |
| 201 if (out_pid) |
| 202 *out_pid = real_pid; |
| 203 else { |
| 204 // If caller doesn't want to receive its real PID, then make sure the |
| 205 // browser didn't send it to us. |
| 206 CHECK_EQ(0, real_pid); |
| 207 } |
| 208 |
| 209 return true; |
| 210 } |
| 211 |
184 } // namespace content | 212 } // namespace content |
OLD | NEW |