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