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_child = SpawnChild("mac_sandbox_path_access"); |
43 if (!child_process.IsValid()) { | 43 if (!spawn_child.process.IsValid()) { |
44 LOG(WARNING) << "SpawnChild failed"; | 44 LOG(WARNING) << "SpawnChild failed"; |
45 return false; | 45 return false; |
46 } | 46 } |
47 int code = -1; | 47 int code = -1; |
48 if (!child_process.WaitForExit(&code)) { | 48 if (!spawn_child.process.WaitForExit(&code)) { |
49 LOG(WARNING) << "Process::WaitForExit failed"; | 49 LOG(WARNING) << "Process::WaitForExit failed"; |
50 return false; | 50 return false; |
51 } | 51 } |
52 return code == 0; | 52 return code == 0; |
53 } | 53 } |
54 }; | 54 }; |
55 | 55 |
56 TEST_F(MacDirAccessSandboxTest, StringEscape) { | 56 TEST_F(MacDirAccessSandboxTest, StringEscape) { |
57 const struct string_escape_test_data { | 57 const struct string_escape_test_data { |
58 const char* to_escape; | 58 const char* to_escape; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 PLOG(ERROR) << "Sandbox breach: was able to write (" | 297 PLOG(ERROR) << "Sandbox breach: was able to write (" |
298 << denied_file2.value() | 298 << denied_file2.value() |
299 << ")"; | 299 << ")"; |
300 return -1; | 300 return -1; |
301 } | 301 } |
302 | 302 |
303 return 0; | 303 return 0; |
304 } | 304 } |
305 | 305 |
306 } // namespace content | 306 } // namespace content |
OLD | NEW |