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