| 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/browser/zygote_host/zygote_host_impl_linux.h" | 5 #include "content/browser/zygote_host/zygote_host_impl_linux.h" |
| 6 | 6 |
| 7 #include <sys/socket.h> | 7 #include <sys/socket.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 int fds[2]; | 79 int fds[2]; |
| 80 #if defined(OS_FREEBSD) || defined(OS_OPENBSD) | 80 #if defined(OS_FREEBSD) || defined(OS_OPENBSD) |
| 81 // The BSDs often don't support SOCK_SEQPACKET yet, so fall back to | 81 // The BSDs often don't support SOCK_SEQPACKET yet, so fall back to |
| 82 // SOCK_DGRAM if necessary. | 82 // SOCK_DGRAM if necessary. |
| 83 if (socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) != 0) | 83 if (socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) != 0) |
| 84 CHECK(socketpair(PF_UNIX, SOCK_DGRAM, 0, fds) == 0); | 84 CHECK(socketpair(PF_UNIX, SOCK_DGRAM, 0, fds) == 0); |
| 85 #else | 85 #else |
| 86 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); | 86 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); |
| 87 #endif | 87 #endif |
| 88 base::FileHandleMappingVector fds_to_map; | 88 base::FileHandleMappingVector fds_to_map; |
| 89 fds_to_map.push_back(std::make_pair(fds[1], kZygoteSocketPairFd)); | 89 fds_to_map.push_back(std::make_pair(fds[1], kMagicZygoteDescriptor)); |
| 90 | 90 |
| 91 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 91 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 92 if (browser_command_line.HasSwitch(switches::kZygoteCmdPrefix)) { | 92 if (browser_command_line.HasSwitch(switches::kZygoteCmdPrefix)) { |
| 93 cmd_line.PrependWrapper( | 93 cmd_line.PrependWrapper( |
| 94 browser_command_line.GetSwitchValueNative(switches::kZygoteCmdPrefix)); | 94 browser_command_line.GetSwitchValueNative(switches::kZygoteCmdPrefix)); |
| 95 } | 95 } |
| 96 // Append any switches from the browser process that need to be forwarded on | 96 // Append any switches from the browser process that need to be forwarded on |
| 97 // to the zygote/renderers. | 97 // to the zygote/renderers. |
| 98 // Should this list be obtained from browser_render_process_host.cc? | 98 // Should this list be obtained from browser_render_process_host.cc? |
| 99 static const char* kForwardSwitches[] = { | 99 static const char* kForwardSwitches[] = { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 LOG(FATAL) << "The SUID sandbox helper binary was found, but is not " | 142 LOG(FATAL) << "The SUID sandbox helper binary was found, but is not " |
| 143 "configured correctly. Rather than run without sandboxing " | 143 "configured correctly. Rather than run without sandboxing " |
| 144 "I'm aborting now. You need to make sure that " | 144 "I'm aborting now. You need to make sure that " |
| 145 << sandbox_binary_ << " is owned by root and has mode 4755."; | 145 << sandbox_binary_ << " is owned by root and has mode 4755."; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Start up the sandbox host process and get the file descriptor for the | 149 // Start up the sandbox host process and get the file descriptor for the |
| 150 // renderers to talk to it. | 150 // renderers to talk to it. |
| 151 const int sfd = RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); | 151 const int sfd = RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); |
| 152 fds_to_map.push_back(std::make_pair(sfd, kZygoteRendererSocketFd)); | 152 fds_to_map.push_back(std::make_pair(sfd, kMagicSandboxIPCDescriptor)); |
| 153 | 153 |
| 154 int dummy_fd = -1; | 154 int dummy_fd = -1; |
| 155 if (using_suid_sandbox_) { | 155 if (using_suid_sandbox_) { |
| 156 dummy_fd = socket(PF_UNIX, SOCK_DGRAM, 0); | 156 dummy_fd = socket(PF_UNIX, SOCK_DGRAM, 0); |
| 157 CHECK(dummy_fd >= 0); | 157 CHECK(dummy_fd >= 0); |
| 158 fds_to_map.push_back(std::make_pair(dummy_fd, kZygoteIdFd)); | 158 fds_to_map.push_back(std::make_pair(dummy_fd, kZygoteIdFd)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 base::ProcessHandle process = -1; | 161 base::ProcessHandle process = -1; |
| 162 base::LaunchOptions options; | 162 base::LaunchOptions options; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return RenderSandboxHostLinux::GetInstance()->pid(); | 505 return RenderSandboxHostLinux::GetInstance()->pid(); |
| 506 } | 506 } |
| 507 | 507 |
| 508 int ZygoteHostImpl::GetSandboxStatus() const { | 508 int ZygoteHostImpl::GetSandboxStatus() const { |
| 509 if (have_read_sandbox_status_word_) | 509 if (have_read_sandbox_status_word_) |
| 510 return sandbox_status_; | 510 return sandbox_status_; |
| 511 return 0; | 511 return 0; |
| 512 } | 512 } |
| 513 | 513 |
| 514 } // namespace content | 514 } // namespace content |
| OLD | NEW |