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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 if (x) { | 138 if (x) { |
139 base::DeleteFile(*x, true); | 139 base::DeleteFile(*x, true); |
140 } | 140 } |
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 base::CreateDirectory; |
149 | 149 |
150 base::FilePath tmp_dir; | 150 base::FilePath tmp_dir; |
151 ASSERT_TRUE(base::CreateNewTempDirectory(base::FilePath::StringType(), | 151 ASSERT_TRUE(base::CreateNewTempDirectory(base::FilePath::StringType(), |
152 &tmp_dir)); | 152 &tmp_dir)); |
153 // 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" |
154 // paths and the paths CreateNewTempDirectory() returns are empirically in | 154 // paths and the paths CreateNewTempDirectory() returns are empirically in |
155 // /var which is a symlink to /private/var . | 155 // /var which is a symlink to /private/var . |
156 tmp_dir = Sandbox::GetCanonicalSandboxPath(tmp_dir); | 156 tmp_dir = Sandbox::GetCanonicalSandboxPath(tmp_dir); |
157 ScopedDirectory cleanup(&tmp_dir); | 157 ScopedDirectory cleanup(&tmp_dir); |
158 | 158 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 PLOG(ERROR) << "Sandbox breach: was able to write (" | 303 PLOG(ERROR) << "Sandbox breach: was able to write (" |
304 << denied_file2.value() | 304 << denied_file2.value() |
305 << ")"; | 305 << ")"; |
306 return -1; | 306 return -1; |
307 } | 307 } |
308 | 308 |
309 return 0; | 309 return 0; |
310 } | 310 } |
311 | 311 |
312 } // namespace content | 312 } // namespace content |
OLD | NEW |