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

Side by Side Diff: chrome/browser/renderer_host/render_sandbox_host_linux.cc

Issue 155783: Linux sandbox: plumb timezone calls through the sandbox (Closed)
Patch Set: ... Created 11 years, 5 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 | « no previous file | chrome/browser/zygote_main_linux.cc » ('j') | chrome/browser/zygote_main_linux.cc » ('J')
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 13
13 #include "base/eintr_wrapper.h" 14 #include "base/eintr_wrapper.h"
14 #include "base/process_util.h" 15 #include "base/process_util.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/message_loop.h" 17 #include "base/message_loop.h"
17 #include "base/pickle.h" 18 #include "base/pickle.h"
18 #include "base/string_util.h" 19 #include "base/string_util.h"
19 #include "base/unix_domain_socket_posix.h" 20 #include "base/unix_domain_socket_posix.h"
20 #include "chrome/common/sandbox_methods_linux.h" 21 #include "chrome/common/sandbox_methods_linux.h"
21 #include "webkit/api/public/gtk/WebFontInfo.h" 22 #include "webkit/api/public/gtk/WebFontInfo.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 int kind; 170 int kind;
170 if (!pickle.ReadInt(&iter, &kind)) 171 if (!pickle.ReadInt(&iter, &kind))
171 goto error; 172 goto error;
172 173
173 if (kind == FontConfigIPC::METHOD_MATCH) { 174 if (kind == FontConfigIPC::METHOD_MATCH) {
174 HandleFontMatchRequest(fd, pickle, iter, fds); 175 HandleFontMatchRequest(fd, pickle, iter, fds);
175 } else if (kind == FontConfigIPC::METHOD_OPEN) { 176 } else if (kind == FontConfigIPC::METHOD_OPEN) {
176 HandleFontOpenRequest(fd, pickle, iter, fds); 177 HandleFontOpenRequest(fd, pickle, iter, fds);
177 } else if (kind == LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS) { 178 } else if (kind == LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS) {
178 HandleGetFontFamilyForChars(fd, pickle, iter, fds); 179 HandleGetFontFamilyForChars(fd, pickle, iter, fds);
180 } else if (kind == LinuxSandbox::METHOD_LOCALTIME) {
181 HandleLocaltime(fd, pickle, iter, fds);
179 } 182 }
180 183
181 error: 184 error:
182 for (std::vector<int>::const_iterator 185 for (std::vector<int>::const_iterator
183 i = fds.begin(); i != fds.end(); ++i) { 186 i = fds.begin(); i != fds.end(); ++i) {
184 close(*i); 187 close(*i);
185 } 188 }
186 } 189 }
187 190
188 void HandleFontMatchRequest(int fd, Pickle& pickle, void* iter, 191 void HandleFontMatchRequest(int fd, Pickle& pickle, void* iter,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 277 }
275 278
276 const WebString family = WebFontInfo::familyForChars(chars.get(), num_chars) ; 279 const WebString family = WebFontInfo::familyForChars(chars.get(), num_chars) ;
277 const std::string family_utf8 = UTF16ToUTF8(family); 280 const std::string family_utf8 = UTF16ToUTF8(family);
278 281
279 Pickle reply; 282 Pickle reply;
280 reply.WriteString(family_utf8); 283 reply.WriteString(family_utf8);
281 SendRendererReply(fds, reply, -1); 284 SendRendererReply(fds, reply, -1);
282 } 285 }
283 286
287 void HandleLocaltime(int fd, Pickle& pickle, void* iter,
288 std::vector<int>& fds) {
289 // The other side of this call is in zygote_main_linux.cc
290
291 std::string time_string;
292 if (!pickle.ReadString(&iter, &time_string) ||
293 time_string.size() != sizeof(time_t)) {
294 return;
295 }
296
297 time_t time;
298 memcpy(&time, time_string.data(), sizeof(time));
299 struct tm expanded_time;
300 localtime_r(&time, &expanded_time);
301
302 const std::string result_string(reinterpret_cast<char*>(&expanded_time),
303 sizeof(expanded_time));
304
305 Pickle reply;
306 reply.WriteString(result_string);
307 SendRendererReply(fds, reply, -1);
308 }
309
284 void SendRendererReply(const std::vector<int>& fds, const Pickle& reply, 310 void SendRendererReply(const std::vector<int>& fds, const Pickle& reply,
285 int reply_fd) { 311 int reply_fd) {
286 struct msghdr msg; 312 struct msghdr msg;
287 memset(&msg, 0, sizeof(msg)); 313 memset(&msg, 0, sizeof(msg));
288 struct iovec iov = {const_cast<void*>(reply.data()), reply.size()}; 314 struct iovec iov = {const_cast<void*>(reply.data()), reply.size()};
289 msg.msg_iov = &iov; 315 msg.msg_iov = &iov;
290 msg.msg_iovlen = 1; 316 msg.msg_iovlen = 1;
291 317
292 char control_buffer[CMSG_SPACE(sizeof(int))]; 318 char control_buffer[CMSG_SPACE(sizeof(int))];
293 319
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 SandboxIPCProcess handler(child_lifeline_fd, browser_socket); 360 SandboxIPCProcess handler(child_lifeline_fd, browser_socket);
335 handler.Run(); 361 handler.Run();
336 _exit(0); 362 _exit(0);
337 } 363 }
338 } 364 }
339 365
340 RenderSandboxHostLinux::~RenderSandboxHostLinux() { 366 RenderSandboxHostLinux::~RenderSandboxHostLinux() {
341 HANDLE_EINTR(close(renderer_socket_)); 367 HANDLE_EINTR(close(renderer_socket_));
342 HANDLE_EINTR(close(childs_lifeline_fd_)); 368 HANDLE_EINTR(close(childs_lifeline_fd_));
343 } 369 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/zygote_main_linux.cc » ('j') | chrome/browser/zygote_main_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698