OLD | NEW |
---|---|
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 "sandbox/win/src/broker_services.h" | 5 #include "sandbox/win/src/broker_services.h" |
6 | 6 |
7 #include <AclAPI.h> | 7 #include <AclAPI.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 | 394 |
395 HANDLE job_temp; | 395 HANDLE job_temp; |
396 result = policy_base->MakeJobObject(&job_temp); | 396 result = policy_base->MakeJobObject(&job_temp); |
397 if (SBOX_ALL_OK != result) | 397 if (SBOX_ALL_OK != result) |
398 return result; | 398 return result; |
399 | 399 |
400 base::win::ScopedHandle job(job_temp); | 400 base::win::ScopedHandle job(job_temp); |
401 | 401 |
402 // Initialize the startup information from the policy. | 402 // Initialize the startup information from the policy. |
403 base::win::StartupInformation startup_info; | 403 base::win::StartupInformation startup_info; |
404 // The liftime of |mitigations| has to be at least as long as |startup_info| | |
405 // because |UpdateProcThreadAttribute| requires that its |lpValue| parameter | |
406 // persist until |DeleteProcThreadAttributeList| is called; | |
407 // StartupInformation's destructor makes such a call. | |
408 DWORD64 mitigations; | |
404 base::string16 desktop = policy_base->GetAlternateDesktop(); | 409 base::string16 desktop = policy_base->GetAlternateDesktop(); |
405 if (!desktop.empty()) { | 410 if (!desktop.empty()) { |
406 startup_info.startup_info()->lpDesktop = | 411 startup_info.startup_info()->lpDesktop = |
407 const_cast<wchar_t*>(desktop.c_str()); | 412 const_cast<wchar_t*>(desktop.c_str()); |
408 } | 413 } |
409 | 414 |
410 bool inherit_handles = false; | 415 bool inherit_handles = false; |
411 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 416 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
412 int attribute_count = 0; | 417 int attribute_count = 0; |
413 const AppContainerAttributes* app_container = | 418 const AppContainerAttributes* app_container = |
414 policy_base->GetAppContainer(); | 419 policy_base->GetAppContainer(); |
415 if (app_container) | 420 if (app_container) |
416 ++attribute_count; | 421 ++attribute_count; |
417 | 422 |
418 DWORD64 mitigations; | |
419 size_t mitigations_size; | 423 size_t mitigations_size; |
420 ConvertProcessMitigationsToPolicy(policy->GetProcessMitigations(), | 424 ConvertProcessMitigationsToPolicy(policy->GetProcessMitigations(), |
421 &mitigations, &mitigations_size); | 425 &mitigations, &mitigations_size); |
422 if (mitigations) | 426 if (mitigations) |
423 ++attribute_count; | 427 ++attribute_count; |
424 | 428 |
425 HANDLE stdout_handle = policy_base->GetStdoutHandle(); | 429 HANDLE stdout_handle = policy_base->GetStdoutHandle(); |
426 HANDLE stderr_handle = policy_base->GetStderrHandle(); | 430 HANDLE stderr_handle = policy_base->GetStderrHandle(); |
427 HANDLE inherit_handle_list[2]; | 431 HANDLE inherit_handle_list[2]; |
Nico
2015/04/20 18:25:10
Now that I look at this again, this guy has the sa
majnemer
2015/04/20 21:08:54
Done.
| |
428 int inherit_handle_count = 0; | 432 int inherit_handle_count = 0; |
429 if (stdout_handle != INVALID_HANDLE_VALUE) | 433 if (stdout_handle != INVALID_HANDLE_VALUE) |
430 inherit_handle_list[inherit_handle_count++] = stdout_handle; | 434 inherit_handle_list[inherit_handle_count++] = stdout_handle; |
431 // Handles in the list must be unique. | 435 // Handles in the list must be unique. |
432 if (stderr_handle != stdout_handle && stderr_handle != INVALID_HANDLE_VALUE) | 436 if (stderr_handle != stdout_handle && stderr_handle != INVALID_HANDLE_VALUE) |
433 inherit_handle_list[inherit_handle_count++] = stderr_handle; | 437 inherit_handle_list[inherit_handle_count++] = stderr_handle; |
434 if (inherit_handle_count) | 438 if (inherit_handle_count) |
435 ++attribute_count; | 439 ++attribute_count; |
436 | 440 |
437 if (!startup_info.InitializeProcThreadAttributeList(attribute_count)) | 441 if (!startup_info.InitializeProcThreadAttributeList(attribute_count)) |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 return SBOX_ERROR_UNSUPPORTED; | 590 return SBOX_ERROR_UNSUPPORTED; |
587 | 591 |
588 base::string16 name = LookupAppContainer(sid); | 592 base::string16 name = LookupAppContainer(sid); |
589 if (name.empty()) | 593 if (name.empty()) |
590 return SBOX_ERROR_INVALID_APP_CONTAINER; | 594 return SBOX_ERROR_INVALID_APP_CONTAINER; |
591 | 595 |
592 return DeleteAppContainer(sid); | 596 return DeleteAppContainer(sid); |
593 } | 597 } |
594 | 598 |
595 } // namespace sandbox | 599 } // namespace sandbox |
OLD | NEW |