OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/pre_exec_delegate.h" | 5 #include "sandbox/mac/pre_exec_delegate.h" |
6 | 6 |
7 #include <mach/mach.h> | 7 #include <mach/mach.h> |
8 #include <servers/bootstrap.h> | 8 #include <servers/bootstrap.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/mac/mac_util.h" | 12 #include "base/mac/mac_util.h" |
13 #include "sandbox/mac/bootstrap_sandbox.h" | 13 #include "sandbox/mac/bootstrap_sandbox.h" |
14 #include "sandbox/mac/xpc.h" | 14 #include "sandbox/mac/xpc.h" |
15 | 15 |
16 namespace sandbox { | 16 namespace sandbox { |
17 | 17 |
18 PreExecDelegate::PreExecDelegate( | 18 PreExecDelegate::PreExecDelegate( |
19 const std::string& sandbox_server_bootstrap_name, | 19 const std::string& sandbox_server_bootstrap_name, |
20 uint64_t sandbox_token) | 20 uint64_t sandbox_token) |
21 : sandbox_server_bootstrap_name_(sandbox_server_bootstrap_name), | 21 : sandbox_server_bootstrap_name_(sandbox_server_bootstrap_name), |
22 sandbox_server_bootstrap_name_ptr_( | 22 sandbox_server_bootstrap_name_ptr_( |
23 sandbox_server_bootstrap_name_.c_str()), | 23 sandbox_server_bootstrap_name_.c_str()), |
24 sandbox_token_(sandbox_token), | 24 sandbox_token_(sandbox_token), |
25 is_yosemite_or_later_(base::mac::IsOSYosemiteOrLater()), | 25 is_yosemite_or_later_(base::mac::IsAtLeastOS10_10()), |
26 look_up_message_(CreateBootstrapLookUpMessage()) { | 26 look_up_message_(CreateBootstrapLookUpMessage()) {} |
27 } | |
28 | 27 |
29 PreExecDelegate::~PreExecDelegate() {} | 28 PreExecDelegate::~PreExecDelegate() {} |
30 | 29 |
31 void PreExecDelegate::RunAsyncSafe() { | 30 void PreExecDelegate::RunAsyncSafe() { |
32 mach_port_t sandbox_server_port = MACH_PORT_NULL; | 31 mach_port_t sandbox_server_port = MACH_PORT_NULL; |
33 kern_return_t kr = DoBootstrapLookUp(&sandbox_server_port); | 32 kern_return_t kr = DoBootstrapLookUp(&sandbox_server_port); |
34 if (kr != KERN_SUCCESS) | 33 if (kr != KERN_SUCCESS) |
35 RAW_LOG(FATAL, "Failed to look up bootstrap sandbox server port."); | 34 RAW_LOG(FATAL, "Failed to look up bootstrap sandbox server port."); |
36 | 35 |
37 mach_port_t new_bootstrap_port = MACH_PORT_NULL; | 36 mach_port_t new_bootstrap_port = MACH_PORT_NULL; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 96 } |
98 } else { | 97 } else { |
99 // On non-XPC launchd systems, bootstrap_look_up() is MIG-based and | 98 // On non-XPC launchd systems, bootstrap_look_up() is MIG-based and |
100 // generally safe. | 99 // generally safe. |
101 return bootstrap_look_up(bootstrap_port, | 100 return bootstrap_look_up(bootstrap_port, |
102 sandbox_server_bootstrap_name_ptr_, out_port); | 101 sandbox_server_bootstrap_name_ptr_, out_port); |
103 } | 102 } |
104 } | 103 } |
105 | 104 |
106 } // namespace sandbox | 105 } // namespace sandbox |
OLD | NEW |