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

Side by Side Diff: content/browser/mach_broker_mac.mm

Issue 345373002: Revert of Define a bootstrap sandbox policy for renderer processes and enable it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/mach_broker_mac.h" 5 #include "content/browser/mach_broker_mac.h"
6 6
7 #include <bsm/libbsm.h> 7 #include <bsm/libbsm.h>
8 #include <servers/bootstrap.h> 8 #include <servers/bootstrap.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 private: 125 private:
126 // The MachBroker to use when new child task rights are received. Can be 126 // The MachBroker to use when new child task rights are received. Can be
127 // NULL. 127 // NULL.
128 MachBroker* broker_; // weak 128 MachBroker* broker_; // weak
129 129
130 base::mac::ScopedMachReceiveRight server_port_; 130 base::mac::ScopedMachReceiveRight server_port_;
131 131
132 DISALLOW_COPY_AND_ASSIGN(MachListenerThreadDelegate); 132 DISALLOW_COPY_AND_ASSIGN(MachListenerThreadDelegate);
133 }; 133 };
134 134
135 // static
136 bool MachBroker::ChildSendTaskPortToParent() { 135 bool MachBroker::ChildSendTaskPortToParent() {
137 // Look up the named MachBroker port that's been registered with the 136 // Look up the named MachBroker port that's been registered with the
138 // bootstrap server. 137 // bootstrap server.
139 mach_port_t parent_port; 138 mach_port_t parent_port;
140 kern_return_t kr = bootstrap_look_up(bootstrap_port, 139 kern_return_t kr = bootstrap_look_up(bootstrap_port,
141 const_cast<char*>(GetMachPortName().c_str()), &parent_port); 140 const_cast<char*>(GetMachPortName().c_str()), &parent_port);
142 if (kr != KERN_SUCCESS) { 141 if (kr != KERN_SUCCESS) {
143 BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_look_up"; 142 BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_look_up";
144 return false; 143 return false;
145 } 144 }
(...skipping 15 matching lines...) Expand all
161 kr = mach_msg(&msg.header, MACH_SEND_MSG | MACH_SEND_TIMEOUT, sizeof(msg), 160 kr = mach_msg(&msg.header, MACH_SEND_MSG | MACH_SEND_TIMEOUT, sizeof(msg),
162 0, MACH_PORT_NULL, 100 /*milliseconds*/, MACH_PORT_NULL); 161 0, MACH_PORT_NULL, 100 /*milliseconds*/, MACH_PORT_NULL);
163 if (kr != KERN_SUCCESS) { 162 if (kr != KERN_SUCCESS) {
164 MACH_LOG(ERROR, kr) << "mach_msg"; 163 MACH_LOG(ERROR, kr) << "mach_msg";
165 return false; 164 return false;
166 } 165 }
167 166
168 return true; 167 return true;
169 } 168 }
170 169
171 // static
172 std::string MachBroker::GetMachPortName() {
173 const CommandLine* command_line = CommandLine::ForCurrentProcess();
174 const bool is_child = command_line->HasSwitch(switches::kProcessType);
175
176 // In non-browser (child) processes, use the parent's pid.
177 const pid_t pid = is_child ? getppid() : getpid();
178 return base::StringPrintf("%s.rohitfork.%d", base::mac::BaseBundleID(), pid);
179 }
180
181 // static
182 MachBroker* MachBroker::GetInstance() { 170 MachBroker* MachBroker::GetInstance() {
183 return Singleton<MachBroker, LeakySingletonTraits<MachBroker> >::get(); 171 return Singleton<MachBroker, LeakySingletonTraits<MachBroker> >::get();
184 } 172 }
185 173
186 base::Lock& MachBroker::GetLock() { 174 base::Lock& MachBroker::GetLock() {
187 return lock_; 175 return lock_;
188 } 176 }
189 177
190 void MachBroker::EnsureRunning() { 178 void MachBroker::EnsureRunning() {
191 lock_.AssertAcquired(); 179 lock_.AssertAcquired();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 MachBroker::MachMap::iterator it = mach_map_.find(pid); 267 MachBroker::MachMap::iterator it = mach_map_.find(pid);
280 if (it == mach_map_.end()) 268 if (it == mach_map_.end())
281 return; 269 return;
282 270
283 kern_return_t kr = mach_port_deallocate(mach_task_self(), 271 kern_return_t kr = mach_port_deallocate(mach_task_self(),
284 it->second); 272 it->second);
285 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) << "mach_port_deallocate"; 273 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) << "mach_port_deallocate";
286 mach_map_.erase(it); 274 mach_map_.erase(it);
287 } 275 }
288 276
277 // static
278 std::string MachBroker::GetMachPortName() {
279 const CommandLine* command_line = CommandLine::ForCurrentProcess();
280 const bool is_child = command_line->HasSwitch(switches::kProcessType);
281
282 // In non-browser (child) processes, use the parent's pid.
283 const pid_t pid = is_child ? getppid() : getpid();
284 return base::StringPrintf("%s.rohitfork.%d", base::mac::BaseBundleID(), pid);
285 }
286
289 void MachBroker::RegisterNotifications() { 287 void MachBroker::RegisterNotifications() {
290 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, 288 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED,
291 NotificationService::AllBrowserContextsAndSources()); 289 NotificationService::AllBrowserContextsAndSources());
292 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, 290 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED,
293 NotificationService::AllBrowserContextsAndSources()); 291 NotificationService::AllBrowserContextsAndSources());
294 292
295 // No corresponding StopObservingBrowserChildProcesses, 293 // No corresponding StopObservingBrowserChildProcesses,
296 // we leak this singleton. 294 // we leak this singleton.
297 BrowserChildProcessObserver::Add(this); 295 BrowserChildProcessObserver::Add(this);
298 } 296 }
299 297
300 } // namespace content 298 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/mach_broker_mac.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698