summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-07 19:34:45 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-07 19:34:45 +0000
commit5667f1bdc8d290f469f9c5eae7bb4ec7563f85ac (patch)
treeb3b4d32437596c5462b1907e6c68f2db2d15b8a0 /sandbox
parent186bf92abfcce5136acb040c301959ff6ca96028 (diff)
downloadchromium_src-5667f1bdc8d290f469f9c5eae7bb4ec7563f85ac.zip
chromium_src-5667f1bdc8d290f469f9c5eae7bb4ec7563f85ac.tar.gz
chromium_src-5667f1bdc8d290f469f9c5eae7bb4ec7563f85ac.tar.bz2
Revert 80819 due to failed tests
TBR=pkasting@chromium.org Review URL: http://codereview.chromium.org/6816024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80824 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/src/Wow64.cc3
-rw-r--r--sandbox/src/dep_test.cc30
-rw-r--r--sandbox/src/integrity_level_test.cc8
-rw-r--r--sandbox/src/interception.cc3
-rw-r--r--sandbox/src/job.cc12
-rw-r--r--sandbox/src/sandbox_utils.cc34
-rw-r--r--sandbox/src/service_resolver_unittest.cc3
-rw-r--r--sandbox/tests/common/controller.cc10
8 files changed, 75 insertions, 28 deletions
diff --git a/sandbox/src/Wow64.cc b/sandbox/src/Wow64.cc
index 60c63fd..9284fe8 100644
--- a/sandbox/src/Wow64.cc
+++ b/sandbox/src/Wow64.cc
@@ -88,8 +88,7 @@ Wow64::~Wow64() {
// bit version of ntdll is loaded, we'll remove the interception and return to
// our caller.
bool Wow64::WaitForNtdll() {
- if (base::win::OSInfo::GetInstance()->wow64_status() !=
- base::win::OSInfo::WOW64_ENABLED)
+ if (base::win::GetWOW64Status() != base::win::WOW64_ENABLED)
return true;
const size_t page_size = 4096;
diff --git a/sandbox/src/dep_test.cc b/sandbox/src/dep_test.cc
index 91d4e67..7d57c6e 100644
--- a/sandbox/src/dep_test.cc
+++ b/sandbox/src/dep_test.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,6 +12,32 @@ namespace sandbox {
namespace {
+class DepTest : public testing::Test {
+ public:
+ static bool IsTestCaseDisabled() {
+ OSVERSIONINFOEX version_info;
+ version_info.dwOSVersionInfoSize = sizeof version_info;
+ GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info));
+
+ // Windows 2000 doesn't support DEP at all.
+ if (version_info.dwMajorVersion == 5 && version_info.dwMinorVersion == 0)
+ return true;
+
+ // Windows XP Service Pack 0 and 1 don't support DEP at all.
+ if (version_info.dwMajorVersion == 5 && version_info.dwMinorVersion == 1
+ && version_info.wServicePackMajor < 2)
+ return true;
+
+ // Bug 1212371 Vista SP0 DEP support is half-baked. Nobody seem to have
+ // noticed!
+ if (version_info.dwMajorVersion == 6 &&
+ version_info.wServicePackMajor == 0)
+ return true;
+
+ return false;
+ }
+};
+
BYTE kReturnCode[] = {
// ret
0xC3,
@@ -141,7 +167,7 @@ SBOX_TESTS_COMMAND int CheckDepLevel(int argc, wchar_t **argv) {
} // namespace
// This test is disabled. See bug 1275842
-TEST(DepTest, DISABLED_TestDepDisable) {
+TEST_F(DepTest, DISABLED_TestDepDisable) {
TestRunner runner(JOB_UNPROTECTED, USER_INTERACTIVE, USER_INTERACTIVE);
runner.SetTimeout(INFINITE);
diff --git a/sandbox/src/integrity_level_test.cc b/sandbox/src/integrity_level_test.cc
index c6e0b64..cdc8da7 100644
--- a/sandbox/src/integrity_level_test.cc
+++ b/sandbox/src/integrity_level_test.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -45,7 +45,7 @@ SBOX_TESTS_COMMAND int CheckIntegrityLevel(int argc, wchar_t **argv) {
}
TEST(IntegrityLevelTest, TestLowILReal) {
- if (base::win::GetVersion() != base::win::VERSION_VISTA)
+ if (base::win::VERSION_VISTA != base::win::GetVersion())
return;
TestRunner runner(JOB_LOCKDOWN, USER_INTERACTIVE, USER_INTERACTIVE);
@@ -61,7 +61,7 @@ TEST(IntegrityLevelTest, TestLowILReal) {
}
TEST(DelayedIntegrityLevelTest, TestLowILDelayed) {
- if (base::win::GetVersion() != base::win::VERSION_VISTA)
+ if (base::win::VERSION_VISTA != base::win::GetVersion())
return;
TestRunner runner(JOB_LOCKDOWN, USER_INTERACTIVE, USER_INTERACTIVE);
@@ -77,7 +77,7 @@ TEST(DelayedIntegrityLevelTest, TestLowILDelayed) {
}
TEST(IntegrityLevelTest, TestNoILChange) {
- if (base::win::GetVersion() != base::win::VERSION_VISTA)
+ if (base::win::VERSION_VISTA != base::win::GetVersion())
return;
TestRunner runner(JOB_LOCKDOWN, USER_INTERACTIVE, USER_INTERACTIVE);
diff --git a/sandbox/src/interception.cc b/sandbox/src/interception.cc
index b66fddd..577d079 100644
--- a/sandbox/src/interception.cc
+++ b/sandbox/src/interception.cc
@@ -438,8 +438,7 @@ bool InterceptionManager::PatchClientFunctions(DllInterceptionData* thunks,
#endif
ServiceResolverThunk* thunk;
- if (base::win::OSInfo::GetInstance()->wow64_status() ==
- base::win::OSInfo::WOW64_ENABLED)
+ if (base::win::GetWOW64Status() == base::win::WOW64_ENABLED)
thunk = new Wow64ResolverThunk(child_->Process(), relaxed_);
else if (!IsXPSP2OrLater())
thunk = new Win2kResolverThunk(child_->Process(), relaxed_);
diff --git a/sandbox/src/job.cc b/sandbox/src/job.cc
index 8ed3a77..e0dca68 100644
--- a/sandbox/src/job.cc
+++ b/sandbox/src/job.cc
@@ -1,10 +1,8 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sandbox/src/job.h"
-
-#include "base/win/windows_version.h"
#include "sandbox/src/restricted_token.h"
namespace sandbox {
@@ -51,11 +49,17 @@ DWORD Job::Init(JobLevel security_level, wchar_t *job_name,
jbur.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_EXITWINDOWS;
}
case JOB_UNPROTECTED: {
+ OSVERSIONINFO version_info = {0};
+ version_info.dwOSVersionInfoSize = sizeof(version_info);
+ GetVersionEx(&version_info);
+
// The JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag is not supported on
// Windows 2000. We need a mechanism on Windows 2000 to ensure
// that processes in the job are terminated when the job is closed
- if (base::win::GetVersion() == base::win::VERSION_PRE_XP)
+ if ((5 == version_info.dwMajorVersion) &&
+ (0 == version_info.dwMinorVersion)) {
break;
+ }
jeli.BasicLimitInformation.LimitFlags |=
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
diff --git a/sandbox/src/sandbox_utils.cc b/sandbox/src/sandbox_utils.cc
index b93434c..9554514 100644
--- a/sandbox/src/sandbox_utils.cc
+++ b/sandbox/src/sandbox_utils.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,7 +7,6 @@
#include <windows.h>
#include "base/logging.h"
-#include "base/win/windows_version.h"
#include "sandbox/src/internal_types.h"
#include "sandbox/src/nt_internals.h"
@@ -57,10 +56,33 @@ bool GetModuleHandleHelper(DWORD flags, const wchar_t* module_name,
}
bool IsXPSP2OrLater() {
- base::win::Version version = base::win::GetVersion();
- return (version > base::win::VERSION_XP) ||
- ((version == base::win::VERSION_XP) &&
- (base::win::OSInfo::GetInstance()->service_pack().major >= 2));
+ OSVERSIONINFOEX version = {0};
+ version.dwOSVersionInfoSize = sizeof(version);
+ if (!::GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version))) {
+ NOTREACHED();
+ return false;
+ }
+
+ // Vista or later
+ if (version.dwMajorVersion > 5)
+ return true;
+
+ // 2k, xp or 2003
+ if (version.dwMajorVersion == 5) {
+ // 2003
+ if (version.dwMinorVersion > 1)
+ return true;
+
+ // 2000
+ if (version.dwMinorVersion == 0)
+ return false;
+
+ // Windows Xp Sp2 or later
+ if (version.wServicePackMajor >= 2)
+ return true;
+ }
+
+ return false;
}
void InitObjectAttribs(const std::wstring& name, ULONG attributes, HANDLE root,
diff --git a/sandbox/src/service_resolver_unittest.cc b/sandbox/src/service_resolver_unittest.cc
index 36ad1d0f..f5e29f3 100644
--- a/sandbox/src/service_resolver_unittest.cc
+++ b/sandbox/src/service_resolver_unittest.cc
@@ -120,8 +120,7 @@ NTSTATUS PatchNtdllWithResolver(const char* function, bool relaxed,
}
sandbox::ServiceResolverThunk* GetTestResolver(bool relaxed) {
- if (base::win::OSInfo::GetInstance()->wow64_status() ==
- base::win::OSInfo::WOW64_ENABLED)
+ if (base::win::GetWOW64Status() == base::win::WOW64_ENABLED)
return new Wow64ResolverTest(relaxed);
if (!sandbox::IsXPSP2OrLater())
return new Win2kResolverTest(relaxed);
diff --git a/sandbox/tests/common/controller.cc b/sandbox/tests/common/controller.cc
index b618069..7efd374 100644
--- a/sandbox/tests/common/controller.cc
+++ b/sandbox/tests/common/controller.cc
@@ -55,10 +55,9 @@ std::wstring MakePathToSysWow64(const wchar_t* name, bool is_obj_man_path) {
namespace sandbox {
std::wstring MakePathToSys(const wchar_t* name, bool is_obj_man_path) {
- return (base::win::OSInfo::GetInstance()->wow64_status() ==
- base::win::OSInfo::WOW64_ENABLED) ?
- MakePathToSysWow64(name, is_obj_man_path) :
- MakePathToSys32(name, is_obj_man_path);
+ if (base::win::GetWOW64Status() == base::win::WOW64_ENABLED)
+ return MakePathToSysWow64(name, is_obj_man_path);
+ return MakePathToSys32(name, is_obj_man_path);
}
BrokerServices* GetBroker() {
@@ -139,8 +138,7 @@ bool TestRunner::AddRuleSys32(TargetPolicy::Semantics semantics,
if (!AddRule(TargetPolicy::SUBSYS_FILES, semantics, win32_path.c_str()))
return false;
- if (base::win::OSInfo::GetInstance()->wow64_status() !=
- base::win::OSInfo::WOW64_ENABLED)
+ if (base::win::GetWOW64Status() != base::win::WOW64_ENABLED)
return true;
win32_path = MakePathToSysWow64(pattern, false);