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 "chrome/app/nacl_fork_delegate_linux.h" | 5 #include "chrome/app/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/resource.h> | 9 #include <sys/resource.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 16 matching lines...) Expand all Loading... |
27 NaClForkDelegate::NaClForkDelegate() | 27 NaClForkDelegate::NaClForkDelegate() |
28 : status_(kNaClHelperUnused), | 28 : status_(kNaClHelperUnused), |
29 fd_(-1) {} | 29 fd_(-1) {} |
30 | 30 |
31 // Note these need to match up with their counterparts in nacl_helper_linux.c | 31 // Note these need to match up with their counterparts in nacl_helper_linux.c |
32 // and nacl_helper_bootstrap_linux.c. | 32 // and nacl_helper_bootstrap_linux.c. |
33 const char kNaClHelperReservedAtZero[] = | 33 const char kNaClHelperReservedAtZero[] = |
34 "--reserved_at_zero=0xXXXXXXXXXXXXXXXX"; | 34 "--reserved_at_zero=0xXXXXXXXXXXXXXXXX"; |
35 const char kNaClHelperRDebug[] = "--r_debug=0xXXXXXXXXXXXXXXXX"; | 35 const char kNaClHelperRDebug[] = "--r_debug=0xXXXXXXXXXXXXXXXX"; |
36 | 36 |
37 void NaClForkDelegate::Init(const int browserdesc, const int sandboxdesc) { | 37 void NaClForkDelegate::Init(const int sandboxdesc) { |
38 VLOG(1) << "NaClForkDelegate::Init()"; | 38 VLOG(1) << "NaClForkDelegate::Init()"; |
39 int fds[2]; | 39 int fds[2]; |
40 | 40 |
41 // Confirm a couple hard-wired assumptions. | 41 // Confirm a hard-wired assumption. |
42 // The NaCl constants are from chrome/nacl/nacl_linux_helper.h | 42 // The NaCl constant is from chrome/nacl/nacl_linux_helper.h |
43 DCHECK(kNaClBrowserDescriptor == browserdesc); | |
44 DCHECK(kNaClSandboxDescriptor == sandboxdesc); | 43 DCHECK(kNaClSandboxDescriptor == sandboxdesc); |
45 | 44 |
46 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); | 45 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); |
47 base::FileHandleMappingVector fds_to_map; | 46 base::FileHandleMappingVector fds_to_map; |
48 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); | 47 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); |
49 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); | 48 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); |
50 | 49 |
51 status_ = kNaClHelperUnused; | 50 status_ = kNaClHelperUnused; |
52 FilePath helper_exe; | 51 FilePath helper_exe; |
53 FilePath helper_bootstrap_exe; | 52 FilePath helper_bootstrap_exe; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 155 |
157 bool NaClForkDelegate::AckChild(const int fd, | 156 bool NaClForkDelegate::AckChild(const int fd, |
158 const std::string& channel_switch) { | 157 const std::string& channel_switch) { |
159 int nwritten = HANDLE_EINTR(write(fd, channel_switch.c_str(), | 158 int nwritten = HANDLE_EINTR(write(fd, channel_switch.c_str(), |
160 channel_switch.length())); | 159 channel_switch.length())); |
161 if (nwritten != static_cast<int>(channel_switch.length())) { | 160 if (nwritten != static_cast<int>(channel_switch.length())) { |
162 return false; | 161 return false; |
163 } | 162 } |
164 return true; | 163 return true; |
165 } | 164 } |
OLD | NEW |