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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendFdsSandboxedClient) { | 190 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendFdsSandboxedClient) { |
191 struct stat st; | 191 struct stat st; |
192 const int fd = open(kDevZeroPath, O_RDONLY); | 192 const int fd = open(kDevZeroPath, O_RDONLY); |
193 fstat(fd, &st); | 193 fstat(fd, &st); |
194 if (IGNORE_EINTR(close(fd)) < 0) | 194 if (IGNORE_EINTR(close(fd)) < 0) |
195 return -1; | 195 return -1; |
196 | 196 |
197 // Enable the sandbox. | 197 // Enable the sandbox. |
198 char* error_buff = NULL; | 198 char* error_buff = NULL; |
199 int error = sandbox::Seatbelt::Init(kSBXProfilePureComputation, SANDBOX_NAMED, | 199 int error = sandbox::Seatbelt::Init( |
200 &error_buff); | 200 sandbox::Seatbelt::kProfilePureComputation, SANDBOX_NAMED, &error_buff); |
201 bool success = (error == 0 && error_buff == NULL); | 201 bool success = (error == 0 && error_buff == NULL); |
202 if (!success) | 202 if (!success) |
203 return -1; | 203 return -1; |
204 | 204 |
205 sandbox::Seatbelt::FreeError(error_buff); | 205 sandbox::Seatbelt::FreeError(error_buff); |
206 | 206 |
207 // Make sure sandbox is really enabled. | 207 // Make sure sandbox is really enabled. |
208 if (open(kDevZeroPath, O_RDONLY) != -1) { | 208 if (open(kDevZeroPath, O_RDONLY) != -1) { |
209 LOG(ERROR) << "Sandbox wasn't properly enabled"; | 209 LOG(ERROR) << "Sandbox wasn't properly enabled"; |
210 return -1; | 210 return -1; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 base::WaitableEvent received_; | 387 base::WaitableEvent received_; |
388 }; | 388 }; |
389 | 389 |
390 TEST_F(IPCMultiSendingFdsTest, StressTest) { | 390 TEST_F(IPCMultiSendingFdsTest, StressTest) { |
391 Run(); | 391 Run(); |
392 } | 392 } |
393 | 393 |
394 } // namespace | 394 } // namespace |
395 | 395 |
396 #endif // defined(OS_POSIX) | 396 #endif // defined(OS_POSIX) |
OLD | NEW |