From 00bfaa4ed7c45e7fa532cd21e73139a95eac41ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Fri, 27 Nov 2015 21:46:00 +0100 Subject: [PATCH] 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 (cherry picked from commit 5f9b8b887d36841bf8400c04527f4dce86585849) --- clients/cli/settings.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 8a6b5fa886..7871055968 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -4150,13 +4150,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) @@ -4167,7 +4180,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)