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 <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 #include <mach/mach.h> | 9 #include <mach/mach.h> |
10 #include <servers/bootstrap.h> | 10 #include <servers/bootstrap.h> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 BootstrapSandboxPolicy policy; | 89 BootstrapSandboxPolicy policy; |
90 if (base::mac::IsOSSnowLeopard()) | 90 if (base::mac::IsOSSnowLeopard()) |
91 policy.rules["com.apple.SecurityServer"] = Rule(POLICY_ALLOW); | 91 policy.rules["com.apple.SecurityServer"] = Rule(POLICY_ALLOW); |
92 return policy; | 92 return policy; |
93 } | 93 } |
94 | 94 |
95 void RunChildWithPolicy(int policy_id, | 95 void RunChildWithPolicy(int policy_id, |
96 const char* child_name, | 96 const char* child_name, |
97 base::ProcessHandle* out_pid) { | 97 base::ProcessHandle* out_pid) { |
98 sandbox_->PrepareToForkWithPolicy(policy_id); | 98 sandbox_->PrepareToForkWithPolicy(policy_id); |
99 base::ProcessHandle pid = SpawnChild(child_name); | 99 base::LaunchOptions options; |
| 100 options.replacement_bootstrap_name = sandbox_->server_bootstrap_name(); |
| 101 base::ProcessHandle pid = SpawnChildWithOptions(child_name, options); |
100 ASSERT_GT(pid, 0); | 102 ASSERT_GT(pid, 0); |
101 sandbox_->FinishedFork(pid); | 103 sandbox_->FinishedFork(pid); |
102 int code = 0; | 104 int code = 0; |
103 EXPECT_TRUE(base::WaitForExitCode(pid, &code)); | 105 EXPECT_TRUE(base::WaitForExitCode(pid, &code)); |
104 EXPECT_EQ(0, code); | 106 EXPECT_EQ(0, code); |
105 if (out_pid) | 107 if (out_pid) |
106 *out_pid = pid; | 108 *out_pid = pid; |
107 } | 109 } |
108 | 110 |
109 protected: | 111 protected: |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 msg.header.msgh_remote_port = port; | 408 msg.header.msgh_remote_port = port; |
407 msg.header.msgh_bits = MACH_MSGH_BITS_REMOTE(MACH_MSG_TYPE_MOVE_SEND); | 409 msg.header.msgh_bits = MACH_MSGH_BITS_REMOTE(MACH_MSG_TYPE_MOVE_SEND); |
408 strncpy(msg.buf, kSubstituteAck, sizeof(msg.buf)); | 410 strncpy(msg.buf, kSubstituteAck, sizeof(msg.buf)); |
409 | 411 |
410 CHECK_EQ(KERN_SUCCESS, mach_msg_send(&msg.header)); | 412 CHECK_EQ(KERN_SUCCESS, mach_msg_send(&msg.header)); |
411 | 413 |
412 return 0; | 414 return 0; |
413 } | 415 } |
414 | 416 |
415 } // namespace sandbox | 417 } // namespace sandbox |
OLD | NEW |