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

Side by Side Diff: content/zygote/zygote_main_linux.cc

Issue 23956010: Define magic descriptors in one place. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/zygote/zygote_main.h" 5 #include "content/zygote/zygote_main.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <pthread.h> 9 #include <pthread.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, 62 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output,
63 char* timezone_out, 63 char* timezone_out,
64 size_t timezone_out_len) { 64 size_t timezone_out_len) {
65 Pickle request; 65 Pickle request;
66 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); 66 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME);
67 request.WriteString( 67 request.WriteString(
68 std::string(reinterpret_cast<char*>(&input), sizeof(input))); 68 std::string(reinterpret_cast<char*>(&input), sizeof(input)));
69 69
70 uint8_t reply_buf[512]; 70 uint8_t reply_buf[512];
71 const ssize_t r = UnixDomainSocket::SendRecvMsg( 71 const ssize_t r = UnixDomainSocket::SendRecvMsg(
72 Zygote::kMagicSandboxIPCDescriptor, reply_buf, sizeof(reply_buf), NULL, 72 kMagicSandboxIPCDescriptor, reply_buf, sizeof(reply_buf), NULL,
73 request); 73 request);
74 if (r == -1) { 74 if (r == -1) {
75 memset(output, 0, sizeof(struct tm)); 75 memset(output, 0, sizeof(struct tm));
76 return; 76 return;
77 } 77 }
78 78
79 Pickle reply(reinterpret_cast<char*>(reply_buf), r); 79 Pickle reply(reinterpret_cast<char*>(reply_buf), r);
80 PickleIterator iter(reply); 80 PickleIterator iter(reply);
81 std::string result, timezone; 81 std::string result, timezone;
82 if (!reply.ReadString(&iter, &result) || 82 if (!reply.ReadString(&iter, &result) ||
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // is enabled. This does not necessarily exclude other types of sandboxing. 386 // is enabled. This does not necessarily exclude other types of sandboxing.
387 static bool EnterSandbox(sandbox::SetuidSandboxClient* setuid_sandbox, 387 static bool EnterSandbox(sandbox::SetuidSandboxClient* setuid_sandbox,
388 bool* using_suid_sandbox, bool* has_started_new_init) { 388 bool* using_suid_sandbox, bool* has_started_new_init) {
389 *using_suid_sandbox = false; 389 *using_suid_sandbox = false;
390 *has_started_new_init = false; 390 *has_started_new_init = false;
391 if (!setuid_sandbox) 391 if (!setuid_sandbox)
392 return false; 392 return false;
393 393
394 PreSandboxInit(); 394 PreSandboxInit();
395 SkFontConfigInterface::SetGlobal( 395 SkFontConfigInterface::SetGlobal(
396 new FontConfigIPC(Zygote::kMagicSandboxIPCDescriptor))->unref(); 396 new FontConfigIPC(kMagicSandboxIPCDescriptor))->unref();
397 397
398 if (setuid_sandbox->IsSuidSandboxChild()) { 398 if (setuid_sandbox->IsSuidSandboxChild()) {
399 // Use the SUID sandbox. This still allows the seccomp sandbox to 399 // Use the SUID sandbox. This still allows the seccomp sandbox to
400 // be enabled by the process later. 400 // be enabled by the process later.
401 *using_suid_sandbox = true; 401 *using_suid_sandbox = true;
402 402
403 if (!setuid_sandbox->IsSuidSandboxUpToDate()) { 403 if (!setuid_sandbox->IsSuidSandboxUpToDate()) {
404 LOG(WARNING) << "You are using a wrong version of the setuid binary!\n" 404 LOG(WARNING) << "You are using a wrong version of the setuid binary!\n"
405 "Please read " 405 "Please read "
406 "https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment." 406 "https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment."
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 459
460 LinuxSandbox* linux_sandbox = LinuxSandbox::GetInstance(); 460 LinuxSandbox* linux_sandbox = LinuxSandbox::GetInstance();
461 // This will pre-initialize the various sandboxes that need it. 461 // This will pre-initialize the various sandboxes that need it.
462 linux_sandbox->PreinitializeSandbox(); 462 linux_sandbox->PreinitializeSandbox();
463 463
464 sandbox::SetuidSandboxClient* setuid_sandbox = 464 sandbox::SetuidSandboxClient* setuid_sandbox =
465 linux_sandbox->setuid_sandbox_client(); 465 linux_sandbox->setuid_sandbox_client();
466 466
467 if (forkdelegate != NULL) { 467 if (forkdelegate != NULL) {
468 VLOG(1) << "ZygoteMain: initializing fork delegate"; 468 VLOG(1) << "ZygoteMain: initializing fork delegate";
469 forkdelegate->Init(Zygote::kMagicSandboxIPCDescriptor); 469 forkdelegate->Init(kMagicSandboxIPCDescriptor);
470 } else { 470 } else {
471 VLOG(1) << "ZygoteMain: fork delegate is NULL"; 471 VLOG(1) << "ZygoteMain: fork delegate is NULL";
472 } 472 }
473 473
474 // Turn on the sandbox. 474 // Turn on the sandbox.
475 bool using_suid_sandbox = false; 475 bool using_suid_sandbox = false;
476 bool has_started_new_init = false; 476 bool has_started_new_init = false;
477 477
478 if (!EnterSandbox(setuid_sandbox, 478 if (!EnterSandbox(setuid_sandbox,
479 &using_suid_sandbox, 479 &using_suid_sandbox,
(...skipping 10 matching lines...) Expand all
490 } 490 }
491 491
492 int sandbox_flags = linux_sandbox->GetStatus(); 492 int sandbox_flags = linux_sandbox->GetStatus();
493 493
494 Zygote zygote(sandbox_flags, forkdelegate); 494 Zygote zygote(sandbox_flags, forkdelegate);
495 // This function call can return multiple times, once per fork(). 495 // This function call can return multiple times, once per fork().
496 return zygote.ProcessRequests(); 496 return zygote.ProcessRequests();
497 } 497 }
498 498
499 } // namespace content 499 } // namespace content
OLDNEW
« content/common/zygote_commands_linux.h ('K') | « content/zygote/zygote_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698