| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_sandbox_host_linux.h" | 5 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <fontconfig/fontconfig.h> | 8 #include <fontconfig/fontconfig.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 // ----------------------------------------------------------------------------- | 636 // ----------------------------------------------------------------------------- |
| 637 | 637 |
| 638 // Runs on the main thread at startup. | 638 // Runs on the main thread at startup. |
| 639 RenderSandboxHostLinux::RenderSandboxHostLinux() | 639 RenderSandboxHostLinux::RenderSandboxHostLinux() |
| 640 : initialized_(false), | 640 : initialized_(false), |
| 641 renderer_socket_(0), | 641 renderer_socket_(0), |
| 642 childs_lifeline_fd_(0), | 642 childs_lifeline_fd_(0), |
| 643 pid_(0) { | 643 pid_(0) { |
| 644 } | 644 } |
| 645 | 645 |
| 646 // static |
| 647 RenderSandboxHostLinux* RenderSandboxHostLinux::GetInstance() { |
| 648 return Singleton<RenderSandboxHostLinux>::get(); |
| 649 } |
| 650 |
| 646 void RenderSandboxHostLinux::Init(const std::string& sandbox_path) { | 651 void RenderSandboxHostLinux::Init(const std::string& sandbox_path) { |
| 647 DCHECK(!initialized_); | 652 DCHECK(!initialized_); |
| 648 initialized_ = true; | 653 initialized_ = true; |
| 649 | 654 |
| 650 int fds[2]; | 655 int fds[2]; |
| 651 // We use SOCK_SEQPACKET rather than SOCK_DGRAM to prevent the renderer from | 656 // We use SOCK_SEQPACKET rather than SOCK_DGRAM to prevent the renderer from |
| 652 // sending datagrams to other sockets on the system. The sandbox may prevent | 657 // sending datagrams to other sockets on the system. The sandbox may prevent |
| 653 // the renderer from calling socket() to create new sockets, but it'll still | 658 // the renderer from calling socket() to create new sockets, but it'll still |
| 654 // inherit some sockets. With PF_UNIX+SOCK_DGRAM, it can call sendmsg to send | 659 // inherit some sockets. With PF_UNIX+SOCK_DGRAM, it can call sendmsg to send |
| 655 // a datagram to any (abstract) socket on the same system. With | 660 // a datagram to any (abstract) socket on the same system. With |
| (...skipping 17 matching lines...) Expand all Loading... |
| 673 } | 678 } |
| 674 | 679 |
| 675 RenderSandboxHostLinux::~RenderSandboxHostLinux() { | 680 RenderSandboxHostLinux::~RenderSandboxHostLinux() { |
| 676 if (initialized_) { | 681 if (initialized_) { |
| 677 if (HANDLE_EINTR(close(renderer_socket_)) < 0) | 682 if (HANDLE_EINTR(close(renderer_socket_)) < 0) |
| 678 PLOG(ERROR) << "close"; | 683 PLOG(ERROR) << "close"; |
| 679 if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) | 684 if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) |
| 680 PLOG(ERROR) << "close"; | 685 PLOG(ERROR) << "close"; |
| 681 } | 686 } |
| 682 } | 687 } |
| OLD | NEW |