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

Side by Side Diff: chrome/nacl/nacl_helper_linux.cc

Issue 10387218: Make GlobalDescriptors::MaybeGet return -1 when the key is not found. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing NaCl tests. Created 8 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 | Annotate | Revision Log
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 // A mini-zygote specifically for Native Client. 5 // A mini-zygote specifically for Native Client.
6 6
7 #include "chrome/common/nacl_helper_linux.h" 7 #include "chrome/common/nacl_helper_linux.h"
8 8
9 #include <errno.h> 9 #include <errno.h>
10 #include <link.h> 10 #include <link.h>
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #include <sys/socket.h> 13 #include <sys/socket.h>
14 #include <sys/types.h> 14 #include <sys/types.h>
15 15
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/at_exit.h" 19 #include "base/at_exit.h"
20 #include "base/command_line.h" 20 #include "base/command_line.h"
21 #include "base/eintr_wrapper.h" 21 #include "base/eintr_wrapper.h"
22 #include "base/global_descriptors_posix.h"
22 #include "base/logging.h" 23 #include "base/logging.h"
23 #include "base/message_loop.h" 24 #include "base/message_loop.h"
24 #include "base/posix/unix_domain_socket.h" 25 #include "base/posix/unix_domain_socket.h"
25 #include "base/rand_util.h" 26 #include "base/rand_util.h"
26 #include "chrome/nacl/nacl_listener.h" 27 #include "chrome/nacl/nacl_listener.h"
27 #include "crypto/nss_util.h" 28 #include "crypto/nss_util.h"
29 #include "ipc/ipc_descriptors.h"
28 #include "ipc/ipc_switches.h" 30 #include "ipc/ipc_switches.h"
29 #include "native_client/src/trusted/service_runtime/sel_addrspace.h" 31 #include "native_client/src/trusted/service_runtime/sel_addrspace.h"
30 32
31 namespace { 33 namespace {
32 34
33 bool g_suid_sandbox_active; 35 bool g_suid_sandbox_active;
34 36
35 // The child must mimic the behavior of zygote_main_linux.cc on the child 37 // The child must mimic the behavior of zygote_main_linux.cc on the child
36 // side of the fork. See zygote_main_linux.cc:HandleForkRequest from 38 // side of the fork. See zygote_main_linux.cc:HandleForkRequest from
37 // if (!child) { 39 // if (!child) {
38 // Note: this code doesn't attempt to support SELINUX or the SECCOMP sandbox. 40 // Note: this code doesn't attempt to support SELINUX or the SECCOMP sandbox.
39 void BecomeNaClLoader(const std::vector<int>& child_fds) { 41 void BecomeNaClLoader(const std::vector<int>& child_fds) {
40 VLOG(1) << "NaCl loader: setting up IPC descriptor"; 42 VLOG(1) << "NaCl loader: setting up IPC descriptor";
41 // don't need zygote FD any more 43 // don't need zygote FD any more
42 if (HANDLE_EINTR(close(kNaClZygoteDescriptor)) != 0) 44 if (HANDLE_EINTR(close(kNaClZygoteDescriptor)) != 0)
43 LOG(ERROR) << "close(kNaClZygoteDescriptor) failed."; 45 LOG(ERROR) << "close(kNaClZygoteDescriptor) failed.";
44 // Set up browser descriptor as expected by Chrome on fd 3 46 // Set up browser descriptor on fd 3 and IPC as expected by Chrome.
45 // The zygote takes care of putting the sandbox IPC channel on fd 5 47 base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel,
48 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor);
46 int zfd = dup2(child_fds[kNaClBrowserFDIndex], kNaClBrowserDescriptor); 49 int zfd = dup2(child_fds[kNaClBrowserFDIndex], kNaClBrowserDescriptor);
47 if (zfd != kNaClBrowserDescriptor) { 50 if (zfd != kNaClBrowserDescriptor) {
48 LOG(ERROR) << "Could not initialize kNaClBrowserDescriptor"; 51 LOG(ERROR) << "Could not initialize kNaClBrowserDescriptor";
49 _exit(-1); 52 _exit(-1);
50 } 53 }
51 54
52 MessageLoopForIO main_message_loop; 55 MessageLoopForIO main_message_loop;
53 NaClListener listener; 56 NaClListener listener;
54 listener.Listen(); 57 listener.Listen();
55 _exit(0); 58 _exit(0);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 233 }
231 } 234 }
232 // if fork fails, send PID=-1 to zygote 235 // if fork fails, send PID=-1 to zygote
233 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, &badpid, 236 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, &badpid,
234 sizeof(badpid), empty)) { 237 sizeof(badpid), empty)) {
235 LOG(ERROR) << "*** send() to zygote failed"; 238 LOG(ERROR) << "*** send() to zygote failed";
236 } 239 }
237 } 240 }
238 CHECK(false); // This routine must not return 241 CHECK(false); // This routine must not return
239 } 242 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc ('k') | ipc/ipc.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698