commit 7d247f78aa1183617a4f1b5427237cef9a8fc648
Author: Pavol Marko <
pma...@google.com>
AuthorDate: Fri Mar 05 05:26:50 2021
Commit: Chromium LUCI CQ <
chromiu...@luci-project-accounts.iam.gserviceaccount.com>
CommitDate: Fri Mar 05 05:26:50 2021
onc_to_shill: Provide an empty StaticIPConfig by default
If neither NameServersConfigType nor IPAddressConfigType is set to
'Static', provide an empty StaticIPConfig dict to shill.
This is reasonable because a missing *ConfigType means 'DHCP', and an
empty StaticIPConfig means DHCP.
A missing StaticIPConfig means 'don't change', so a non-DHCP setting
could persist otherwise.
Bug: 1109660
Change-Id: I9247dbc975fb7dbb4a15c887f0b0846e2d16e061
Reviewed-on:
https://chromium-review.googlesource.com/c/chromium/src/+/2734816
Reviewed-by: Steven Bennetts <
stev...@chromium.org>
Commit-Queue: Pavol Marko <
pma...@chromium.org>
Cr-Commit-Position: refs/heads/master@{#860133}
diff --git a/chromeos/network/onc/onc_translator_onc_to_shill.cc b/chromeos/network/onc/onc_translator_onc_to_shill.cc
index b1f07f0..b2fd18d 100644
--- a/chromeos/network/onc/onc_translator_onc_to_shill.cc
+++ b/chromeos/network/onc/onc_translator_onc_to_shill.cc
@@ -424,11 +424,12 @@
onc_object_, ::onc::network_config::kIPAddressConfigType);
const std::string name_servers_config_type = FindStringKeyOrEmpty(
onc_object_, ::onc::network_config::kNameServersConfigType);
- if ((ip_address_config_type == ::onc::network_config::kIPConfigTypeDHCP) ||
- (name_servers_config_type == ::onc::network_config::kIPConfigTypeDHCP)) {
- // If either type is set to DHCP, provide an empty dictionary to ensure
- // that any unset properties are cleared. Note: if either type is specified,
- // the other type defaults to DHCP if not specified.
+ if ((ip_address_config_type != ::onc::network_config::kIPConfigTypeStatic) &&
+ (name_servers_config_type !=
+ ::onc::network_config::kIPConfigTypeStatic)) {
+ // If neither type is set to Static, provide an empty dictionary to ensure
+ // that any unset properties are cleared. Note: A type defaults to DHCP if
+ // not specified.
shill_dictionary_->SetKey(shill::kStaticIPConfigProperty,
base::Value(base::Value::Type::DICTIONARY));
}
diff --git a/chromeos/test/data/network/policy/shill_managed_vpn_ipsec.json b/chromeos/test/data/network/policy/shill_managed_vpn_ipsec.json
index 088e316..3149c01 100644
--- a/chromeos/test/data/network/policy/shill_managed_vpn_ipsec.json
+++ b/chromeos/test/data/network/policy/shill_managed_vpn_ipsec.json
@@ -6,6 +6,7 @@
"Host": "
vpn.my.domain.com",
"Type": "l2tpipsec"
},
+ "StaticIPConfig": {},
"UIData": "{\"onc_source\":\"user_policy\",\"user_settings\":{}}",
"Type": "vpn"
}
diff --git a/chromeos/test/data/network/policy/shill_policy_autoconnect_on_unconfigured_vpn.json b/chromeos/test/data/network/policy/shill_policy_autoconnect_on_unconfigured_vpn.json
index 76e99a6..c6b1256 100644
--- a/chromeos/test/data/network/policy/shill_policy_autoconnect_on_unconfigured_vpn.json
+++ b/chromeos/test/data/network/policy/shill_policy_autoconnect_on_unconfigured_vpn.json
@@ -18,6 +18,7 @@
},
"SaveCredentials": false,
"State": "idle",
+ "StaticIPConfig": {},
"Type": "vpn",
"UIData": "{\"onc_source\":\"user_policy\"}",
"Visible": true
diff --git a/chromeos/test/data/network/policy/shill_policy_on_managed_vpn.json b/chromeos/test/data/network/policy/shill_policy_on_managed_vpn.json
index 0d71486d..3984f3f 100644
--- a/chromeos/test/data/network/policy/shill_policy_on_managed_vpn.json
+++ b/chromeos/test/data/network/policy/shill_policy_on_managed_vpn.json
@@ -17,6 +17,7 @@
},
"SaveCredentials": false,
"State": "idle",
+ "StaticIPConfig": {},
"Type": "vpn",
"UIData": "{\"onc_source\":\"user_policy\",\"user_settings\":{}}",
"Visible": true
diff --git a/chromeos/test/data/network/policy/shill_policy_on_managed_vpn_ipsec_plus_ui.json b/chromeos/test/data/network/policy/shill_policy_on_managed_vpn_ipsec_plus_ui.json
index bb17ca04..bd447d4 100644
--- a/chromeos/test/data/network/policy/shill_policy_on_managed_vpn_ipsec_plus_ui.json
+++ b/chromeos/test/data/network/policy/shill_policy_on_managed_vpn_ipsec_plus_ui.json
@@ -16,6 +16,7 @@
},
"SaveCredentials": true,
"State": "idle",
+ "StaticIPConfig": {},
"Type": "vpn",
"UIData": "{\"onc_source\":\"user_policy\",\"user_settings\":{\"GUID\":\"{a3860e83-f03d-4cb1-bafa-b22c9e746950}\",\"Name\":\"my vpn\",\"Type\":\"VPN\",\"VPN\":{\"AutoConnect\":false,\"Host\":\"
vpn.my.domain.com\",\"IPsec\":{\"AuthenticationType\":\"PSK\",\"ClientCertType\":\"\",\"PSK\":\"FAKE_CREDENTIAL_VPaJDV9x\"},\"L2TP\":{\"Password\":\"FAKE_CREDENTIAL_VPaJDV9x\"},\"Type\":\"L2TP-IPsec\"}}}",
"Visible": true
diff --git a/chromeos/test/data/network/policy/shill_policy_on_managed_vpn_plus_ui.json b/chromeos/test/data/network/policy/shill_policy_on_managed_vpn_plus_ui.json
index e7702b3..6d3b4c1 100644
--- a/chromeos/test/data/network/policy/shill_policy_on_managed_vpn_plus_ui.json
+++ b/chromeos/test/data/network/policy/shill_policy_on_managed_vpn_plus_ui.json
@@ -18,6 +18,7 @@
},
"SaveCredentials": true,
"State": "idle",
+ "StaticIPConfig": {},
"Type": "vpn",
"UIData": "{\"onc_source\":\"user_policy\",\"user_settings\":{\"GUID\":\"{a3860e83-f03d-4cb1-bafa-b22c9e746950}\",\"Name\":\"my vpn\",\"Type\":\"VPN\",\"VPN\":{\"AutoConnect\":false,\"Host\":\"
vpn.my.domain.com\",\"OpenVPN\":{\"ClientCertPKCS11Id\":\"1:2345\",\"ClientCertType\":\"PKCS11Id\",\"OTP\":\"user OTP\",\"Password\":\"FAKE_CREDENTIAL_VPaJDV9x\",\"SaveCredentials\":true,\"UserAuthenticationType\":\"PasswordAndOTP\",\"Username\":\"user name\"},\"Type\":\"OpenVPN\"}}}",
"Visible": true
diff --git a/chromeos/test/data/network/policy/shill_policy_on_unmanaged_wifi1.json b/chromeos/test/data/network/policy/shill_policy_on_unmanaged_wifi1.json
index 18547d2..fa5baf8 100644
--- a/chromeos/test/data/network/policy/shill_policy_on_unmanaged_wifi1.json
+++ b/chromeos/test/data/network/policy/shill_policy_on_unmanaged_wifi1.json
@@ -8,6 +8,7 @@
"SSID": "policy_wifi1",
"SecurityClass": "psk",
"Type": "wifi",
+ "StaticIPConfig": {},
"UIData": "{\"onc_source\":\"user_policy\",\"user_settings\":{\"WiFi\":{\"Passphrase\":\"FAKE_CREDENTIAL_VPaJDV9x\"}}}",
"Visible":true,
"WiFi.HexSSID": "7769666931" // "wifi1"
diff --git a/chromeos/test/data/network/shill_cellular.json b/chromeos/test/data/network/shill_cellular.json
index f26d223d..3838e7a 100644
--- a/chromeos/test/data/network/shill_cellular.json
+++ b/chromeos/test/data/network/shill_cellular.json
@@ -6,5 +6,6 @@
"authentication": "chap",
"username": "test-username",
"password": "test-password"
- }
+ },
+ "StaticIPConfig": {}
}
diff --git a/chromeos/test/data/network/shill_ethernet_with_eap.json b/chromeos/test/data/network/shill_ethernet_with_eap.json
index 2e9f42b..c3b7632 100644
--- a/chromeos/test/data/network/shill_ethernet_with_eap.json
+++ b/chromeos/test/data/network/shill_ethernet_with_eap.json
@@ -7,5 +7,6 @@
"EAP.UseSystemCAs":true,
"GUID":"guid",
"SaveCredentials":true,
+ "StaticIPConfig": {},
"Type":"etherneteap"
}
diff --git a/chromeos/test/data/network/shill_l2tpipsec.json b/chromeos/test/data/network/shill_l2tpipsec.json
index f9927c8..e5c6693 100644
--- a/chromeos/test/data/network/shill_l2tpipsec.json
+++ b/chromeos/test/data/network/shill_l2tpipsec.json
@@ -13,5 +13,6 @@
"L2TPIPsec.User": "some username",
"L2TPIPsec.XauthPassword": "some xauth password",
"L2TPIPsec.XauthUser": "some xauth username",
- "SaveCredentials": true
+ "SaveCredentials": true,
+ "StaticIPConfig": {}
}
diff --git a/chromeos/test/data/network/shill_l2tpipsec_clientcert.json b/chromeos/test/data/network/shill_l2tpipsec_clientcert.json
index a6ba4d5..83bc336 100644
--- a/chromeos/test/data/network/shill_l2tpipsec_clientcert.json
+++ b/chromeos/test/data/network/shill_l2tpipsec_clientcert.json
@@ -12,5 +12,6 @@
"Provider.Host": "
some.host.org",
"Provider.Type": "l2tpipsec",
"SaveCredentials": true,
+ "StaticIPConfig": {},
"Type": "vpn",
}
diff --git a/chromeos/test/data/network/shill_openvpn.json b/chromeos/test/data/network/shill_openvpn.json
index c98ec42..7cfd223 100644
--- a/chromeos/test/data/network/shill_openvpn.json
+++ b/chromeos/test/data/network/shill_openvpn.json
@@ -35,5 +35,6 @@
"Provider.Host":"
vpn.my.domain.com",
"Provider.Type":"openvpn",
"SaveCredentials":false,
+ "StaticIPConfig": {},
"Type":"vpn"
}
diff --git a/chromeos/test/data/network/shill_openvpn_clientcert.json b/chromeos/test/data/network/shill_openvpn_clientcert.json
index 0400fbf..f3ed75c3 100644
--- a/chromeos/test/data/network/shill_openvpn_clientcert.json
+++ b/chromeos/test/data/network/shill_openvpn_clientcert.json
@@ -17,5 +17,6 @@
"Provider.Type": "openvpn",
"ProxyConfig": "{\"mode\":\"direct\"}",
"SaveCredentials": true,
+ "StaticIPConfig": {},
"Type": "vpn",
}
diff --git a/chromeos/test/data/network/shill_openvpn_clientcert_pkcs11.json b/chromeos/test/data/network/shill_openvpn_clientcert_pkcs11.json
index cbda8fa..c14fb79 100644
--- a/chromeos/test/data/network/shill_openvpn_clientcert_pkcs11.json
+++ b/chromeos/test/data/network/shill_openvpn_clientcert_pkcs11.json
@@ -10,5 +10,6 @@
"Provider.Type": "openvpn",
"ProxyConfig": "{\"mode\":\"direct\"}",
"SaveCredentials": true,
+ "StaticIPConfig": {},
"Type": "vpn",
}
diff --git a/chromeos/test/data/network/shill_openvpn_compression_algorithm_lzo.json b/chromeos/test/data/network/shill_openvpn_compression_algorithm_lzo.json
index 2894cc22..ef1afa1 100644
--- a/chromeos/test/data/network/shill_openvpn_compression_algorithm_lzo.json
+++ b/chromeos/test/data/network/shill_openvpn_compression_algorithm_lzo.json
@@ -22,5 +22,6 @@
"Provider.Host":"
vpn.my.domain.com",
"Provider.Type":"openvpn",
"SaveCredentials":false,
+ "StaticIPConfig": {},
"Type":"vpn"
}
diff --git a/chromeos/test/data/network/shill_openvpn_compression_algorithm_none.json b/chromeos/test/data/network/shill_openvpn_compression_algorithm_none.json
index 2383511..eb512c1 100644
--- a/chromeos/test/data/network/shill_openvpn_compression_algorithm_none.json
+++ b/chromeos/test/data/network/shill_openvpn_compression_algorithm_none.json
@@ -22,5 +22,6 @@
"Provider.Host":"
vpn.my.domain.com",
"Provider.Type":"openvpn",
"SaveCredentials":false,
+ "StaticIPConfig": {},
"Type":"vpn"
}
diff --git a/chromeos/test/data/network/shill_third_party_vpn.json b/chromeos/test/data/network/shill_third_party_vpn.json
index 9ee0fe0..5ed0c75d 100644
--- a/chromeos/test/data/network/shill_third_party_vpn.json
+++ b/chromeos/test/data/network/shill_third_party_vpn.json
@@ -3,4 +3,5 @@
"Name": "third-party VPN",
"Provider.Host": "deadbeefdeadbeefdeadbeefdeadbeef",
"Provider.Type": "thirdpartyvpn",
+ "StaticIPConfig": {}
}
diff --git a/chromeos/test/data/network/shill_vpn_ipsec_clientcert_pkcs11.json b/chromeos/test/data/network/shill_vpn_ipsec_clientcert_pkcs11.json
index e7671184..a53bcd4 100644
--- a/chromeos/test/data/network/shill_vpn_ipsec_clientcert_pkcs11.json
+++ b/chromeos/test/data/network/shill_vpn_ipsec_clientcert_pkcs11.json
@@ -10,5 +10,6 @@
"Provider.Type": "l2tpipsec",
"ProxyConfig": "{\"mode\":\"direct\"}",
"SaveCredentials": true,
+ "StaticIPConfig": {},
"Type": "vpn",
}
diff --git a/chromeos/test/data/network/shill_wifi_clientcert.json b/chromeos/test/data/network/shill_wifi_clientcert.json
index 30e9f35..96951c9e 100644
--- a/chromeos/test/data/network/shill_wifi_clientcert.json
+++ b/chromeos/test/data/network/shill_wifi_clientcert.json
@@ -11,6 +11,7 @@
"ProxyConfig": "{\"mode\":\"pac_script\",\"pac_mandatory\":false,\"pac_url\":\"
https://proxycfg.my.domain.com/proxy.dat\"}",
"SaveCredentials": true,
"SecurityClass": "802_1x",
+ "StaticIPConfig": {},
"Type": "wifi",
"WiFi.HexSSID": "4F70656E577274" // "OpenWrt"
}
diff --git a/chromeos/test/data/network/shill_wifi_clientref.json b/chromeos/test/data/network/shill_wifi_clientref.json
index 9dd9a9f..bc1405a 100644
--- a/chromeos/test/data/network/shill_wifi_clientref.json
+++ b/chromeos/test/data/network/shill_wifi_clientref.json
@@ -10,6 +10,7 @@
"ProxyConfig": "{\"mode\":\"pac_script\",\"pac_mandatory\":false,\"pac_url\":\"
https://proxycfg.my.domain.com/proxy.dat\"}",
"SaveCredentials": true,
"SecurityClass": "802_1x",
+ "StaticIPConfig": {},
"Type": "wifi",
"WiFi.HexSSID": "4F70656E577274", // "OpenWrt"
}
diff --git a/chromeos/test/data/network/shill_wifi_eap_tls.json b/chromeos/test/data/network/shill_wifi_eap_tls.json
index eff54f7..6e47e56 100644
--- a/chromeos/test/data/network/shill_wifi_eap_tls.json
+++ b/chromeos/test/data/network/shill_wifi_eap_tls.json
@@ -18,5 +18,6 @@
"Mode": "managed",
"SaveCredentials": true,
"SecurityClass": "802_1x",
+ "StaticIPConfig": {},
"Type": "wifi",
}
diff --git a/chromeos/test/data/network/shill_wifi_eap_ttls.json b/chromeos/test/data/network/shill_wifi_eap_ttls.json
index 074ed12..78f02bb 100644
--- a/chromeos/test/data/network/shill_wifi_eap_ttls.json
+++ b/chromeos/test/data/network/shill_wifi_eap_ttls.json
@@ -10,5 +10,6 @@
"Mode": "managed",
"SaveCredentials": true,
"SecurityClass": "802_1x",
+ "StaticIPConfig": {},
"Type": "wifi"
}
diff --git a/chromeos/test/data/network/shill_wifi_eap_ttls_with_hardcoded_password.json b/chromeos/test/data/network/shill_wifi_eap_ttls_with_hardcoded_password.json
index fc952cf3..1c2623a 100644
--- a/chromeos/test/data/network/shill_wifi_eap_ttls_with_hardcoded_password.json
+++ b/chromeos/test/data/network/shill_wifi_eap_ttls_with_hardcoded_password.json
@@ -11,5 +11,6 @@
"Mode": "managed",
"SaveCredentials": true,
"SecurityClass": "802_1x",
+ "StaticIPConfig": {},
"Type": "wifi"
}
diff --git a/chromeos/test/data/network/shill_wifi_eap_ttls_with_password_variable.json b/chromeos/test/data/network/shill_wifi_eap_ttls_with_password_variable.json
index 73b6e4e..b6cba7a 100644
--- a/chromeos/test/data/network/shill_wifi_eap_ttls_with_password_variable.json
+++ b/chromeos/test/data/network/shill_wifi_eap_ttls_with_password_variable.json
@@ -12,5 +12,6 @@
"Mode": "managed",
"SaveCredentials": true,
"SecurityClass": "802_1x",
+ "StaticIPConfig": {},
"Type": "wifi"
}
diff --git a/chromeos/test/data/network/shill_wifi_proxy.json b/chromeos/test/data/network/shill_wifi_proxy.json
index 47b8716..439f539 100644
--- a/chromeos/test/data/network/shill_wifi_proxy.json
+++ b/chromeos/test/data/network/shill_wifi_proxy.json
@@ -2,5 +2,6 @@
"Mode": "managed",
"ProxyConfig": "{\"bypass_list\":\"\\u003Clocal>;
google.com;\",\"mode\":\"fixed_servers\",\"server\":\"ftp=ftp.example.com:5678;http=http.example.com:1234;socks=socks5://socks.example.com:7890;https=
https.example.com:3456\"}",
"SecurityClass": "none",
+ "StaticIPConfig": {},
"Type": "wifi",
}
diff --git a/chromeos/test/data/network/shill_wifi_proxy_pac.json b/chromeos/test/data/network/shill_wifi_proxy_pac.json
index 1d5c22a..112f204 100644
--- a/chromeos/test/data/network/shill_wifi_proxy_pac.json
+++ b/chromeos/test/data/network/shill_wifi_proxy_pac.json
@@ -2,5 +2,6 @@
"Mode": "managed",
"ProxyConfig": "{\"mode\":\"pac_script\",\"pac_mandatory\":false,\"pac_url\":\"
http://pac.foo.com/script.pac\"}",
"SecurityClass": "none",
+ "StaticIPConfig": {},
"Type": "wifi",
}
diff --git a/chromeos/test/data/network/shill_wifi_psk.json b/chromeos/test/data/network/shill_wifi_psk.json
index bb9268b..7fe7105 100644
--- a/chromeos/test/data/network/shill_wifi_psk.json
+++ b/chromeos/test/data/network/shill_wifi_psk.json
@@ -5,6 +5,7 @@
"Passphrase": "some passphrase",
"ProxyConfig": "{\"mode\":\"fixed_servers\",\"server\":\"ftp=192.168.2.1:8889;http=192.168.2.1:8889;socks=socks4://192.168.2.1:8889;https=
192.168.2.1:8889\"}",
"SecurityClass": "psk",
+ "StaticIPConfig": {},
"Type": "wifi",
"WiFi.HexSSID": "4F70656E577274", // "OpenWrt"
"WiFi.HiddenSSID": false,
diff --git a/chromeos/test/data/network/shill_wifi_wep_8021x_clientcert.json b/chromeos/test/data/network/shill_wifi_wep_8021x_clientcert.json
index 3330f84..419a4c3 100644
--- a/chromeos/test/data/network/shill_wifi_wep_8021x_clientcert.json
+++ b/chromeos/test/data/network/shill_wifi_wep_8021x_clientcert.json
@@ -12,6 +12,7 @@
"ProxyConfig": "{\"mode\":\"pac_script\",\"pac_mandatory\":false,\"pac_url\":\"
https://proxycfg.my.domain.com/proxy.dat\"}",
"SaveCredentials": true,
"SecurityClass": "wep",
+ "StaticIPConfig": {},
"Type": "wifi",
"WiFi.HexSSID": "4F70656E577274" // "OpenWrt"
}