summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-11-27 21:46:00 +0100
committerJiří Klimeš <jklimes@redhat.com>2015-11-28 19:48:02 +0100
commit5f9b8b887d36841bf8400c04527f4dce86585849 (patch)
tree1e554f0045f3a2bb98546445f29aa6e05e3f4426
parent1b0be2bab00d77578c5f71101488a8d3a556944f (diff)
downloadNetworkManager-5f9b8b887d36841bf8400c04527f4dce86585849.tar.gz
cli: fix an error in nmcli editor when setting vpn.data/vpn.secrets
nmcli> set vpn.data haha= (process:3951): libnm-CRITICAL **: nm_setting_vpn_add_data_item: assertion 'strlen (item) > 0' failed nmcli> set vpn.secrets haha= (process:3951): libnm-CRITICAL **: nm_setting_vpn_add_secret: assertion 'strlen (secret) > 0' failed
-rw-r--r--clients/cli/settings.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index 7769fc9d2c..d91959196e 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -4423,13 +4423,26 @@ nmc_property_vlan_remove_egress_priority_map (NMSetting *setting,
}
/* --- NM_SETTING_VPN_SETTING_NAME property setter functions --- */
+/* Validate value of vpn 'data' and 'secret' options */
+static const char *
+_validate_vpn_hash_value (const char *option, const char *value, GError **error)
+{
+ /* nm_setting_vpn_add_data_item() and nm_setting_vpn_add_secret() does not
+ * allow empty strings */
+ if (!value || !*value) {
+ g_set_error (error, 1, 0, _("'%s' cannot be empty"), option);
+ return NULL;
+ }
+ return value;
+}
+
/* 'data' */
DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_data,
NM_SETTING_VPN,
NMSettingVpn,
nm_setting_vpn_add_data_item,
NULL,
- NULL)
+ _validate_vpn_hash_value)
DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_data,
NM_SETTING_VPN,
nm_setting_vpn_remove_data_item)
@@ -4440,7 +4453,7 @@ DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_secrets,
NMSettingVpn,
nm_setting_vpn_add_secret,
NULL,
- NULL)
+ _validate_vpn_hash_value)
DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_secret,
NM_SETTING_VPN,
nm_setting_vpn_remove_secret)