| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer_host/sandbox_ipc_linux.h" | 5 #include "content/browser/renderer_host/sandbox_ipc_linux.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <fontconfig/fontconfig.h> | 8 #include <fontconfig/fontconfig.h> |
| 9 #include <sys/poll.h> | 9 #include <sys/poll.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // default: | 122 // default: |
| 123 // Don't add any languages in that case that we don't recognise the | 123 // Don't add any languages in that case that we don't recognise the |
| 124 // constant. | 124 // constant. |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace | 128 } // namespace |
| 129 | 129 |
| 130 namespace content { | 130 namespace content { |
| 131 | 131 |
| 132 SandboxIPCProcess::SandboxIPCProcess(int lifeline_fd, | 132 SandboxIPCProcess::SandboxIPCProcess(int lifeline_fd, int browser_socket) |
| 133 int browser_socket, | |
| 134 std::string sandbox_cmd) | |
| 135 : lifeline_fd_(lifeline_fd), browser_socket_(browser_socket) { | 133 : lifeline_fd_(lifeline_fd), browser_socket_(browser_socket) { |
| 136 if (!sandbox_cmd.empty()) { | |
| 137 sandbox_cmd_.push_back(sandbox_cmd); | |
| 138 sandbox_cmd_.push_back(base::kFindInodeSwitch); | |
| 139 } | |
| 140 | |
| 141 // FontConfig doesn't provide a standard property to control subpixel | 134 // FontConfig doesn't provide a standard property to control subpixel |
| 142 // positioning, so we pass the current setting through to WebKit. | 135 // positioning, so we pass the current setting through to WebKit. |
| 143 WebFontInfo::setSubpixelPositioning( | 136 WebFontInfo::setSubpixelPositioning( |
| 144 gfx::GetDefaultWebkitSubpixelPositioning()); | 137 gfx::GetDefaultWebkitSubpixelPositioning()); |
| 145 | 138 |
| 146 CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 139 CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 147 command_line.AppendSwitchASCII(switches::kProcessType, | 140 command_line.AppendSwitchASCII(switches::kProcessType, |
| 148 switches::kSandboxIPCProcess); | 141 switches::kSandboxIPCProcess); |
| 149 | 142 |
| 150 // Update the process title. The argv was already cached by the call to | 143 // Update the process title. The argv was already cached by the call to |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return; | 206 return; |
| 214 | 207 |
| 215 if (kind == FontConfigIPC::METHOD_MATCH) { | 208 if (kind == FontConfigIPC::METHOD_MATCH) { |
| 216 HandleFontMatchRequest(fd, pickle, iter, fds.get()); | 209 HandleFontMatchRequest(fd, pickle, iter, fds.get()); |
| 217 } else if (kind == FontConfigIPC::METHOD_OPEN) { | 210 } else if (kind == FontConfigIPC::METHOD_OPEN) { |
| 218 HandleFontOpenRequest(fd, pickle, iter, fds.get()); | 211 HandleFontOpenRequest(fd, pickle, iter, fds.get()); |
| 219 } else if (kind == LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHAR) { | 212 } else if (kind == LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHAR) { |
| 220 HandleGetFontFamilyForChar(fd, pickle, iter, fds.get()); | 213 HandleGetFontFamilyForChar(fd, pickle, iter, fds.get()); |
| 221 } else if (kind == LinuxSandbox::METHOD_LOCALTIME) { | 214 } else if (kind == LinuxSandbox::METHOD_LOCALTIME) { |
| 222 HandleLocaltime(fd, pickle, iter, fds.get()); | 215 HandleLocaltime(fd, pickle, iter, fds.get()); |
| 223 } else if (kind == LinuxSandbox::METHOD_GET_CHILD_WITH_INODE) { | |
| 224 HandleGetChildWithInode(fd, pickle, iter, fds.get()); | |
| 225 } else if (kind == LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE) { | 216 } else if (kind == LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE) { |
| 226 HandleGetStyleForStrike(fd, pickle, iter, fds.get()); | 217 HandleGetStyleForStrike(fd, pickle, iter, fds.get()); |
| 227 } else if (kind == LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT) { | 218 } else if (kind == LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT) { |
| 228 HandleMakeSharedMemorySegment(fd, pickle, iter, fds.get()); | 219 HandleMakeSharedMemorySegment(fd, pickle, iter, fds.get()); |
| 229 } else if (kind == LinuxSandbox::METHOD_MATCH_WITH_FALLBACK) { | 220 } else if (kind == LinuxSandbox::METHOD_MATCH_WITH_FALLBACK) { |
| 230 HandleMatchWithFallback(fd, pickle, iter, fds.get()); | 221 HandleMatchWithFallback(fd, pickle, iter, fds.get()); |
| 231 } | 222 } |
| 232 } | 223 } |
| 233 | 224 |
| 234 int SandboxIPCProcess::FindOrAddPath(const SkString& path) { | 225 int SandboxIPCProcess::FindOrAddPath(const SkString& path) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 sizeof(struct tm)); | 387 sizeof(struct tm)); |
| 397 time_zone_string = expanded_time->tm_zone; | 388 time_zone_string = expanded_time->tm_zone; |
| 398 } | 389 } |
| 399 | 390 |
| 400 Pickle reply; | 391 Pickle reply; |
| 401 reply.WriteString(result_string); | 392 reply.WriteString(result_string); |
| 402 reply.WriteString(time_zone_string); | 393 reply.WriteString(time_zone_string); |
| 403 SendRendererReply(fds, reply, -1); | 394 SendRendererReply(fds, reply, -1); |
| 404 } | 395 } |
| 405 | 396 |
| 406 void SandboxIPCProcess::HandleGetChildWithInode( | |
| 407 int fd, | |
| 408 const Pickle& pickle, | |
| 409 PickleIterator iter, | |
| 410 const std::vector<base::ScopedFD*>& fds) { | |
| 411 // The other side of this call is in zygote_main_linux.cc | |
| 412 if (sandbox_cmd_.empty()) { | |
| 413 LOG(ERROR) << "Not in the sandbox, this should not be called"; | |
| 414 return; | |
| 415 } | |
| 416 | |
| 417 uint64_t inode; | |
| 418 if (!pickle.ReadUInt64(&iter, &inode)) | |
| 419 return; | |
| 420 | |
| 421 base::ProcessId pid = 0; | |
| 422 std::string inode_output; | |
| 423 | |
| 424 std::vector<std::string> sandbox_cmd = sandbox_cmd_; | |
| 425 sandbox_cmd.push_back(base::Int64ToString(inode)); | |
| 426 CommandLine get_inode_cmd(sandbox_cmd); | |
| 427 if (base::GetAppOutput(get_inode_cmd, &inode_output)) | |
| 428 base::StringToInt(inode_output, &pid); | |
| 429 | |
| 430 if (!pid) { | |
| 431 // Even though the pid is invalid, we still need to reply to the zygote | |
| 432 // and not just return here. | |
| 433 LOG(ERROR) << "Could not get pid"; | |
| 434 } | |
| 435 | |
| 436 Pickle reply; | |
| 437 reply.WriteInt(pid); | |
| 438 SendRendererReply(fds, reply, -1); | |
| 439 } | |
| 440 | |
| 441 void SandboxIPCProcess::HandleMakeSharedMemorySegment( | 397 void SandboxIPCProcess::HandleMakeSharedMemorySegment( |
| 442 int fd, | 398 int fd, |
| 443 const Pickle& pickle, | 399 const Pickle& pickle, |
| 444 PickleIterator iter, | 400 PickleIterator iter, |
| 445 const std::vector<base::ScopedFD*>& fds) { | 401 const std::vector<base::ScopedFD*>& fds) { |
| 446 base::SharedMemoryCreateOptions options; | 402 base::SharedMemoryCreateOptions options; |
| 447 uint32_t size; | 403 uint32_t size; |
| 448 if (!pickle.ReadUInt32(&iter, &size)) | 404 if (!pickle.ReadUInt32(&iter, &size)) |
| 449 return; | 405 return; |
| 450 options.size = size; | 406 options.size = size; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 } | 617 } |
| 662 | 618 |
| 663 void SandboxIPCProcess::EnsureWebKitInitialized() { | 619 void SandboxIPCProcess::EnsureWebKitInitialized() { |
| 664 if (webkit_platform_support_) | 620 if (webkit_platform_support_) |
| 665 return; | 621 return; |
| 666 webkit_platform_support_.reset(new BlinkPlatformImpl); | 622 webkit_platform_support_.reset(new BlinkPlatformImpl); |
| 667 blink::initializeWithoutV8(webkit_platform_support_.get()); | 623 blink::initializeWithoutV8(webkit_platform_support_.get()); |
| 668 } | 624 } |
| 669 | 625 |
| 670 } // namespace content | 626 } // namespace content |
| OLD | NEW |