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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #if defined(OS_MACOSX) | 8 #if defined(OS_MACOSX) |
9 extern "C" { | 9 extern "C" { |
10 #include <sandbox.h> | 10 #include <sandbox.h> |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 | 186 |
187 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendFdsSandboxedClient) { | 187 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendFdsSandboxedClient) { |
188 struct stat st; | 188 struct stat st; |
189 const int fd = open(kDevZeroPath, O_RDONLY); | 189 const int fd = open(kDevZeroPath, O_RDONLY); |
190 fstat(fd, &st); | 190 fstat(fd, &st); |
191 if (IGNORE_EINTR(close(fd)) < 0) | 191 if (IGNORE_EINTR(close(fd)) < 0) |
192 return -1; | 192 return -1; |
193 | 193 |
194 // Enable the sandbox. | 194 // Enable the sandbox. |
195 char* error_buff = NULL; | 195 char* error_buff = NULL; |
196 #pragma clang diagnostic push | |
197 #pragma clang diagnostic ignored "-Wdeprecated-declarations" | |
Nico
2016/03/31 19:50:15
Here too
| |
196 int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED, | 198 int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED, |
197 &error_buff); | 199 &error_buff); |
198 bool success = (error == 0 && error_buff == NULL); | 200 bool success = (error == 0 && error_buff == NULL); |
199 if (!success) | 201 if (!success) |
200 return -1; | 202 return -1; |
201 | 203 |
202 sandbox_free_error(error_buff); | 204 sandbox_free_error(error_buff); |
205 #pragma clang diagnostic pop | |
203 | 206 |
204 // Make sure sandbox is really enabled. | 207 // Make sure sandbox is really enabled. |
205 if (open(kDevZeroPath, O_RDONLY) != -1) { | 208 if (open(kDevZeroPath, O_RDONLY) != -1) { |
206 LOG(ERROR) << "Sandbox wasn't properly enabled"; | 209 LOG(ERROR) << "Sandbox wasn't properly enabled"; |
207 return -1; | 210 return -1; |
208 } | 211 } |
209 | 212 |
210 // See if we can receive a file descriptor. | 213 // See if we can receive a file descriptor. |
211 return SendFdsClientCommon("SendFdsSandboxedClient", st.st_ino); | 214 return SendFdsClientCommon("SendFdsSandboxedClient", st.st_ino); |
212 } | 215 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 base::WaitableEvent received_; | 381 base::WaitableEvent received_; |
379 }; | 382 }; |
380 | 383 |
381 TEST_F(IPCMultiSendingFdsTest, StressTest) { | 384 TEST_F(IPCMultiSendingFdsTest, StressTest) { |
382 Run(); | 385 Run(); |
383 } | 386 } |
384 | 387 |
385 } // namespace | 388 } // namespace |
386 | 389 |
387 #endif // defined(OS_POSIX) | 390 #endif // defined(OS_POSIX) |
OLD | NEW |