summaryrefslogtreecommitdiff
path: root/clients/common
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-03-20 17:16:06 +0100
committerThomas Haller <thaller@redhat.com>2019-03-25 09:12:33 +0100
commit3a8fe7ad457cf9dbf672e3ca0d719c3e33b524ba (patch)
tree4d6cb20ed4fbc61d2c6245f316a8f941ed5956f2 /clients/common
parent96c4f51208ff41d571557d6a6cb99f418e3fd162 (diff)
downloadNetworkManager-3a8fe7ad457cf9dbf672e3ca0d719c3e33b524ba.tar.gz
cli: consistently validate multilist options for add and remove
There is no reason to validate only in certain cases. Either we validate, or we don't (always the same). This is a change in behavior, but the cases should be sensible.
Diffstat (limited to 'clients/common')
-rw-r--r--clients/common/nm-meta-setting-desc.c39
-rw-r--r--clients/common/nm-meta-setting-desc.h6
2 files changed, 14 insertions, 31 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
index d98ac5c09b..c2e19f5021 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -1807,29 +1807,24 @@ vpn_data_item (const char *key, const char *value, gpointer user_data)
static const char *
_multilist_do_validate (const NMMetaPropertyInfo *property_info,
- gboolean for_set /* else for remove */,
NMSetting *setting,
const char *item,
GError **error)
{
- if ( for_set
- ? property_info->property_typ_data->subtype.multilist.no_validate_add
- : property_info->property_typ_data->subtype.multilist.no_validate_remove_by_value) {
- if (property_info->property_typ_data->values_static) {
- nm_assert (!property_info->property_typ_data->subtype.multilist.validate_fcn);
- return nmc_string_is_valid (item,
- (const char **) property_info->property_typ_data->values_static,
- error);
- }
- if (property_info->property_typ_data->subtype.multilist.validate_fcn) {
- return property_info->property_typ_data->subtype.multilist.validate_fcn (item,
- error);
- }
- if (property_info->property_typ_data->subtype.multilist.validate2_fcn) {
- return property_info->property_typ_data->subtype.multilist.validate2_fcn (setting,
- item,
- error);
- }
+ if (property_info->property_typ_data->values_static) {
+ nm_assert (!property_info->property_typ_data->subtype.multilist.validate_fcn);
+ return nmc_string_is_valid (item,
+ (const char **) property_info->property_typ_data->values_static,
+ error);
+ }
+ if (property_info->property_typ_data->subtype.multilist.validate_fcn) {
+ return property_info->property_typ_data->subtype.multilist.validate_fcn (item,
+ error);
+ }
+ if (property_info->property_typ_data->subtype.multilist.validate2_fcn) {
+ return property_info->property_typ_data->subtype.multilist.validate2_fcn (setting,
+ item,
+ error);
}
return item;
@@ -1885,9 +1880,7 @@ _set_fcn_multilist (ARGS_SET_FCN)
for (i = 0; i < nstrv; i++) {
const char *item = strv[i];
- /* FIXME: don't validate differently for remove/add. */
item = _multilist_do_validate (property_info,
- !_SET_FCN_DO_REMOVE (modifier, value),
setting,
item,
error);
@@ -4920,7 +4913,6 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
.remove_by_idx_fcn_u32 = MULTILIST_REMOVE_BY_IDX_FCN_U32 (NMSettingConnection, nm_setting_connection_remove_secondary),
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingConnection, nm_setting_connection_remove_secondary_by_value),
.validate2_fcn = _multilist_validate2_fcn_uuid,
- .no_validate_add = TRUE,
),
),
),
@@ -5287,7 +5279,6 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
.remove_by_idx_fcn_s = MULTILIST_REMOVE_BY_IDX_FCN_S (NMSettingIPConfig, nm_setting_ip_config_remove_dns_search),
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingIPConfig, nm_setting_ip_config_remove_dns_search_by_value),
.validate_fcn = _multilist_validate_fcn_is_domain,
- .no_validate_remove_by_value = TRUE,
),
),
),
@@ -5479,7 +5470,6 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
.remove_by_idx_fcn_s = MULTILIST_REMOVE_BY_IDX_FCN_S (NMSettingIPConfig, nm_setting_ip_config_remove_dns_search),
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingIPConfig, nm_setting_ip_config_remove_dns_search_by_value),
.validate_fcn = _multilist_validate_fcn_is_domain,
- .no_validate_remove_by_value = TRUE,
),
),
),
@@ -6252,7 +6242,6 @@ static const NMMetaPropertyInfo *const property_infos_TEAM[] = {
.add_fcn = MULTILIST_ADD_FCN (NMSettingTeam, nm_setting_team_add_runner_tx_hash),
.remove_by_idx_fcn_u = MULTILIST_REMOVE_BY_IDX_FCN_U (NMSettingTeam, nm_setting_team_remove_runner_tx_hash),
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingTeam, nm_setting_team_remove_runner_tx_hash_by_value),
- .no_validate_remove_by_value = TRUE,
),
.values_static = NM_MAKE_STRV ("eth", "vlan", "ipv4", "ipv6", "ip",
"l3", "tcp", "udp", "sctp", "l4"),
diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h
index 636c659c72..9a7438c672 100644
--- a/clients/common/nm-meta-setting-desc.h
+++ b/clients/common/nm-meta-setting-desc.h
@@ -280,12 +280,6 @@ struct _NMMetaPropertyTypData {
void (*remove_by_idx_fcn_s) (NMSetting *setting, int idx);
gboolean (*remove_by_value_fcn) (NMSetting *setting, const char *item);
- /* if TRUE, validate_fcn() is ignored for add_fcn(). */
- bool no_validate_add:1;
-
- /* if TRUE, validate_fcn() is ignored for remove_by_value(). */
- bool no_validate_remove_by_value:1;
-
/* if true, separate the list by space and allow backslash escaping. */
bool with_escaped_spaces:1;
} multilist;