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 "content/common/sandbox_policy.h" | 5 #include "content/common/sandbox_policy.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 AddGenericDllEvictionPolicy(policy); | 376 AddGenericDllEvictionPolicy(policy); |
377 #endif | 377 #endif |
378 return true; | 378 return true; |
379 } | 379 } |
380 | 380 |
381 bool AddPolicyForRenderer(sandbox::TargetPolicy* policy) { | 381 bool AddPolicyForRenderer(sandbox::TargetPolicy* policy) { |
382 // Renderers need to copy sections for plugin DIBs. | 382 // Renderers need to copy sections for plugin DIBs. |
383 sandbox::ResultCode result; | 383 sandbox::ResultCode result; |
384 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, | 384 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, |
385 sandbox::TargetPolicy::HANDLES_DUP_ANY, | 385 sandbox::TargetPolicy::HANDLES_DUP_ANY, |
386 L"Section"); | 386 L"*"); |
jschuh
2012/04/12 22:42:03
Does this really need to be "*"?
Mark Seaborn
2012/04/13 00:50:28
OK, I wasn't sure if listing handle types bought u
| |
387 if (result != sandbox::SBOX_ALL_OK) { | 387 if (result != sandbox::SBOX_ALL_OK) { |
388 NOTREACHED(); | 388 NOTREACHED(); |
389 return false; | 389 return false; |
390 } | 390 } |
391 | 391 |
392 policy->SetJobLevel(sandbox::JOB_LOCKDOWN, 0); | 392 policy->SetJobLevel(sandbox::JOB_LOCKDOWN, 0); |
393 | 393 |
394 sandbox::TokenLevel initial_token = sandbox::USER_UNPROTECTED; | 394 sandbox::TokenLevel initial_token = sandbox::USER_UNPROTECTED; |
395 if (base::win::GetVersion() > base::win::VERSION_XP) { | 395 if (base::win::GetVersion() > base::win::VERSION_XP) { |
396 // On 2003/Vista the initial token has to be restricted if the main | 396 // On 2003/Vista the initial token has to be restricted if the main |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
469 } | 469 } |
470 | 470 |
471 ResultCode result = g_target_services->DuplicateHandle(source_handle, | 471 ResultCode result = g_target_services->DuplicateHandle(source_handle, |
472 target_process_id, | 472 target_process_id, |
473 target_handle, | 473 target_handle, |
474 desired_access, | 474 desired_access, |
475 options); | 475 options); |
476 return SBOX_ALL_OK == result; | 476 return SBOX_ALL_OK == result; |
477 } | 477 } |
478 | 478 |
479 bool BrokerAddTargetPeer(HANDLE peer_process) { | |
480 ResultCode result = g_broker_services->AddTargetPeer(peer_process); | |
481 return SBOX_ALL_OK == result; | |
482 } | |
483 | |
479 | 484 |
480 base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, | 485 base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, |
481 const FilePath& exposed_dir) { | 486 const FilePath& exposed_dir) { |
482 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 487 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
483 content::ProcessType type; | 488 content::ProcessType type; |
484 std::string type_str = cmd_line->GetSwitchValueASCII(switches::kProcessType); | 489 std::string type_str = cmd_line->GetSwitchValueASCII(switches::kProcessType); |
485 if (type_str == switches::kRendererProcess) { | 490 if (type_str == switches::kRendererProcess) { |
486 type = content::PROCESS_TYPE_RENDERER; | 491 type = content::PROCESS_TYPE_RENDERER; |
487 } else if (type_str == switches::kPluginProcess) { | 492 } else if (type_str == switches::kPluginProcess) { |
488 type = content::PROCESS_TYPE_PLUGIN; | 493 type = content::PROCESS_TYPE_PLUGIN; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 | 669 |
665 // Help the process a little. It can't start the debugger by itself if | 670 // Help the process a little. It can't start the debugger by itself if |
666 // the process is in a sandbox. | 671 // the process is in a sandbox. |
667 if (child_needs_help) | 672 if (child_needs_help) |
668 base::debug::SpawnDebuggerOnProcess(target.process_id()); | 673 base::debug::SpawnDebuggerOnProcess(target.process_id()); |
669 | 674 |
670 return target.TakeProcessHandle(); | 675 return target.TakeProcessHandle(); |
671 } | 676 } |
672 | 677 |
673 } // namespace sandbox | 678 } // namespace sandbox |
OLD | NEW |