| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #include <dirent.h> | 6 #include <dirent.h> |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 extern "C" { | 9 extern "C" { |
| 10 #include <sandbox.h> | 10 #include <sandbox.h> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 // Tests need to be in the same namespace as the Sandbox class to be useable | 34 // Tests need to be in the same namespace as the Sandbox class to be useable |
| 35 // with FRIEND_TEST() declaration. | 35 // with FRIEND_TEST() declaration. |
| 36 namespace content { | 36 namespace content { |
| 37 | 37 |
| 38 class MacDirAccessSandboxTest : public base::MultiProcessTest { | 38 class MacDirAccessSandboxTest : public base::MultiProcessTest { |
| 39 public: | 39 public: |
| 40 bool CheckSandbox(const std::string& directory_to_try) { | 40 bool CheckSandbox(const std::string& directory_to_try) { |
| 41 setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1); | 41 setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1); |
| 42 base::Process child_process = SpawnChild("mac_sandbox_path_access"); | 42 base::SpawnChildResult spawn_result = SpawnChild("mac_sandbox_path_access"); |
| 43 base::Process child_process = std::move(spawn_result.process); |
| 43 if (!child_process.IsValid()) { | 44 if (!child_process.IsValid()) { |
| 44 LOG(WARNING) << "SpawnChild failed"; | 45 LOG(WARNING) << "SpawnChild failed"; |
| 45 return false; | 46 return false; |
| 46 } | 47 } |
| 47 int code = -1; | 48 int code = -1; |
| 48 if (!child_process.WaitForExit(&code)) { | 49 if (!child_process.WaitForExit(&code)) { |
| 49 LOG(WARNING) << "Process::WaitForExit failed"; | 50 LOG(WARNING) << "Process::WaitForExit failed"; |
| 50 return false; | 51 return false; |
| 51 } | 52 } |
| 52 return code == 0; | 53 return code == 0; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 PLOG(ERROR) << "Sandbox breach: was able to write (" | 298 PLOG(ERROR) << "Sandbox breach: was able to write (" |
| 298 << denied_file2.value() | 299 << denied_file2.value() |
| 299 << ")"; | 300 << ")"; |
| 300 return -1; | 301 return -1; |
| 301 } | 302 } |
| 302 | 303 |
| 303 return 0; | 304 return 0; |
| 304 } | 305 } |
| 305 | 306 |
| 306 } // namespace content | 307 } // namespace content |
| OLD | NEW |