diff options
author | cpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-13 02:01:41 +0000 |
---|---|---|
committer | cpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-13 02:01:41 +0000 |
commit | 1b31477393c50ca192abf0789900c9eda0bfea7d (patch) | |
tree | a575081816a30c3793dc2186b0b6b4a560150db9 /chrome/installer/util | |
parent | 7619b422a8c5a58a5ecfc76766fbdd5f2642cbe5 (diff) | |
download | chromium_src-1b31477393c50ca192abf0789900c9eda0bfea7d.zip chromium_src-1b31477393c50ca192abf0789900c9eda0bfea7d.tar.gz chromium_src-1b31477393c50ca192abf0789900c9eda0bfea7d.tar.bz2 |
Test for Symantec SEP
- Versions before 11MR3 crash chrome
- Still need to wire the code.
BUG=38
Review URL: http://codereview.chromium.org/24015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util')
-rw-r--r-- | chrome/installer/util/compat_checks.cc | 59 | ||||
-rw-r--r-- | chrome/installer/util/compat_checks.h | 12 | ||||
-rw-r--r-- | chrome/installer/util/compat_checks_unittest.cc | 23 | ||||
-rw-r--r-- | chrome/installer/util/installer_unittests.vcproj | 8 | ||||
-rw-r--r-- | chrome/installer/util/util.vcproj | 8 |
5 files changed, 108 insertions, 2 deletions
diff --git a/chrome/installer/util/compat_checks.cc b/chrome/installer/util/compat_checks.cc new file mode 100644 index 0000000..3c1d3ae --- /dev/null +++ b/chrome/installer/util/compat_checks.cc @@ -0,0 +1,59 @@ +// Copyright (c) 2006-2009 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 "chrome/installer/util/compat_checks.h" + +#include "base/registry.h" +#include "base/string_util.h" + +namespace { + +// SEP stands for Symantec End Point Protection. +std::wstring GetSEPVersion() { + const wchar_t kProductKey[] = + L"SOFTWARE\\Symantec\\Symantec Endpoint Protection\\SMC"; + RegKey key(HKEY_LOCAL_MACHINE, kProductKey, KEY_READ); + std::wstring version_str; + key.ReadValue(L"ProductVersion", &version_str); + return version_str; +} + +// The product version should be a string like "11.0.3001.2224". This function +// returns as params the first 3 values. Return value is false if anything +// does not fit the format. +bool ParseSEPVersion(const std::wstring& version, int* v0, int* v1, int* v2) { + std::vector<std::wstring> v; + SplitString(version, L'.', &v); + if (v.size() != 4) + return false; + if (!StringToInt(v[0], v0)) + return false; + if (!StringToInt(v[1], v1)) + return false; + if (!StringToInt(v[2], v2)) + return false; + return true; +} + +// The incompatible versions are anything before 11MR3, which is 11.0.3001. +bool IsBadSEPVersion(int v0, int v1, int v2) { + if (v0 < 11) + return true; + if (v1 > 0) + return false; + if (v2 < 3001) + return true; + return false; +} + +} // namespace + +bool HasIncompatibleSymantecEndpointVersion(const wchar_t* version) { + int v0, v1, v2; + std::wstring ver_str(version ? version : GetSEPVersion()); + if (!ParseSEPVersion(ver_str, &v0, &v1, &v2)) + return false; + return IsBadSEPVersion(v0, v1, v2); +} + diff --git a/chrome/installer/util/compat_checks.h b/chrome/installer/util/compat_checks.h new file mode 100644 index 0000000..c489208 --- /dev/null +++ b/chrome/installer/util/compat_checks.h @@ -0,0 +1,12 @@ +// Copyright (c) 2006-2009 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. + +#ifndef CHROME_INSTALLER_UTIL_COMPAT_CHECKS_H_ +#define CHROME_INSTALLER_UTIL_COMPAT_CHECKS_H_ + +// Returns true if this computer has a Symantec End Point version that +// is known to cause trouble. Non- null parameters are only used in testing. +bool HasIncompatibleSymantecEndpointVersion(const wchar_t* version); + +#endif // CHROME_INSTALLER_UTIL_COMPAT_CHECKS_H_ diff --git a/chrome/installer/util/compat_checks_unittest.cc b/chrome/installer/util/compat_checks_unittest.cc new file mode 100644 index 0000000..3c43a26 --- /dev/null +++ b/chrome/installer/util/compat_checks_unittest.cc @@ -0,0 +1,23 @@ +// Copyright (c) 2006-2009 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 "chrome/installer/setup/compat_checks.h" +#include "testing/gtest/include/gtest/gtest.h" + +// Test that we detect the incompatible SEP version. The very last digit +// of the version does not matter but must be present. +TEST(CompatTests, SymantecSEP) { + EXPECT_FALSE(HasIncompatibleSymantecEndpointVersion(L"11.0.3001.0")); + EXPECT_TRUE(HasIncompatibleSymantecEndpointVersion(L"11.0.3000.1")); + EXPECT_TRUE(HasIncompatibleSymantecEndpointVersion(L"11.0.2999.1")); + EXPECT_TRUE(HasIncompatibleSymantecEndpointVersion(L"10.1.5000.1")); + EXPECT_TRUE(HasIncompatibleSymantecEndpointVersion(L"9.5.1000.0")); + + EXPECT_FALSE(HasIncompatibleSymantecEndpointVersion(L"")); + EXPECT_FALSE(HasIncompatibleSymantecEndpointVersion(L"11.0.3000")); + EXPECT_FALSE(HasIncompatibleSymantecEndpointVersion(L"11.0.3000.1.2")); + EXPECT_FALSE(HasIncompatibleSymantecEndpointVersion(L"11.b.3000.1")); + +} + diff --git a/chrome/installer/util/installer_unittests.vcproj b/chrome/installer/util/installer_unittests.vcproj index 5ac125b..62ac85a 100644 --- a/chrome/installer/util/installer_unittests.vcproj +++ b/chrome/installer/util/installer_unittests.vcproj @@ -152,6 +152,10 @@ Name="tests" > <File + RelativePath="..\setup\compat_checks_unittest.cc" + > + </File> + <File RelativePath="copy_tree_work_item_unittest.cc" > </File> @@ -172,11 +176,11 @@ > </File> <File - RelativePath="helper_unittest.cc" + RelativePath="google_chrome_distribution_unittest.cc" > </File> <File - RelativePath="google_chrome_distribution_unittest.cc" + RelativePath="helper_unittest.cc" > </File> <File diff --git a/chrome/installer/util/util.vcproj b/chrome/installer/util/util.vcproj index 6bd7ed0..9c7547f 100644 --- a/chrome/installer/util/util.vcproj +++ b/chrome/installer/util/util.vcproj @@ -129,6 +129,14 @@ > </File> <File + RelativePath=".\compat_checks.cc" + > + </File> + <File + RelativePath=".\compat_checks.h" + > + </File> + <File RelativePath=".\copy_tree_work_item.cc" > </File> |