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

Unified Diff: sandbox/tests/common/controller.cc

Issue 9960045: Add sandbox support for associating peer processes (Closed) Base URL: svn://chrome-svn/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/tests/common/controller.h ('k') | sandbox/tests/integration_tests/integration_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/tests/common/controller.cc
===================================================================
--- sandbox/tests/common/controller.cc (revision 132034)
+++ sandbox/tests/common/controller.cc (working copy)
@@ -6,6 +6,8 @@
#include <string>
+#include "base/process.h"
+#include "base/process_util.h"
#include "base/sys_string_conversions.h"
#include "base/win/windows_version.h"
#include "sandbox/src/sandbox_factory.h"
@@ -89,12 +91,14 @@
TestRunner::TestRunner(JobLevel job_level, TokenLevel startup_token,
TokenLevel main_token)
- : is_init_(false), is_async_(false), target_process_id_(0) {
+ : is_init_(false), is_async_(false), no_sandbox_(false),
+ target_process_id_(0) {
Init(job_level, startup_token, main_token);
}
TestRunner::TestRunner()
- : is_init_(false), is_async_(false), target_process_id_(0) {
+ : is_init_(false), is_async_(false), no_sandbox_(false),
+ target_process_id_(0) {
Init(JOB_LOCKDOWN, USER_RESTRICTED_SAME_ACCESS, USER_LOCKDOWN);
}
@@ -209,11 +213,21 @@
std::wstring arguments(L"\"");
arguments += prog_name;
- arguments += L"\" -child ";
+ arguments += L"\" -child";
+ arguments += no_sandbox_ ? L"-no-sandbox " : L" ";
arguments += command;
- result = broker_->SpawnTarget(prog_name, arguments.c_str(), policy_,
- &target);
+ if (no_sandbox_) {
+ STARTUPINFO startup_info = {sizeof(STARTUPINFO)};
+ if (!::CreateProcessW(prog_name, &arguments[0], NULL, NULL, FALSE, 0,
+ NULL, NULL, &startup_info, &target)) {
+ return SBOX_ERROR_GENERIC;
+ }
+ broker_->AddTargetPeer(target.hProcess);
+ } else {
+ result = broker_->SpawnTarget(prog_name, arguments.c_str(), policy_,
+ &target);
+ }
if (SBOX_ALL_OK != result)
return SBOX_TEST_FAILED_TO_RUN_TEST;
@@ -304,18 +318,20 @@
command(argc - 4, argv + 4);
TargetServices* target = SandboxFactory::GetTargetServices();
- if (!target)
- return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
+ if (target) {
+ if (SBOX_ALL_OK != target->Init())
+ return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
- if (SBOX_ALL_OK != target->Init())
+ if (BEFORE_REVERT == state)
+ return command(argc - 4, argv + 4);
+ else if (EVERY_STATE == state)
+ command(argc - 4, argv + 4);
+
+ target->LowerToken();
+ } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) {
return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
+ }
- if (BEFORE_REVERT == state)
- return command(argc - 4, argv + 4);
- else if (EVERY_STATE == state)
- command(argc - 4, argv + 4);
-
- target->LowerToken();
return command(argc - 4, argv + 4);
}
« no previous file with comments | « sandbox/tests/common/controller.h ('k') | sandbox/tests/integration_tests/integration_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698