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

Side by Side Diff: sandbox/src/broker_services.cc

Issue 9924010: Revert 129627 - Add a sandbox API for broker handle duplication (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « sandbox/src/broker_services.h ('k') | sandbox/src/handle_dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 "sandbox/src/broker_services.h" 5 #include "sandbox/src/broker_services.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/threading/platform_thread.h" 8 #include "base/threading/platform_thread.h"
9 #include "sandbox/src/sandbox_policy_base.h" 9 #include "sandbox/src/sandbox_policy_base.h"
10 #include "sandbox/src/sandbox.h" 10 #include "sandbox/src/sandbox.h"
11 #include "sandbox/src/target_process.h" 11 #include "sandbox/src/target_process.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 case JOB_OBJECT_MSG_NEW_PROCESS: { 177 case JOB_OBJECT_MSG_NEW_PROCESS: {
178 ++target_counter; 178 ++target_counter;
179 if (1 == target_counter) { 179 if (1 == target_counter) {
180 ::ResetEvent(no_targets); 180 ::ResetEvent(no_targets);
181 } 181 }
182 break; 182 break;
183 } 183 }
184 184
185 case JOB_OBJECT_MSG_EXIT_PROCESS: 185 case JOB_OBJECT_MSG_EXIT_PROCESS:
186 case JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: { 186 case JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: {
187 {
188 AutoLock lock(&broker->lock_);
189 broker->child_process_ids_.erase(reinterpret_cast<DWORD>(ovl));
190 }
191 --target_counter; 187 --target_counter;
192 if (0 == target_counter) 188 if (0 == target_counter)
193 ::SetEvent(no_targets); 189 ::SetEvent(no_targets);
194 190
195 DCHECK(target_counter >= 0); 191 DCHECK(target_counter >= 0);
196 break; 192 break;
197 } 193 }
198 194
199 case JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT: { 195 case JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT: {
200 break; 196 break;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 285
290 // We are going to keep a pointer to the policy because we'll call it when 286 // We are going to keep a pointer to the policy because we'll call it when
291 // the job object generates notifications using the completion port. 287 // the job object generates notifications using the completion port.
292 policy_base->AddRef(); 288 policy_base->AddRef();
293 JobTracker* tracker = new JobTracker(job, policy_base); 289 JobTracker* tracker = new JobTracker(job, policy_base);
294 if (!AssociateCompletionPort(job, job_port_, tracker)) 290 if (!AssociateCompletionPort(job, job_port_, tracker))
295 return SpawnCleanup(target, 0); 291 return SpawnCleanup(target, 0);
296 // Save the tracker because in cleanup we might need to force closing 292 // Save the tracker because in cleanup we might need to force closing
297 // the Jobs. 293 // the Jobs.
298 tracker_list_.push_back(tracker); 294 tracker_list_.push_back(tracker);
299 child_process_ids_.insert(process_info.dwProcessId);
300 295
301 // We return the caller a duplicate of the process handle so they 296 // We return the caller a duplicate of the process handle so they
302 // can close it at will. 297 // can close it at will.
303 HANDLE dup_process_handle = NULL; 298 HANDLE dup_process_handle = NULL;
304 if (!::DuplicateHandle(::GetCurrentProcess(), process_info.hProcess, 299 if (!::DuplicateHandle(::GetCurrentProcess(), process_info.hProcess,
305 ::GetCurrentProcess(), &dup_process_handle, 300 ::GetCurrentProcess(), &dup_process_handle,
306 0, FALSE, DUPLICATE_SAME_ACCESS)) 301 0, FALSE, DUPLICATE_SAME_ACCESS))
307 return SpawnCleanup(target, 0); 302 return SpawnCleanup(target, 0);
308 303
309 *target_info = process_info; 304 *target_info = process_info;
310 target_info->hProcess = dup_process_handle; 305 target_info->hProcess = dup_process_handle;
311 return SBOX_ALL_OK; 306 return SBOX_ALL_OK;
312 } 307 }
313 308
314 309
315 ResultCode BrokerServicesBase::WaitForAllTargets() { 310 ResultCode BrokerServicesBase::WaitForAllTargets() {
316 ::WaitForSingleObject(no_targets_, INFINITE); 311 ::WaitForSingleObject(no_targets_, INFINITE);
317 return SBOX_ALL_OK; 312 return SBOX_ALL_OK;
318 } 313 }
319 314
320 bool BrokerServicesBase::IsActiveTarget(DWORD process_id) {
321 AutoLock lock(&lock_);
322 return child_process_ids_.find(process_id) != child_process_ids_.end();
323 }
324
325 } // namespace sandbox 315 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/src/broker_services.h ('k') | sandbox/src/handle_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698