| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sandbox/mac/bootstrap_sandbox.h" | 5 #include "sandbox/mac/bootstrap_sandbox.h" |
| 6 | 6 |
| 7 #include <servers/bootstrap.h> | 7 #include <servers/bootstrap.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 sandbox->launchd_server_.reset(new LaunchdInterceptionServer(sandbox.get())); | 61 sandbox->launchd_server_.reset(new LaunchdInterceptionServer(sandbox.get())); |
| 62 | 62 |
| 63 // Check in with launchd to get the receive right for the server that is | 63 // Check in with launchd to get the receive right for the server that is |
| 64 // published in the bootstrap namespace. | 64 // published in the bootstrap namespace. |
| 65 mach_port_t port = MACH_PORT_NULL; | 65 mach_port_t port = MACH_PORT_NULL; |
| 66 kern_return_t kr = bootstrap_check_in(bootstrap_port, | 66 kern_return_t kr = bootstrap_check_in(bootstrap_port, |
| 67 sandbox->server_bootstrap_name().c_str(), &port); | 67 sandbox->server_bootstrap_name().c_str(), &port); |
| 68 if (kr != KERN_SUCCESS) { | 68 if (kr != KERN_SUCCESS) { |
| 69 BOOTSTRAP_LOG(ERROR, kr) | 69 BOOTSTRAP_LOG(ERROR, kr) |
| 70 << "Failed to bootstrap_check_in the sandbox server."; | 70 << "Failed to bootstrap_check_in the sandbox server."; |
| 71 return null.Pass(); | 71 return null; |
| 72 } | 72 } |
| 73 sandbox->check_in_port_.reset(port); | 73 sandbox->check_in_port_.reset(port); |
| 74 | 74 |
| 75 BootstrapSandbox* __block sandbox_ptr = sandbox.get(); | 75 BootstrapSandbox* __block sandbox_ptr = sandbox.get(); |
| 76 sandbox->check_in_server_.reset(new base::DispatchSourceMach( | 76 sandbox->check_in_server_.reset(new base::DispatchSourceMach( |
| 77 "org.chromium.sandbox.BootstrapClientManager", | 77 "org.chromium.sandbox.BootstrapClientManager", |
| 78 sandbox->check_in_port_.get(), | 78 sandbox->check_in_port_.get(), |
| 79 ^{ sandbox_ptr->HandleChildCheckIn(); })); | 79 ^{ sandbox_ptr->HandleChildCheckIn(); })); |
| 80 sandbox->check_in_server_->Resume(); | 80 sandbox->check_in_server_->Resume(); |
| 81 | 81 |
| 82 // Start the sandbox server. | 82 // Start the sandbox server. |
| 83 if (!sandbox->launchd_server_->Initialize(MACH_PORT_NULL)) | 83 if (!sandbox->launchd_server_->Initialize(MACH_PORT_NULL)) |
| 84 return null.Pass(); | 84 return null; |
| 85 | 85 |
| 86 return sandbox.Pass(); | 86 return sandbox; |
| 87 } | 87 } |
| 88 | 88 |
| 89 // Warning: This function must be safe to call in | 89 // Warning: This function must be safe to call in |
| 90 // PreExecDelegate::RunAsyncSafe(). | 90 // PreExecDelegate::RunAsyncSafe(). |
| 91 // static | 91 // static |
| 92 bool BootstrapSandbox::ClientCheckIn(mach_port_t sandbox_server_port, | 92 bool BootstrapSandbox::ClientCheckIn(mach_port_t sandbox_server_port, |
| 93 uint64_t sandbox_token, | 93 uint64_t sandbox_token, |
| 94 mach_port_t* new_bootstrap_port) { | 94 mach_port_t* new_bootstrap_port) { |
| 95 // Create a reply port for the check in message. | 95 // Create a reply port for the check in message. |
| 96 mach_port_t reply_port; | 96 mach_port_t reply_port; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } else { | 252 } else { |
| 253 { | 253 { |
| 254 base::AutoLock lock(lock_); | 254 base::AutoLock lock(lock_); |
| 255 sandboxed_processes_.erase(client_pid); | 255 sandboxed_processes_.erase(client_pid); |
| 256 } | 256 } |
| 257 MACH_LOG(ERROR, kr) << "HandleChildCheckIn mach_msg MACH_SEND_MSG"; | 257 MACH_LOG(ERROR, kr) << "HandleChildCheckIn mach_msg MACH_SEND_MSG"; |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 } // namespace sandbox | 261 } // namespace sandbox |
| OLD | NEW |