nmcli: drop validation of DNS name in nmcli

Now, nm_setting_ip_config_add_dns() no longer asserts that
the name is a valid DNS nameserver. Instead, that is handled
by nm_connection_verify().

Also, the DNS property is going to be extended to support
specifying the SNI server name for DNS over TLS. The validation
would need to be extended.

Instead, drop the validation from nmcli. nmcli often needs to understand
what is happening. But in this case, it doesn't need to know (or
validate) the exact text. Don't duplicate the validation and let
libnm (or the daemon) reject invalid settings.
This commit is contained in:
Thomas Haller 2022-10-20 12:14:07 +02:00
parent 053d0a0768
commit a20aae326f
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -3449,23 +3449,6 @@ _set_fcn_ip_config_method(ARGS_SET_FCN)
return TRUE;
}
static const char *
_multilist_validate2_fcn_ip_config_dns(NMSetting *setting, const char *value, GError **error)
{
int addr_family = nm_setting_ip_config_get_addr_family(NM_SETTING_IP_CONFIG(setting));
if (!nm_inet_parse_str(addr_family, value, NULL)) {
nm_utils_error_set(error,
NM_UTILS_ERROR_INVALID_ARGUMENT,
_("invalid IPv%c address '%s'"),
nm_utils_addr_family_to_char(addr_family),
value);
return NULL;
}
return value;
}
static gboolean
_multilist_add_fcn_ip_config_dns_options(NMSetting *setting, const char *item)
{
@ -6040,7 +6023,6 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
.add_fcn = MULTILIST_ADD_FCN (NMSettingIPConfig, nm_setting_ip_config_add_dns),
.remove_by_idx_fcn_s = MULTILIST_REMOVE_BY_IDX_FCN_S (NMSettingIPConfig, nm_setting_ip_config_remove_dns),
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingIPConfig, nm_setting_ip_config_remove_dns_by_value),
.validate2_fcn = _multilist_validate2_fcn_ip_config_dns,
.strsplit_plain = TRUE,
),
),
@ -6293,7 +6275,6 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
.add_fcn = MULTILIST_ADD_FCN (NMSettingIPConfig, nm_setting_ip_config_add_dns),
.remove_by_idx_fcn_s = MULTILIST_REMOVE_BY_IDX_FCN_S (NMSettingIPConfig, nm_setting_ip_config_remove_dns),
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingIPConfig, nm_setting_ip_config_remove_dns_by_value),
.validate2_fcn = _multilist_validate2_fcn_ip_config_dns,
.strsplit_plain = TRUE,
),
),