Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(904)

Side by Side Diff: chrome/renderer/renderer_sandbox_support_linux.cc

Issue 669055: Add support for running the NaCl plugin in the Linux SUID sandbox (Closed)
Patch Set: Removed tab char; removed change to test (which assumed the NaCl-side change) Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/renderer_sandbox_support_linux.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "chrome/renderer/renderer_sandbox_support_linux.h" 5 #include "chrome/renderer/renderer_sandbox_support_linux.h"
6 6
7 #include "base/global_descriptors_posix.h" 7 #include "base/global_descriptors_posix.h"
8 #include "base/pickle.h" 8 #include "base/pickle.h"
9 #include "base/unix_domain_socket_posix.h" 9 #include "base/unix_domain_socket_posix.h"
10 #include "chrome/common/chrome_descriptors.h" 10 #include "chrome/common/chrome_descriptors.h"
11 #include "chrome/common/sandbox_methods_linux.h" 11 #include "chrome/common/sandbox_methods_linux.h"
12 12
13 #include "third_party/WebKit/WebKit/chromium/public/linux/WebFontRenderStyle.h" 13 #include "third_party/WebKit/WebKit/chromium/public/linux/WebFontRenderStyle.h"
14 14
15 static int GetSandboxFD() {
16 return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor;
17 }
18
15 namespace renderer_sandbox_support { 19 namespace renderer_sandbox_support {
16 20
17 std::string getFontFamilyForCharacters(const uint16_t* utf16, size_t num_utf16) { 21 std::string getFontFamilyForCharacters(const uint16_t* utf16, size_t num_utf16) {
18 Pickle request; 22 Pickle request;
19 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS); 23 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS);
20 request.WriteInt(num_utf16); 24 request.WriteInt(num_utf16);
21 for (size_t i = 0; i < num_utf16; ++i) 25 for (size_t i = 0; i < num_utf16; ++i)
22 request.WriteUInt32(utf16[i]); 26 request.WriteUInt32(utf16[i]);
23 27
24 uint8_t buf[512]; 28 uint8_t buf[512];
25 const int sandbox_fd = 29 const ssize_t n = base::SendRecvMsg(GetSandboxFD(), buf, sizeof(buf), NULL,
26 kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor;
27 const ssize_t n = base::SendRecvMsg(sandbox_fd, buf, sizeof(buf), NULL,
28 request); 30 request);
29 31
30 std::string family_name; 32 std::string family_name;
31 if (n != -1) { 33 if (n != -1) {
32 Pickle reply(reinterpret_cast<char*>(buf), n); 34 Pickle reply(reinterpret_cast<char*>(buf), n);
33 void* pickle_iter = NULL; 35 void* pickle_iter = NULL;
34 reply.ReadString(&pickle_iter, &family_name); 36 reply.ReadString(&pickle_iter, &family_name);
35 } 37 }
36 38
37 return family_name; 39 return family_name;
38 } 40 }
39 41
40 void getRenderStyleForStrike(const char* family, int sizeAndStyle, 42 void getRenderStyleForStrike(const char* family, int sizeAndStyle,
41 WebKit::WebFontRenderStyle* out) { 43 WebKit::WebFontRenderStyle* out) {
42 Pickle request; 44 Pickle request;
43 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE); 45 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE);
44 request.WriteString(family); 46 request.WriteString(family);
45 request.WriteInt(sizeAndStyle); 47 request.WriteInt(sizeAndStyle);
46 48
47 uint8_t buf[512]; 49 uint8_t buf[512];
48 const int sandbox_fd = 50 const ssize_t n = base::SendRecvMsg(GetSandboxFD(), buf, sizeof(buf), NULL,
49 kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor;
50 const ssize_t n = base::SendRecvMsg(sandbox_fd, buf, sizeof(buf), NULL,
51 request); 51 request);
52 52
53 out->setDefaults(); 53 out->setDefaults();
54 if (n == -1) { 54 if (n == -1) {
55 return; 55 return;
56 } 56 }
57 57
58 Pickle reply(reinterpret_cast<char*>(buf), n); 58 Pickle reply(reinterpret_cast<char*>(buf), n);
59 void* pickle_iter = NULL; 59 void* pickle_iter = NULL;
60 int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias, useSubpixel; 60 int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias, useSubpixel;
61 if (reply.ReadInt(&pickle_iter, &useBitmaps) && 61 if (reply.ReadInt(&pickle_iter, &useBitmaps) &&
62 reply.ReadInt(&pickle_iter, &useAutoHint) && 62 reply.ReadInt(&pickle_iter, &useAutoHint) &&
63 reply.ReadInt(&pickle_iter, &useHinting) && 63 reply.ReadInt(&pickle_iter, &useHinting) &&
64 reply.ReadInt(&pickle_iter, &hintStyle) && 64 reply.ReadInt(&pickle_iter, &hintStyle) &&
65 reply.ReadInt(&pickle_iter, &useAntiAlias) && 65 reply.ReadInt(&pickle_iter, &useAntiAlias) &&
66 reply.ReadInt(&pickle_iter, &useSubpixel)) { 66 reply.ReadInt(&pickle_iter, &useSubpixel)) {
67 out->useBitmaps = useBitmaps; 67 out->useBitmaps = useBitmaps;
68 out->useAutoHint = useAutoHint; 68 out->useAutoHint = useAutoHint;
69 out->useHinting = useHinting; 69 out->useHinting = useHinting;
70 out->hintStyle = hintStyle; 70 out->hintStyle = hintStyle;
71 out->useAntiAlias = useAntiAlias; 71 out->useAntiAlias = useAntiAlias;
72 out->useSubpixel = useSubpixel; 72 out->useSubpixel = useSubpixel;
73 } 73 }
74 } 74 }
75 75
76 int MakeSharedMemorySegmentViaIPC(size_t length) {
77 Pickle request;
78 request.WriteInt(LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT);
79 request.WriteUInt32(length);
80 uint8_t reply_buf[10];
81 int result_fd;
82 ssize_t result = base::SendRecvMsg(GetSandboxFD(),
83 reply_buf, sizeof(reply_buf),
84 &result_fd, request);
85 if (result == -1)
86 return -1;
87 return result_fd;
88 }
89
76 } // namespace render_sandbox_support 90 } // namespace render_sandbox_support
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_sandbox_support_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698