Commit e6196cfa authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Network config: Elim bogus profile path unknown errors

Currently calls to FindPolicyByGuidAndProfile produce an error when
called with an empty profile path. There are several places where this
can occur, but we recently added one to the system tray UI:

https://chromium-review.googlesource.com/c/chromium/src/+/1101204/12/ash/system/network/network_list.cc#813

Rather than ensure that we test for an empty profile path everywhere
(which just indicates a non favorite/saved network), just return nullptr
with no error when the path is empty.

Bug: None
Change-Id: I692babc10ae2472e8fa5dbfef1c8be170cc841b2
Reviewed-on: https://chromium-review.googlesource.com/1149096Reviewed-by: default avatarAlexander Hendrich <hendrich@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577936}
parent 1782edbe
...@@ -352,7 +352,6 @@ void AutoConnectHandler::DisconnectAndRemoveBlacklistedNetworks() { ...@@ -352,7 +352,6 @@ void AutoConnectHandler::DisconnectAndRemoveBlacklistedNetworks() {
continue; continue;
const bool is_managed = const bool is_managed =
!network->profile_path().empty() && !network->guid().empty() &&
managed_configuration_handler_->FindPolicyByGuidAndProfile( managed_configuration_handler_->FindPolicyByGuidAndProfile(
network->guid(), network->profile_path(), nullptr /* onc_source */); network->guid(), network->profile_path(), nullptr /* onc_source */);
if (is_managed) if (is_managed)
...@@ -376,7 +375,6 @@ void AutoConnectHandler::DisconnectFromAllUnmanagedWiFiNetworks( ...@@ -376,7 +375,6 @@ void AutoConnectHandler::DisconnectFromAllUnmanagedWiFiNetworks(
false, false, 0, &networks); false, false, 0, &networks);
for (const NetworkState* network : networks) { for (const NetworkState* network : networks) {
const bool is_managed = const bool is_managed =
!network->profile_path().empty() && !network->guid().empty() &&
managed_configuration_handler_->FindPolicyByGuidAndProfile( managed_configuration_handler_->FindPolicyByGuidAndProfile(
network->guid(), network->profile_path(), nullptr /* onc_source */); network->guid(), network->profile_path(), nullptr /* onc_source */);
if (is_managed) if (is_managed)
......
...@@ -778,16 +778,19 @@ ManagedNetworkConfigurationHandlerImpl::FindPolicyByGuidAndProfile( ...@@ -778,16 +778,19 @@ ManagedNetworkConfigurationHandlerImpl::FindPolicyByGuidAndProfile(
const std::string& guid, const std::string& guid,
const std::string& profile_path, const std::string& profile_path,
::onc::ONCSource* onc_source) const { ::onc::ONCSource* onc_source) const {
if (profile_path.empty())
return nullptr;
const NetworkProfile* profile = const NetworkProfile* profile =
network_profile_handler_->GetProfileForPath(profile_path); network_profile_handler_->GetProfileForPath(profile_path);
if (!profile) { if (!profile) {
NET_LOG_ERROR("Profile path unknown:" + profile_path, guid); NET_LOG_ERROR("Profile path unknown:" + profile_path, guid);
return NULL; return nullptr;
} }
const Policies* policies = GetPoliciesForProfile(*profile); const Policies* policies = GetPoliciesForProfile(*profile);
if (!policies) if (!policies)
return NULL; return nullptr;
const base::DictionaryValue* policy = const base::DictionaryValue* policy =
GetByGUID(policies->per_network_config, guid); GetByGUID(policies->per_network_config, guid);
...@@ -816,7 +819,6 @@ bool ManagedNetworkConfigurationHandlerImpl::IsNetworkBlockedByPolicy( ...@@ -816,7 +819,6 @@ bool ManagedNetworkConfigurationHandlerImpl::IsNetworkBlockedByPolicy(
// Check if the network is managed. Managed networks are always allowed. // Check if the network is managed. Managed networks are always allowed.
bool is_managed = bool is_managed =
!profile_path.empty() &&
FindPolicyByGuidAndProfile(guid, profile_path, nullptr /* onc_source */); FindPolicyByGuidAndProfile(guid, profile_path, nullptr /* onc_source */);
if (is_managed) if (is_managed)
return false; return false;
......
...@@ -461,11 +461,9 @@ void NetworkConnectionHandlerImpl::VerifyConfiguredAndConnect( ...@@ -461,11 +461,9 @@ void NetworkConnectionHandlerImpl::VerifyConfiguredAndConnect(
service_properties.GetStringWithoutPathExpansion(shill::kProfileProperty, service_properties.GetStringWithoutPathExpansion(shill::kProfileProperty,
&profile); &profile);
::onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; ::onc::ONCSource onc_source = onc::ONC_SOURCE_NONE;
const base::DictionaryValue* policy = nullptr; const base::DictionaryValue* policy =
if (!profile.empty()) { managed_configuration_handler_->FindPolicyByGuidAndProfile(guid, profile,
policy = managed_configuration_handler_->FindPolicyByGuidAndProfile( &onc_source);
guid, profile, &onc_source);
}
if (type == shill::kTypeWifi) { if (type == shill::kTypeWifi) {
const base::Value* hex_ssid_value = service_properties.FindKeyOfType( const base::Value* hex_ssid_value = service_properties.FindKeyOfType(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment