OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/renderer/renderer_main_platform_delegate.h" | 5 #include "chrome/renderer/renderer_main_platform_delegate.h" |
6 | 6 |
| 7 #include <stdlib.h> |
| 8 |
7 #include "base/debug_util.h" | 9 #include "base/debug_util.h" |
| 10 #include "base/eintr_wrapper.h" |
8 | 11 |
9 // This is a no op class because we do not have a sandbox on linux. | 12 // This is a no op class because we do not have a sandbox on linux. |
10 | 13 |
11 RendererMainPlatformDelegate::RendererMainPlatformDelegate( | 14 RendererMainPlatformDelegate::RendererMainPlatformDelegate( |
12 const MainFunctionParams& parameters) | 15 const MainFunctionParams& parameters) |
13 : parameters_(parameters) { | 16 : parameters_(parameters) { |
14 } | 17 } |
15 | 18 |
16 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { | 19 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { |
17 } | 20 } |
18 | 21 |
| 22 extern void SkiaFontConfigUseIPCImplementation(int fd); |
| 23 extern void SkiaFontConfigUseDirectImplementation(); |
| 24 |
19 void RendererMainPlatformDelegate::PlatformInitialize() { | 25 void RendererMainPlatformDelegate::PlatformInitialize() { |
20 } | 26 } |
21 | 27 |
22 void RendererMainPlatformDelegate::PlatformUninitialize() { | 28 void RendererMainPlatformDelegate::PlatformUninitialize() { |
23 } | 29 } |
24 | 30 |
25 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { | 31 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { |
26 // We have no sandbox. | 32 // Our sandbox support is in the very early stages |
27 // http://code.google.com/p/chromium/issues/detail?id=8081 | 33 // http://code.google.com/p/chromium/issues/detail?id=8081 |
28 return true; | 34 return true; |
29 } | 35 } |
30 | 36 |
31 bool RendererMainPlatformDelegate::EnableSandbox() { | 37 bool RendererMainPlatformDelegate::EnableSandbox() { |
32 // We have no sandbox. | 38 // Our sandbox support is in the very early stages |
33 // http://code.google.com/p/chromium/issues/detail?id=8081 | 39 // http://code.google.com/p/chromium/issues/detail?id=8081 |
| 40 |
| 41 const char* const sandbox_fd_string = getenv("SBX_D"); |
| 42 if (sandbox_fd_string) { |
| 43 // The SUID sandbox sets this environment variable to a file descriptor |
| 44 // over which we can signal that we have completed our startup and can be |
| 45 // chrooted. |
| 46 |
| 47 char* endptr; |
| 48 const long fd_long = strtol(sandbox_fd_string, &endptr, 10); |
| 49 if (!*sandbox_fd_string || *endptr || fd_long < 0 || fd_long > INT_MAX) |
| 50 return false; |
| 51 const int fd = fd_long; |
| 52 |
| 53 static const char kChrootMe = 'C'; |
| 54 static const char kChrootMeSuccess = 'O'; |
| 55 |
| 56 if (HANDLE_EINTR(write(fd, &kChrootMe, 1)) != 1) |
| 57 return false; |
| 58 |
| 59 char reply; |
| 60 if (HANDLE_EINTR(read(fd, &reply, 1)) != 1) |
| 61 return false; |
| 62 if (reply != kChrootMeSuccess) |
| 63 return false; |
| 64 if (chdir("/") == -1) |
| 65 return false; |
| 66 |
| 67 static const int kMagicSandboxIPCDescriptor = 5; |
| 68 SkiaFontConfigUseIPCImplementation(kMagicSandboxIPCDescriptor); |
| 69 } else { |
| 70 SkiaFontConfigUseDirectImplementation(); |
| 71 } |
| 72 |
34 return true; | 73 return true; |
35 } | 74 } |
36 | 75 |
37 void RendererMainPlatformDelegate::RunSandboxTests() { | 76 void RendererMainPlatformDelegate::RunSandboxTests() { |
38 // We have no sandbox. | 77 // Our sandbox support is in the very early stages |
39 // http://code.google.com/p/chromium/issues/detail?id=8081 | 78 // http://code.google.com/p/chromium/issues/detail?id=8081 |
40 } | 79 } |
OLD | NEW |