diff options
author | Torne (Richard Coles) <torne@google.com> | 2014-06-09 12:00:27 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2014-06-09 12:00:27 +0100 |
commit | 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd (patch) | |
tree | ed52337c337f5fd1db77873d9ff980ca3e334b35 /chrome/installer | |
parent | 7ef4c70daab901f557268ad466f62cd2f7896916 (diff) | |
download | chromium_org-46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd.tar.gz |
Merge from Chromium at DEPS revision 275586
This commit was generated by merge_to_master.py.
Change-Id: Ief3a0ffd810858bfddbe0ec5931e3ee90d53f78c
Diffstat (limited to 'chrome/installer')
-rwxr-xr-x | chrome/installer/linux/common/wrapper | 6 | ||||
-rw-r--r-- | chrome/installer/test/alternate_version_generator.cc | 2 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings.cc | 61 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings.h | 4 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings_unittest.cc | 54 |
5 files changed, 101 insertions, 26 deletions
diff --git a/chrome/installer/linux/common/wrapper b/chrome/installer/linux/common/wrapper index e174637c52..d06b674144 100755 --- a/chrome/installer/linux/common/wrapper +++ b/chrome/installer/linux/common/wrapper @@ -73,6 +73,12 @@ if [[ -n "$CHROME_USER_DATA_DIR" ]]; then PROFILE_DIRECTORY_FLAG="--user-data-dir=$CHROME_USER_DATA_DIR" fi +# Sanitize std{in,out,err} because they'll be shared with untrusted child +# processes (http://crbug.com/376567). +exec < /dev/null +exec > >(exec cat) +exec 2> >(exec cat >&2) + # Note: exec -a below is a bashism. exec -a "$0" "$HERE/@@PROGNAME@@" @@DEFAULT_FLAGS@@ "$PROFILE_DIRECTORY_FLAG" \ "$@" diff --git a/chrome/installer/test/alternate_version_generator.cc b/chrome/installer/test/alternate_version_generator.cc index 146f1b05d0..b5035bb4ed 100644 --- a/chrome/installer/test/alternate_version_generator.cc +++ b/chrome/installer/test/alternate_version_generator.cc @@ -203,7 +203,7 @@ bool MappedFile::Initialize(base::File file) { << " are not supported."; } } else { - PLOG(DFATAL) << "GetPlatformFileInfo failed"; + PLOG(DFATAL) << "file.GetInfo failed"; } file_ = file.Pass(); return result; diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc index feac280afb..94b7994f8b 100644 --- a/chrome/installer/util/google_update_settings.cc +++ b/chrome/installer/util/google_update_settings.cc @@ -75,6 +75,7 @@ bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data, // presubmit: allow wstring const std::wstring& value, const wchar_t* const aggregate) { + const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; if (system_install) { DCHECK(aggregate); // Machine installs require each OS user to write a unique key under a @@ -89,13 +90,12 @@ bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data, base::string16 reg_path(app_reg_data.GetStateMediumKey()); reg_path.append(L"\\"); reg_path.append(name); - RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_SET_VALUE); + RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), kAccess); key.WriteValue(google_update::kRegAggregateMethod, aggregate); return (key.WriteValue(uniquename.c_str(), value.c_str()) == ERROR_SUCCESS); } else { // User installs are easy: just write the values to HKCU tree. - RegKey key(HKEY_CURRENT_USER, app_reg_data.GetStateKey().c_str(), - KEY_SET_VALUE); + RegKey key(HKEY_CURRENT_USER, app_reg_data.GetStateKey().c_str(), kAccess); return (key.WriteValue(name, value.c_str()) == ERROR_SUCCESS); } } @@ -134,29 +134,41 @@ bool GetChromeChannelInternal(bool system_install, bool add_multi_modifier, base::string16* channel) { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - if (dist->GetChromeChannel(channel)) { - return true; - } - HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - base::string16 reg_path = dist->GetStateKey(); - RegKey key(root_key, reg_path.c_str(), KEY_READ | KEY_WOW64_32KEY); + // Shortcut in case this distribution knows what channel it is (canary). + if (dist->GetChromeChannel(channel)) + return true; + // Determine whether or not chrome is multi-install. If so, updates are + // delivered under the binaries' app guid, so that's where the relevant + // channel is found. + installer::ProductState state; installer::ChannelInfo channel_info; - if (!channel_info.Initialize(key)) { - channel->assign(installer::kChromeChannelUnknown); - return false; + ignore_result(state.Initialize(system_install, dist)); + if (!state.is_multi_install()) { + // Use the channel info that was just read for this single-install chrome. + channel_info = state.channel(); + } else { + // Read the channel info from the binaries' state key. + HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + dist = BrowserDistribution::GetSpecificDistribution( + BrowserDistribution::CHROME_BINARIES); + RegKey key(root_key, dist->GetStateKey().c_str(), + KEY_READ | KEY_WOW64_32KEY); + + if (!channel_info.Initialize(key)) { + channel->assign(installer::kChromeChannelUnknown); + return false; + } } - if (!channel_info.GetChannelName(channel)) { + if (!channel_info.GetChannelName(channel)) channel->assign(installer::kChromeChannelUnknown); - } // Tag the channel name if this is a multi-install. - if (add_multi_modifier && channel_info.IsMultiInstall()) { - if (!channel->empty()) { + if (add_multi_modifier && state.is_multi_install()) { + if (!channel->empty()) channel->push_back(L'-'); - } channel->push_back(L'm'); } @@ -226,12 +238,13 @@ bool GoogleUpdateSettings::GetCollectStatsConsentAtLevel(bool system_install) { RegKey key; DWORD value = 0; bool have_value = false; + const REGSAM kAccess = KEY_QUERY_VALUE | KEY_WOW64_32KEY; // For system-level installs, try ClientStateMedium first. have_value = system_install && key.Open(HKEY_LOCAL_MACHINE, dist->GetStateMediumKey().c_str(), - KEY_QUERY_VALUE) == ERROR_SUCCESS && + kAccess) == ERROR_SUCCESS && key.ReadValueDW(google_update::kRegUsageStatsField, &value) == ERROR_SUCCESS; @@ -240,7 +253,7 @@ bool GoogleUpdateSettings::GetCollectStatsConsentAtLevel(bool system_install) { have_value = key.Open(system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, dist->GetStateKey().c_str(), - KEY_QUERY_VALUE) == ERROR_SUCCESS && + kAccess) == ERROR_SUCCESS && key.ReadValueDW(google_update::kRegUsageStatsField, &value) == ERROR_SUCCESS; } @@ -271,7 +284,8 @@ bool GoogleUpdateSettings::SetCollectStatsConsentAtLevel(bool system_install, std::wstring reg_path = system_install ? dist->GetStateMediumKey() : dist->GetStateKey(); RegKey key; - LONG result = key.Create(root_key, reg_path.c_str(), KEY_SET_VALUE); + LONG result = key.Create( + root_key, reg_path.c_str(), KEY_SET_VALUE | KEY_WOW64_32KEY); if (result != ERROR_SUCCESS) { LOG(ERROR) << "Failed opening key " << reg_path << " to set " << google_update::kRegUsageStatsField << "; result: " << result; @@ -303,13 +317,14 @@ bool GoogleUpdateSettings::SetEULAConsent( bool consented) { DCHECK(dist); const DWORD eula_accepted = consented ? 1 : 0; + const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; std::wstring reg_path = dist->GetStateMediumKey(); bool succeeded = true; RegKey key; // Write the consent value into the product's ClientStateMedium key. if (key.Create(HKEY_LOCAL_MACHINE, reg_path.c_str(), - KEY_SET_VALUE) != ERROR_SUCCESS || + kAccess) != ERROR_SUCCESS || key.WriteValue(google_update::kRegEULAAceptedField, eula_accepted) != ERROR_SUCCESS) { succeeded = false; @@ -325,7 +340,7 @@ bool GoogleUpdateSettings::SetEULAConsent( BrowserDistribution::CHROME_BINARIES); reg_path = dist->GetStateMediumKey(); if (key.Create(HKEY_LOCAL_MACHINE, reg_path.c_str(), - KEY_SET_VALUE) != ERROR_SUCCESS || + kAccess) != ERROR_SUCCESS || key.WriteValue(google_update::kRegEULAAceptedField, eula_accepted) != ERROR_SUCCESS) { succeeded = false; @@ -697,7 +712,7 @@ base::string16 GoogleUpdateSettings::GetUninstallCommandLine( RegKey update_key; if (update_key.Open(root_key, google_update::kRegPathGoogleUpdate, - KEY_QUERY_VALUE) == ERROR_SUCCESS) { + KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { update_key.ReadValue(google_update::kRegUninstallCmdLine, &cmd_line); } diff --git a/chrome/installer/util/google_update_settings.h b/chrome/installer/util/google_update_settings.h index c05bf096a3..a2ff11db8e 100644 --- a/chrome/installer/util/google_update_settings.h +++ b/chrome/installer/util/google_update_settings.h @@ -127,7 +127,7 @@ class GoogleUpdateSettings { // assigned to a partner. Returns false if the information is not available. // // NOTE: This function is Windows only. If the code you are writing is not - // specifically for Windows, prefer calling google_util::GetBrand(). + // specifically for Windows, prefer calling google_brand::GetBrand(). static bool GetBrand(std::wstring* brand); // Returns in |brand| the RLZ reactivation brand code or distribution tag @@ -136,7 +136,7 @@ class GoogleUpdateSettings { // // NOTE: This function is Windows only. If the code you are writing is not // specifically for Windows, prefer calling - // google_util::GetReactivationBrand(). + // google_brand::GetReactivationBrand(). static bool GetReactivationBrand(std::wstring* brand); // Returns in |client| the google_update client field, which is currently diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc index 71c0262676..f3ddafc6b5 100644 --- a/chrome/installer/util/google_update_settings_unittest.cc +++ b/chrome/installer/util/google_update_settings_unittest.cc @@ -54,6 +54,37 @@ class GoogleUpdateSettingsTest : public testing::Test { ASSERT_EQ(ERROR_SUCCESS, update_key.WriteValue(L"ap", value)); } + // Sets the "ap" field for a multi-install product (both the product and + // the binaries). + void SetMultiApField(SystemUserInstall is_system, const wchar_t* value) { + // Caller must specify a multi-install ap value. + ASSERT_NE(std::wstring::npos, std::wstring(value).find(L"-multi")); + HKEY root = is_system == SYSTEM_INSTALL ? + HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + RegKey update_key; + + // Write the ap value for both the product and the binaries. + BrowserDistribution* const kDists[] = { + BrowserDistribution::GetDistribution(), + BrowserDistribution::GetSpecificDistribution( + BrowserDistribution::CHROME_BINARIES) + }; + for (size_t i = 0; i < arraysize(kDists); ++i) { + std::wstring path = kDists[i]->GetStateKey(); + ASSERT_EQ(ERROR_SUCCESS, update_key.Create(root, path.c_str(), + KEY_WRITE)); + ASSERT_EQ(ERROR_SUCCESS, update_key.WriteValue(L"ap", value)); + } + + // Make the product technically multi-install. + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + ASSERT_EQ(ERROR_SUCCESS, + update_key.Create(root, dist->GetStateKey().c_str(), KEY_WRITE)); + ASSERT_EQ(ERROR_SUCCESS, + update_key.WriteValue(installer::kUninstallArgumentsField, + L"--multi-install")); + } + // Tests setting the ap= value to various combinations of values with // prefixes and suffixes, while asserting on the correct channel value. // Note that any non-empty ap= value that doesn't match ".*-{dev|beta}.*" @@ -310,6 +341,29 @@ TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelEmptyUser) { EXPECT_STREQ(L"", channel.c_str()); } +// Test that the channel is pulled from the binaries for multi-install products. +TEST_F(GoogleUpdateSettingsTest, MultiInstallChannelFromBinaries) { + SetMultiApField(USER_INSTALL, L"2.0-dev-multi-chrome"); + base::string16 channel; + + EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false, + &channel)); + EXPECT_STREQ(L"dev-m", channel.c_str()); + + // See if the same happens if the product's ap is cleared. + SetApField(USER_INSTALL, L""); + EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false, + &channel)); + EXPECT_STREQ(L"dev-m", channel.c_str()); + + // Test the converse (binaries are stable, Chrome is other). + SetMultiApField(USER_INSTALL, L"-multi-chrome"); + SetApField(USER_INSTALL, L"2.0-dev-multi-chrome"); + EXPECT_TRUE(GoogleUpdateSettings::GetChromeChannelAndModifiers(false, + &channel)); + EXPECT_STREQ(L"m", channel.c_str()); +} + TEST_F(GoogleUpdateSettingsTest, CurrentChromeChannelVariousApValuesSystem) { TestCurrentChromeChannelWithVariousApValues(SYSTEM_INSTALL); } |