| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/nacl_fork_delegate_linux.h" | 5 #include "chrome/common/nacl_fork_delegate_linux.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 sandboxed_ = sandboxed; | 37 sandboxed_ = sandboxed; |
| 38 // Confirm a couple hard-wired assumptions. | 38 // Confirm a couple hard-wired assumptions. |
| 39 // The NaCl constants are from chrome/nacl/nacl_linux_helper.h | 39 // The NaCl constants are from chrome/nacl/nacl_linux_helper.h |
| 40 DCHECK(kNaClBrowserDescriptor == browserdesc); | 40 DCHECK(kNaClBrowserDescriptor == browserdesc); |
| 41 DCHECK(kNaClSandboxDescriptor == sandboxdesc); | 41 DCHECK(kNaClSandboxDescriptor == sandboxdesc); |
| 42 | 42 |
| 43 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); | 43 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); |
| 44 base::file_handle_mapping_vector fds_to_map; | 44 base::file_handle_mapping_vector fds_to_map; |
| 45 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); | 45 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); |
| 46 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); | 46 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); |
| 47 // TODO(bradchen): To make this the default for release builds, | |
| 48 // remove command line switch. | |
| 49 ready_ = false; | 47 ready_ = false; |
| 50 const bool use_helper = CommandLine::ForCurrentProcess()->HasSwitch( | |
| 51 switches::kNaClLinuxHelper); | |
| 52 FilePath helper_exe; | 48 FilePath helper_exe; |
| 53 FilePath helper_bootstrap_exe; | 49 FilePath helper_bootstrap_exe; |
| 54 if (use_helper && | 50 if (PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe) && |
| 55 PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe) && | |
| 56 PathService::Get(chrome::FILE_NACL_HELPER_BOOTSTRAP, | 51 PathService::Get(chrome::FILE_NACL_HELPER_BOOTSTRAP, |
| 57 &helper_bootstrap_exe)) { | 52 &helper_bootstrap_exe)) { |
| 58 CommandLine::StringVector argv = CommandLine::ForCurrentProcess()->argv(); | 53 CommandLine::StringVector argv = CommandLine::ForCurrentProcess()->argv(); |
| 59 argv[0] = helper_bootstrap_exe.value(); | 54 argv[0] = helper_bootstrap_exe.value(); |
| 60 argv[1] = helper_exe.value(); | 55 argv[1] = helper_exe.value(); |
| 61 argv[2] = kNaClHelperAtZero; | 56 argv[2] = kNaClHelperAtZero; |
| 62 base::LaunchOptions options; | 57 base::LaunchOptions options; |
| 63 options.fds_to_remap = &fds_to_map; | 58 options.fds_to_remap = &fds_to_map; |
| 64 options.clone_flags = CLONE_FS | SIGCHLD; | 59 options.clone_flags = CLONE_FS | SIGCHLD; |
| 65 ready_ = base::LaunchProcess(argv, options, NULL); | 60 ready_ = base::LaunchProcess(argv, options, NULL); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 117 |
| 123 bool NaClForkDelegate::AckChild(const int fd, | 118 bool NaClForkDelegate::AckChild(const int fd, |
| 124 const std::string& channel_switch) { | 119 const std::string& channel_switch) { |
| 125 int nwritten = HANDLE_EINTR(write(fd, channel_switch.c_str(), | 120 int nwritten = HANDLE_EINTR(write(fd, channel_switch.c_str(), |
| 126 channel_switch.length())); | 121 channel_switch.length())); |
| 127 if (nwritten != static_cast<int>(channel_switch.length())) { | 122 if (nwritten != static_cast<int>(channel_switch.length())) { |
| 128 return false; | 123 return false; |
| 129 } | 124 } |
| 130 return true; | 125 return true; |
| 131 } | 126 } |
| OLD | NEW |