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> |
11 #include <sys/uio.h> | 11 #include <sys/uio.h> |
12 #include <sys/stat.h> | 12 #include <sys/stat.h> |
13 #include <sys/socket.h> | 13 #include <sys/socket.h> |
14 #include <sys/poll.h> | 14 #include <sys/poll.h> |
15 #include <time.h> | 15 #include <time.h> |
16 | 16 |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
20 #include "base/eintr_wrapper.h" | 20 #include "base/eintr_wrapper.h" |
21 #include "base/linux_util.h" | 21 #include "base/linux_util.h" |
22 #include "base/pickle.h" | 22 #include "base/pickle.h" |
23 #include "base/process_util.h" | 23 #include "base/process_util.h" |
24 #include "base/scoped_ptr.h" | 24 #include "base/scoped_ptr.h" |
25 #include "base/shared_memory.h" | 25 #include "base/shared_memory.h" |
| 26 #include "base/singleton.h" |
26 #include "base/string_number_conversions.h" | 27 #include "base/string_number_conversions.h" |
27 #include "base/string_util.h" | 28 #include "base/string_util.h" |
28 #include "base/unix_domain_socket_posix.h" | 29 #include "base/unix_domain_socket_posix.h" |
29 #include "chrome/common/sandbox_methods_linux.h" | 30 #include "chrome/common/sandbox_methods_linux.h" |
30 #include "third_party/npapi/bindings/npapi_extensions.h" | 31 #include "third_party/npapi/bindings/npapi_extensions.h" |
31 #include "third_party/WebKit/WebKit/chromium/public/gtk/WebFontInfo.h" | 32 #include "third_party/WebKit/WebKit/chromium/public/gtk/WebFontInfo.h" |
32 | 33 |
33 #include "SkFontHost_fontconfig_direct.h" | 34 #include "SkFontHost_fontconfig_direct.h" |
34 #include "SkFontHost_fontconfig_ipc.h" | 35 #include "SkFontHost_fontconfig_ipc.h" |
35 | 36 |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 // ----------------------------------------------------------------------------- | 637 // ----------------------------------------------------------------------------- |
637 | 638 |
638 // Runs on the main thread at startup. | 639 // Runs on the main thread at startup. |
639 RenderSandboxHostLinux::RenderSandboxHostLinux() | 640 RenderSandboxHostLinux::RenderSandboxHostLinux() |
640 : initialized_(false), | 641 : initialized_(false), |
641 renderer_socket_(0), | 642 renderer_socket_(0), |
642 childs_lifeline_fd_(0), | 643 childs_lifeline_fd_(0), |
643 pid_(0) { | 644 pid_(0) { |
644 } | 645 } |
645 | 646 |
| 647 // static |
| 648 RenderSandboxHostLinux* RenderSandboxHostLinux::GetInstance() { |
| 649 return Singleton<RenderSandboxHostLinux>::get(); |
| 650 } |
| 651 |
646 void RenderSandboxHostLinux::Init(const std::string& sandbox_path) { | 652 void RenderSandboxHostLinux::Init(const std::string& sandbox_path) { |
647 DCHECK(!initialized_); | 653 DCHECK(!initialized_); |
648 initialized_ = true; | 654 initialized_ = true; |
649 | 655 |
650 int fds[2]; | 656 int fds[2]; |
651 // We use SOCK_SEQPACKET rather than SOCK_DGRAM to prevent the renderer from | 657 // 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 | 658 // 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 | 659 // 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 | 660 // 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 | 661 // a datagram to any (abstract) socket on the same system. With |
(...skipping 17 matching lines...) Expand all Loading... |
673 } | 679 } |
674 | 680 |
675 RenderSandboxHostLinux::~RenderSandboxHostLinux() { | 681 RenderSandboxHostLinux::~RenderSandboxHostLinux() { |
676 if (initialized_) { | 682 if (initialized_) { |
677 if (HANDLE_EINTR(close(renderer_socket_)) < 0) | 683 if (HANDLE_EINTR(close(renderer_socket_)) < 0) |
678 PLOG(ERROR) << "close"; | 684 PLOG(ERROR) << "close"; |
679 if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) | 685 if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) |
680 PLOG(ERROR) << "close"; | 686 PLOG(ERROR) << "close"; |
681 } | 687 } |
682 } | 688 } |
OLD | NEW |