diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 22:30:47 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 22:30:47 +0000 |
commit | 3a3e5b3c585d110766921a79997b4c6ab8a49440 (patch) | |
tree | 2969b47e71db438b56b572cd8b5e37ab3d818fa4 /chrome/renderer/renderer_main_platform_delegate_mac.mm | |
parent | fe474ed7f9eee2c666a3be32336c359c67d40fc4 (diff) | |
download | chromium_src-3a3e5b3c585d110766921a79997b4c6ab8a49440.zip chromium_src-3a3e5b3c585d110766921a79997b4c6ab8a49440.tar.gz chromium_src-3a3e5b3c585d110766921a79997b4c6ab8a49440.tar.bz2 |
Some tweaks to the OS X Sandbox:
* Fix 10.6 bug where garbled text was displayed due to insuccesful font loading.
* Tightened down the Sandbox a bit, instead of allowing access to /System/Library limit it to certain subdirectories.
* Remove unused warmup code now that we allow sysctl-read.
BUG=11269
BUG=b/1853366
TEST=On 10.6, copy Arial.ttf from /System/Library/Fonts to ~/Library/Fonts , Launch Chrome. Text on NTP should be displayed normally and not garbled.
Review URL: http://codereview.chromium.org/174254
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24030 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/renderer_main_platform_delegate_mac.mm')
-rw-r--r-- | chrome/renderer/renderer_main_platform_delegate_mac.mm | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/chrome/renderer/renderer_main_platform_delegate_mac.mm b/chrome/renderer/renderer_main_platform_delegate_mac.mm index c194d7d..a165909 100644 --- a/chrome/renderer/renderer_main_platform_delegate_mac.mm +++ b/chrome/renderer/renderer_main_platform_delegate_mac.mm @@ -54,7 +54,7 @@ void SandboxWarmup() { } { // [-NSColor colorUsingColorSpaceName] - 10.5.6 - NSColor *color = [NSColor controlTextColor]; + NSColor* color = [NSColor controlTextColor]; [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; } @@ -63,10 +63,16 @@ void SandboxWarmup() { localtime(&tv); } + { // Gestalt() tries to read /System/Library/CoreServices/SystemVersion.plist + // on 10.5.6 + int32 tmp; + base::SysInfo::OperatingSystemVersionNumbers(&tmp, &tmp, &tmp); + } + { // CGImageSourceGetStatus() - 10.6 seed release. // Create a png with just enough data to get everything warmed up... char png_header[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; - NSData *data = [NSData dataWithBytes:png_header + NSData* data = [NSData dataWithBytes:png_header length:arraysize(png_header)]; scoped_cftyperef<CGImageSourceRef> img( CGImageSourceCreateWithData((CFDataRef)data, @@ -86,7 +92,7 @@ void RendererMainPlatformDelegate::PlatformInitialize() { SandboxWarmup(); if (![NSThread isMultiThreaded]) { - NSString *string = @""; + NSString* string = @""; [NSThread detachNewThreadSelector:@selector(length) toTarget:string withObject:nil]; @@ -105,31 +111,28 @@ bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { } bool RendererMainPlatformDelegate::EnableSandbox() { - - // TODO(jeremy): Remove BeingDebugged() and CacheSysInfo() calls. They are - // no longer required since the sandbox now allows sysctl() reads. - - // This call doesn't work when the sandbox is enabled, the implementation - // caches it's return value so we call it here and then future calls will - // succeed. - DebugUtil::BeingDebugged(); - - // For the renderer, we give it a custom sandbox to lock down as tight as - // possible, but still be able to draw. - + // For the renderer, we give it a custom sandbox to lock things down as + // tightly as possible, while still enabling drawing. NSString* sandbox_profile_path = [mac_util::MainAppBundle() pathForResource:@"renderer" ofType:@"sb"]; - BOOL is_dir = NO; - if (![[NSFileManager defaultManager] fileExistsAtPath:sandbox_profile_path - isDirectory:&is_dir] || is_dir) { + NSString* sandbox_data = [NSString + stringWithContentsOfFile:sandbox_profile_path + encoding:NSUTF8StringEncoding + error:nil]; + + if (!sandbox_data) { LOG(ERROR) << "Failed to find the sandbox profile on disk"; return false; } - const char *sandbox_profile = [sandbox_profile_path fileSystemRepresentation]; + // Splice the path of the user's home directory into the sandbox profile + // (see renderer.sb for details). + sandbox_data = [sandbox_data + stringByReplacingOccurrencesOfString:@"USER_HOMEDIR" + withString:NSHomeDirectory()]; + char* error_buff = NULL; - int error = sandbox_init(sandbox_profile, SANDBOX_NAMED_EXTERNAL, - &error_buff); + int error = sandbox_init([sandbox_data UTF8String], 0, &error_buff); bool success = (error == 0 && error_buff == NULL); if (error == -1) { LOG(ERROR) << "Failed to Initialize Sandbox: " << error_buff; |