summaryrefslogtreecommitdiffstats
path: root/chromeos/network/shill_property_util.cc
diff options
context:
space:
mode:
authorpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-16 21:45:10 +0000
committerpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-16 21:45:10 +0000
commit154004e9dc42710e8c4d0325fbe943fa4e864e2b (patch)
tree3f8966780980652e3afa0cc0b9dc6757535355b0 /chromeos/network/shill_property_util.cc
parentb4aedfa6eeb39f1ef96fe0563cabfb67935be327 (diff)
downloadchromium_src-154004e9dc42710e8c4d0325fbe943fa4e864e2b.zip
chromium_src-154004e9dc42710e8c4d0325fbe943fa4e864e2b.tar.gz
chromium_src-154004e9dc42710e8c4d0325fbe943fa4e864e2b.tar.bz2
Fix VPN identifying properties during policy application.
The policy application code didn't respect the fact that VPN properties are written differently than being read. BUG=365392 Review URL: https://codereview.chromium.org/319693002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277543 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/network/shill_property_util.cc')
-rw-r--r--chromeos/network/shill_property_util.cc54
1 files changed, 35 insertions, 19 deletions
diff --git a/chromeos/network/shill_property_util.cc b/chromeos/network/shill_property_util.cc
index d9e1054..3104a5e 100644
--- a/chromeos/network/shill_property_util.cc
+++ b/chromeos/network/shill_property_util.cc
@@ -238,6 +238,7 @@ void SetUIData(const NetworkUIData& ui_data,
}
bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties,
+ const bool properties_read_from_shill,
base::DictionaryValue* dest) {
bool success = true;
@@ -265,25 +266,33 @@ bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties,
} else if (type == shill::kTypeVPN) {
success &= CopyStringFromDictionary(
service_properties, shill::kNameProperty, dest);
+
// VPN Provider values are read from the "Provider" dictionary, but written
// with the keys "Provider.Type" and "Provider.Host".
- const base::DictionaryValue* provider_properties = NULL;
- if (!service_properties.GetDictionaryWithoutPathExpansion(
- shill::kProviderProperty, &provider_properties)) {
- NET_LOG_ERROR("Missing VPN provider dict",
- GetNetworkIdFromProperties(service_properties));
- return false;
- }
+ // TODO(pneubeck): Simplify this once http://crbug.com/381135 is fixed.
std::string vpn_provider_type;
- provider_properties->GetStringWithoutPathExpansion(shill::kTypeProperty,
- &vpn_provider_type);
+ std::string vpn_provider_host;
+ if (properties_read_from_shill) {
+ const base::DictionaryValue* provider_properties = NULL;
+ if (!service_properties.GetDictionaryWithoutPathExpansion(
+ shill::kProviderProperty, &provider_properties)) {
+ NET_LOG_ERROR("Missing VPN provider dict",
+ GetNetworkIdFromProperties(service_properties));
+ }
+ provider_properties->GetStringWithoutPathExpansion(shill::kTypeProperty,
+ &vpn_provider_type);
+ provider_properties->GetStringWithoutPathExpansion(shill::kHostProperty,
+ &vpn_provider_host);
+ } else {
+ service_properties.GetStringWithoutPathExpansion(
+ shill::kProviderTypeProperty, &vpn_provider_type);
+ service_properties.GetStringWithoutPathExpansion(
+ shill::kProviderHostProperty, &vpn_provider_host);
+ }
success &= !vpn_provider_type.empty();
dest->SetStringWithoutPathExpansion(shill::kProviderTypeProperty,
vpn_provider_type);
- std::string vpn_provider_host;
- provider_properties->GetStringWithoutPathExpansion(shill::kHostProperty,
- &vpn_provider_host);
success &= !vpn_provider_host.empty();
dest->SetStringWithoutPathExpansion(shill::kProviderHostProperty,
vpn_provider_host);
@@ -301,16 +310,23 @@ bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties,
return success;
}
-bool DoIdentifyingPropertiesMatch(const base::DictionaryValue& properties_a,
- const base::DictionaryValue& properties_b) {
- base::DictionaryValue identifying_a;
- if (!CopyIdentifyingProperties(properties_a, &identifying_a))
+bool DoIdentifyingPropertiesMatch(const base::DictionaryValue& new_properties,
+ const base::DictionaryValue& old_properties) {
+ base::DictionaryValue new_identifying;
+ if (!CopyIdentifyingProperties(
+ new_properties,
+ false /* properties were not read from Shill */,
+ &new_identifying)) {
return false;
- base::DictionaryValue identifying_b;
- if (!CopyIdentifyingProperties(properties_b, &identifying_b))
+ }
+ base::DictionaryValue old_identifying;
+ if (!CopyIdentifyingProperties(old_properties,
+ true /* properties were read from Shill */,
+ &old_identifying)) {
return false;
+ }
- return identifying_a.Equals(&identifying_b);
+ return new_identifying.Equals(&old_identifying);
}
bool IsPassphraseKey(const std::string& key) {