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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 141 } |
142 }; | 142 }; |
143 | 143 |
144 typedef scoped_ptr_malloc<base::FilePath, ScopedDirectoryDelete> | 144 typedef scoped_ptr_malloc<base::FilePath, ScopedDirectoryDelete> |
145 ScopedDirectory; | 145 ScopedDirectory; |
146 | 146 |
147 TEST_F(MacDirAccessSandboxTest, SandboxAccess) { | 147 TEST_F(MacDirAccessSandboxTest, SandboxAccess) { |
148 using file_util::CreateDirectory; | 148 using file_util::CreateDirectory; |
149 | 149 |
150 base::FilePath tmp_dir; | 150 base::FilePath tmp_dir; |
151 ASSERT_TRUE(file_util::CreateNewTempDirectory("", &tmp_dir)); | 151 ASSERT_TRUE(base::CreateNewTempDirectory(base::FilePath::StringType(), |
| 152 &tmp_dir)); |
152 // This step is important on OS X since the sandbox only understands "real" | 153 // This step is important on OS X since the sandbox only understands "real" |
153 // paths and the paths CreateNewTempDirectory() returns are empirically in | 154 // paths and the paths CreateNewTempDirectory() returns are empirically in |
154 // /var which is a symlink to /private/var . | 155 // /var which is a symlink to /private/var . |
155 tmp_dir = Sandbox::GetCanonicalSandboxPath(tmp_dir); | 156 tmp_dir = Sandbox::GetCanonicalSandboxPath(tmp_dir); |
156 ScopedDirectory cleanup(&tmp_dir); | 157 ScopedDirectory cleanup(&tmp_dir); |
157 | 158 |
158 const char* sandbox_dir_cases[] = { | 159 const char* sandbox_dir_cases[] = { |
159 "simple_dir_name", | 160 "simple_dir_name", |
160 "^hello++ $", // Regex. | 161 "^hello++ $", // Regex. |
161 "\\^.$|()[]*+?{}", // All regex characters. | 162 "\\^.$|()[]*+?{}", // All regex characters. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 PLOG(ERROR) << "Sandbox breach: was able to write (" | 303 PLOG(ERROR) << "Sandbox breach: was able to write (" |
303 << denied_file2.value() | 304 << denied_file2.value() |
304 << ")"; | 305 << ")"; |
305 return -1; | 306 return -1; |
306 } | 307 } |
307 | 308 |
308 return 0; | 309 return 0; |
309 } | 310 } |
310 | 311 |
311 } // namespace content | 312 } // namespace content |
OLD | NEW |