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 #include "content/common/sandbox_mac.h" | 5 #include "content/common/sandbox_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 extern "C" { | 9 extern "C" { |
10 #include <sandbox.h> | 10 #include <sandbox.h> |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 CGImageSourceGetStatus(img); | 264 CGImageSourceGetStatus(img); |
265 } | 265 } |
266 | 266 |
267 { | 267 { |
268 // Allow access to /dev/urandom. | 268 // Allow access to /dev/urandom. |
269 GetUrandomFD(); | 269 GetUrandomFD(); |
270 } | 270 } |
271 | 271 |
272 // Process-type dependent warm-up. | 272 // Process-type dependent warm-up. |
273 if (sandbox_type == content::SANDBOX_TYPE_GPU) { | 273 if (sandbox_type == content::SANDBOX_TYPE_GPU) { |
274 // Preload either the desktop GL or the osmesa so, depending on the | 274 // Preload either the desktop GL or the osmesa so, depending on the |
275 // --use-gl flag. | 275 // --use-gl flag. |
276 gfx::GLSurface::InitializeOneOff(); | 276 gfx::GLSurface::InitializeOneOff(); |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 // static | 280 // static |
281 NSString* Sandbox::BuildAllowDirectoryAccessSandboxString( | 281 NSString* Sandbox::BuildAllowDirectoryAccessSandboxString( |
282 const FilePath& allowed_dir, | 282 const FilePath& allowed_dir, |
283 SandboxVariableSubstitions* substitutions) { | 283 SandboxVariableSubstitions* substitutions) { |
284 // A whitelist is used to determine which directories can be statted | 284 // A whitelist is used to determine which directories can be statted |
285 // This means that in the case of an /a/b/c/d/ directory, we may be able to | 285 // This means that in the case of an /a/b/c/d/ directory, we may be able to |
286 // stat the leaf directory, but not its parent. | 286 // stat the leaf directory, but not its parent. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 if (common_sandbox_definition.empty()) { | 378 if (common_sandbox_definition.empty()) { |
379 LOG(FATAL) << "Failed to load the common sandbox profile"; | 379 LOG(FATAL) << "Failed to load the common sandbox profile"; |
380 return nil; | 380 return nil; |
381 } | 381 } |
382 | 382 |
383 scoped_nsobject<NSString> common_sandbox_prefix_data( | 383 scoped_nsobject<NSString> common_sandbox_prefix_data( |
384 [[NSString alloc] initWithBytes:common_sandbox_definition.data() | 384 [[NSString alloc] initWithBytes:common_sandbox_definition.data() |
385 length:common_sandbox_definition.length() | 385 length:common_sandbox_definition.length() |
386 encoding:NSUTF8StringEncoding]); | 386 encoding:NSUTF8StringEncoding]); |
387 | 387 |
388 #if defined(COMPONENT_BUILD) | |
389 // dlopen() fails without file-read-metadata access if the executable image | |
390 // contains LC_RPATH load commands. The components build uses those. | |
391 // See http://crbug.com/127465 | |
392 if (base::mac::IsOSSnowLeopardOrEarlier()) { | |
393 NSString* suffixed = [common_sandbox_prefix_data | |
394 stringByAppendingString:@"\n(allow file-read-metadata)\n"]; | |
jeremy
2012/05/30 16:33:17
Please move these lines to the Sandbox definition
Nico
2012/05/30 16:38:33
See bug, it needs file-read-metadata for the curre
| |
395 common_sandbox_prefix_data.reset([suffixed retain]); | |
396 } | |
397 #endif | |
398 | |
388 scoped_nsobject<NSString> sandbox_data( | 399 scoped_nsobject<NSString> sandbox_data( |
389 [[NSString alloc] initWithBytes:sandbox_definition.data() | 400 [[NSString alloc] initWithBytes:sandbox_definition.data() |
390 length:sandbox_definition.length() | 401 length:sandbox_definition.length() |
391 encoding:NSUTF8StringEncoding]); | 402 encoding:NSUTF8StringEncoding]); |
392 | 403 |
393 // Prefix sandbox_data with common_sandbox_prefix_data. | 404 // Prefix sandbox_data with common_sandbox_prefix_data. |
394 return [common_sandbox_prefix_data stringByAppendingString:sandbox_data]; | 405 return [common_sandbox_prefix_data stringByAppendingString:sandbox_data]; |
395 } | 406 } |
396 | 407 |
397 // static | 408 // static |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) { | 589 if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) { |
579 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " | 590 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " |
580 << path->value(); | 591 << path->value(); |
581 return; | 592 return; |
582 } | 593 } |
583 | 594 |
584 *path = FilePath(canonical_path); | 595 *path = FilePath(canonical_path); |
585 } | 596 } |
586 | 597 |
587 } // namespace sandbox | 598 } // namespace sandbox |
OLD | NEW |