| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 7 |
| 8 extern "C" { | 8 extern "C" { |
| 9 #include <sandbox.h> | 9 #include <sandbox.h> |
| 10 } | 10 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // Tests need to be in the same namespace as the sandbox::Sandbox class to be | 28 // Tests need to be in the same namespace as the sandbox::Sandbox class to be |
| 29 // useable with FRIEND_TEST() declaration. | 29 // useable with FRIEND_TEST() declaration. |
| 30 namespace sandbox { | 30 namespace sandbox { |
| 31 | 31 |
| 32 class MacDirAccessSandboxTest : public base::MultiProcessTest { | 32 class MacDirAccessSandboxTest : public base::MultiProcessTest { |
| 33 public: | 33 public: |
| 34 bool CheckSandbox(const std::string& directory_to_try) { | 34 bool CheckSandbox(const std::string& directory_to_try) { |
| 35 setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1); | 35 setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1); |
| 36 base::ProcessHandle child_process = SpawnChild("mac_sandbox_path_access", | 36 base::ProcessHandle child_process = SpawnChild("mac_sandbox_path_access", |
| 37 false); | 37 false); |
| 38 if (child_process == base::kNullProcessHandle) { |
| 39 LOG(WARNING) << "SpawnChild failed"; |
| 40 return false; |
| 41 } |
| 38 int code = -1; | 42 int code = -1; |
| 39 if (!base::WaitForExitCode(child_process, &code)) { | 43 if (!base::WaitForExitCode(child_process, &code)) { |
| 40 LOG(WARNING) << "base::WaitForExitCode failed"; | 44 LOG(WARNING) << "base::WaitForExitCode failed"; |
| 41 return false; | 45 return false; |
| 42 } | 46 } |
| 43 return code == 0; | 47 return code == 0; |
| 44 } | 48 } |
| 45 }; | 49 }; |
| 46 | 50 |
| 47 TEST_F(MacDirAccessSandboxTest, StringEscape) { | 51 TEST_F(MacDirAccessSandboxTest, StringEscape) { |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 PLOG(ERROR) << "Sandbox breach: was able to write (" | 299 PLOG(ERROR) << "Sandbox breach: was able to write (" |
| 296 << denied_file2.value() | 300 << denied_file2.value() |
| 297 << ")"; | 301 << ")"; |
| 298 return -1; | 302 return -1; |
| 299 } | 303 } |
| 300 | 304 |
| 301 return 0; | 305 return 0; |
| 302 } | 306 } |
| 303 | 307 |
| 304 } // namespace sandbox | 308 } // namespace sandbox |
| OLD | NEW |