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

Side by Side Diff: chrome/app/chrome_exe_main_mac.cc

Issue 2931173003: Implement the V2 sandbox in the process launcher. (Closed)
Patch Set: Created 3 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // The entry point for all Mac Chromium processes, including the outer app 5 // The entry point for all Mac Chromium processes, including the outer app
6 // bundle (browser) and helper app (renderer, plugin, and friends). 6 // bundle (browser) and helper app (renderer, plugin, and friends).
7 7
8 #include <dlfcn.h> 8 #include <dlfcn.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <libgen.h> 10 #include <libgen.h>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 char rp[MAXPATHLEN]; 49 char rp[MAXPATHLEN];
50 if (realpath(exec_path, rp) == NULL) { 50 if (realpath(exec_path, rp) == NULL) {
51 perror("realpath"); 51 perror("realpath");
52 abort(); 52 abort();
53 } 53 }
54 54
55 sandbox::SeatbeltExecServer server(fd_mapping); 55 sandbox::SeatbeltExecServer server(fd_mapping);
56 56
57 // The name of the parameter containing the executable path. 57 // The name of the parameter containing the executable path.
58 const std::string exec_param = "EXECUTABLE_PATH"; 58 const std::string exec_param = "EXECUTABLE_PATH";
59 // The name of the parameter containing the PID of Chrome.
60 const std::string pid_param = "CHROMIUM_PID";
61 59
62 if (!server.SetParameter(exec_param, rp) || 60 if (!server.SetParameter(exec_param, rp)) {
63 !server.SetParameter(pid_param, std::to_string(getpid()))) {
64 fprintf(stderr, "Failed to set up parameters for sandbox.\n"); 61 fprintf(stderr, "Failed to set up parameters for sandbox.\n");
65 abort(); 62 abort();
66 } 63 }
67 64
68 if (server.InitializeSandbox() != 0) { 65 if (!server.InitializeSandbox()) {
69 fprintf(stderr, "Failed to initialize sandbox.\n"); 66 fprintf(stderr, "Failed to initialize sandbox.\n");
70 abort(); 67 abort();
71 } 68 }
72 69
73 std::vector<char*> new_argv; 70 std::vector<char*> new_argv;
74 for (int i = 1; i < argc; ++i) { 71 for (int i = 0; i < argc; ++i) {
75 if (strcmp(argv[i], v2_sandbox_arg) != 0 && 72 if (strcmp(argv[i], v2_sandbox_arg) != 0 &&
76 strncmp(argv[i], fd_mapping_arg, strlen(fd_mapping_arg)) != 0) { 73 strncmp(argv[i], fd_mapping_arg, strlen(fd_mapping_arg)) != 0) {
77 new_argv.push_back(argv[i]); 74 new_argv.push_back(argv[i]);
78 } 75 }
79 } 76 }
80 // Tell Chrome that the sandbox should already be enabled. 77 // Tell Chrome that the sandbox should already be enabled.
81 // Note that execv() is documented to treat the argv as constants, so the 78 // Note that execv() is documented to treat the argv as constants, so the
82 // const_cast is safe. 79 // const_cast is safe.
83 new_argv.push_back(const_cast<char*>(v2_sandbox_enabled_arg)); 80 new_argv.push_back(const_cast<char*>(v2_sandbox_enabled_arg));
84 new_argv.push_back(nullptr); 81 new_argv.push_back(nullptr);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (!chrome_main) { 163 if (!chrome_main) {
167 fprintf(stderr, "dlsym ChromeMain: %s\n", dlerror()); 164 fprintf(stderr, "dlsym ChromeMain: %s\n", dlerror());
168 abort(); 165 abort();
169 } 166 }
170 rv = chrome_main(argc, argv); 167 rv = chrome_main(argc, argv);
171 168
172 // exit, don't return from main, to avoid the apparent removal of main from 169 // exit, don't return from main, to avoid the apparent removal of main from
173 // stack backtraces under tail call optimization. 170 // stack backtraces under tail call optimization.
174 exit(rv); 171 exit(rv);
175 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698