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

Side by Side Diff: chrome/browser/renderer_host/render_sandbox_host_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 | « base/rand_util_posix.cc ('k') | chrome/common/sandbox_methods_linux.h » ('j') | 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. 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/browser/renderer_host/render_sandbox_host_linux.h" 5 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 #include <sys/uio.h> 9 #include <sys/uio.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
11 #include <sys/poll.h> 11 #include <sys/poll.h>
12 #include <time.h> 12 #include <time.h>
13 13
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/eintr_wrapper.h" 17 #include "base/eintr_wrapper.h"
18 #include "base/linux_util.h" 18 #include "base/linux_util.h"
19 #include "base/pickle.h" 19 #include "base/pickle.h"
20 #include "base/process_util.h" 20 #include "base/process_util.h"
21 #include "base/scoped_ptr.h" 21 #include "base/scoped_ptr.h"
22 #include "base/shared_memory.h"
22 #include "base/string_util.h" 23 #include "base/string_util.h"
23 #include "base/unix_domain_socket_posix.h" 24 #include "base/unix_domain_socket_posix.h"
24 #include "chrome/common/sandbox_methods_linux.h" 25 #include "chrome/common/sandbox_methods_linux.h"
25 #include "third_party/WebKit/WebKit/chromium/public/gtk/WebFontInfo.h" 26 #include "third_party/WebKit/WebKit/chromium/public/gtk/WebFontInfo.h"
26 27
27 #include "SkFontHost_fontconfig_direct.h" 28 #include "SkFontHost_fontconfig_direct.h"
28 #include "SkFontHost_fontconfig_ipc.h" 29 #include "SkFontHost_fontconfig_ipc.h"
29 30
30 using WebKit::WebCString; 31 using WebKit::WebCString;
31 using WebKit::WebFontInfo; 32 using WebKit::WebFontInfo;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } else if (kind == FontConfigIPC::METHOD_OPEN) { 130 } else if (kind == FontConfigIPC::METHOD_OPEN) {
130 HandleFontOpenRequest(fd, pickle, iter, fds); 131 HandleFontOpenRequest(fd, pickle, iter, fds);
131 } else if (kind == LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS) { 132 } else if (kind == LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS) {
132 HandleGetFontFamilyForChars(fd, pickle, iter, fds); 133 HandleGetFontFamilyForChars(fd, pickle, iter, fds);
133 } else if (kind == LinuxSandbox::METHOD_LOCALTIME) { 134 } else if (kind == LinuxSandbox::METHOD_LOCALTIME) {
134 HandleLocaltime(fd, pickle, iter, fds); 135 HandleLocaltime(fd, pickle, iter, fds);
135 } else if (kind == LinuxSandbox::METHOD_GET_CHILD_WITH_INODE) { 136 } else if (kind == LinuxSandbox::METHOD_GET_CHILD_WITH_INODE) {
136 HandleGetChildWithInode(fd, pickle, iter, fds); 137 HandleGetChildWithInode(fd, pickle, iter, fds);
137 } else if (kind == LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE) { 138 } else if (kind == LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE) {
138 HandleGetStyleForStrike(fd, pickle, iter, fds); 139 HandleGetStyleForStrike(fd, pickle, iter, fds);
140 } else if (kind == LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT) {
141 HandleMakeSharedMemorySegment(fd, pickle, iter, fds);
139 } 142 }
140 143
141 error: 144 error:
142 for (std::vector<int>::const_iterator 145 for (std::vector<int>::const_iterator
143 i = fds.begin(); i != fds.end(); ++i) { 146 i = fds.begin(); i != fds.end(); ++i) {
144 close(*i); 147 close(*i);
145 } 148 }
146 } 149 }
147 150
148 void HandleFontMatchRequest(int fd, const Pickle& pickle, void* iter, 151 void HandleFontMatchRequest(int fd, const Pickle& pickle, void* iter,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 if (!pid) { 325 if (!pid) {
323 LOG(ERROR) << "Could not get pid"; 326 LOG(ERROR) << "Could not get pid";
324 return; 327 return;
325 } 328 }
326 329
327 Pickle reply; 330 Pickle reply;
328 reply.WriteInt(pid); 331 reply.WriteInt(pid);
329 SendRendererReply(fds, reply, -1); 332 SendRendererReply(fds, reply, -1);
330 } 333 }
331 334
335 void HandleMakeSharedMemorySegment(int fd, const Pickle& pickle, void* iter,
336 std::vector<int>& fds) {
337 uint32_t shm_size;
338 if (!pickle.ReadUInt32(&iter, &shm_size))
339 return;
340 int shm_fd = -1;
341 base::SharedMemory shm;
342 if (shm.Create(L"", false, false, shm_size))
343 shm_fd = shm.handle().fd;
344 Pickle reply;
345 SendRendererReply(fds, reply, shm_fd);
346 }
347
332 void SendRendererReply(const std::vector<int>& fds, const Pickle& reply, 348 void SendRendererReply(const std::vector<int>& fds, const Pickle& reply,
333 int reply_fd) { 349 int reply_fd) {
334 struct msghdr msg; 350 struct msghdr msg;
335 memset(&msg, 0, sizeof(msg)); 351 memset(&msg, 0, sizeof(msg));
336 struct iovec iov = {const_cast<void*>(reply.data()), reply.size()}; 352 struct iovec iov = {const_cast<void*>(reply.data()), reply.size()};
337 msg.msg_iov = &iov; 353 msg.msg_iov = &iov;
338 msg.msg_iovlen = 1; 354 msg.msg_iovlen = 1;
339 355
340 char control_buffer[CMSG_SPACE(sizeof(int))]; 356 char control_buffer[CMSG_SPACE(sizeof(int))];
341 357
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 _exit(0); 414 _exit(0);
399 } 415 }
400 } 416 }
401 417
402 RenderSandboxHostLinux::~RenderSandboxHostLinux() { 418 RenderSandboxHostLinux::~RenderSandboxHostLinux() {
403 if (init_) { 419 if (init_) {
404 HANDLE_EINTR(close(renderer_socket_)); 420 HANDLE_EINTR(close(renderer_socket_));
405 HANDLE_EINTR(close(childs_lifeline_fd_)); 421 HANDLE_EINTR(close(childs_lifeline_fd_));
406 } 422 }
407 } 423 }
OLDNEW
« no previous file with comments | « base/rand_util_posix.cc ('k') | chrome/common/sandbox_methods_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698