| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" | 7 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" |
| 8 | 8 |
| 9 #include "native_client/src/include/nacl_macros.h" | 9 #include "native_client/src/include/nacl_macros.h" |
| 10 #include "native_client/src/shared/platform/nacl_check.h" | 10 #include "native_client/src/shared/platform/nacl_check.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // Start the SRPC client to communicate with the trusted command channel. | 85 // Start the SRPC client to communicate with the trusted command channel. |
| 86 // SRPC client takes an additional reference to command_desc. | 86 // SRPC client takes an additional reference to command_desc. |
| 87 if (!NaClSrpcClientCtor(command, command_desc->desc())) { | 87 if (!NaClSrpcClientCtor(command, command_desc->desc())) { |
| 88 NaClLog(0, "SelLdrLauncher::SetupCommand: " | 88 NaClLog(0, "SelLdrLauncher::SetupCommand: " |
| 89 "NaClSrpcClientCtor failed\n"); | 89 "NaClSrpcClientCtor failed\n"); |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 return true; | 92 return true; |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool SelLdrLauncherBase::SetupUntrustedCommand(NaClSrpcChannel* command) { |
| 96 NaClSrpcChannel secure_chan; |
| 97 if (!SetupCommand(&secure_chan)) { |
| 98 NaClLog(LOG_ERROR, "SelLdrLauncher::SetupCommand: " |
| 99 "failed to setup trusted command channel\n"); |
| 100 return false; |
| 101 } |
| 102 NaClDesc* h; |
| 103 NaClSrpcResultCodes rpc_result = |
| 104 NaClSrpcInvokeBySignature(&secure_chan, |
| 105 "command_setup::h", |
| 106 &h); |
| 107 if (NACL_SRPC_RESULT_OK != rpc_result) { |
| 108 NaClLog(LOG_ERROR, "SelLdrLauncher::SetupCommand: " |
| 109 "command setup failed\n"); |
| 110 return false; |
| 111 } |
| 112 // Make a nacl::DescWrapper* from the NaClDesc* |
| 113 scoped_ptr<nacl::DescWrapper> conn_cap(WrapCleanup(h)); |
| 114 if (conn_cap == NULL) { |
| 115 NaClLog(LOG_ERROR, "SelLdrLauncher::SetupCommand: " |
| 116 "command conn desc wrap failed\n"); |
| 117 return false; |
| 118 } |
| 119 scoped_ptr<DescWrapper> command_desc(conn_cap->Connect()); |
| 120 if (command_desc == NULL) { |
| 121 NaClLog(0, "SelLdrLauncher::SetupCommand: Connect failed\n"); |
| 122 return false; |
| 123 } |
| 124 // Start the SRPC client to communicate with the command channel. |
| 125 // SRPC client takes an additional reference to command_desc. |
| 126 if (!NaClSrpcClientCtor(command, command_desc->desc())) { |
| 127 NaClLog(0, "SelLdrLauncher::SetupCommand: " |
| 128 "NaClSrpcClientCtor failed\n"); |
| 129 return false; |
| 130 } |
| 131 return true; |
| 132 } |
| 133 |
| 95 bool SelLdrLauncherBase::LoadModule(NaClSrpcChannel* command, | 134 bool SelLdrLauncherBase::LoadModule(NaClSrpcChannel* command, |
| 96 DescWrapper* nexe) { | 135 DescWrapper* nexe) { |
| 97 // TODO(sehr): This argument to load_module is unused. Remove it. | 136 // TODO(sehr): This argument to load_module is unused. Remove it. |
| 98 static const char kLoadModulePlaceHolderString[] = "place holder"; | 137 static const char kLoadModulePlaceHolderString[] = "place holder"; |
| 99 | 138 |
| 100 CHECK(nexe != NULL); | 139 CHECK(nexe != NULL); |
| 101 // Load module over command channel. | 140 // Load module over command channel. |
| 102 NaClSrpcResultCodes rpc_result = | 141 NaClSrpcResultCodes rpc_result = |
| 103 NaClSrpcInvokeBySignature(command, | 142 NaClSrpcInvokeBySignature(command, |
| 104 "load_module:hs:", | 143 "load_module:hs:", |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 if (NULL != bootstrap_socket_.get()) { | 262 if (NULL != bootstrap_socket_.get()) { |
| 224 nbytes = bootstrap_socket_->RecvMsg(&hdr, 0, NULL); | 263 nbytes = bootstrap_socket_->RecvMsg(&hdr, 0, NULL); |
| 225 } | 264 } |
| 226 if (nbytes > 0) { | 265 if (nbytes > 0) { |
| 227 return nacl::string(msg_buf, nbytes); | 266 return nacl::string(msg_buf, nbytes); |
| 228 } | 267 } |
| 229 return ""; | 268 return ""; |
| 230 } | 269 } |
| 231 | 270 |
| 232 } // namespace nacl | 271 } // namespace nacl |
| OLD | NEW |