diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2015-11-27 21:46:00 +0100 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2015-11-28 19:56:20 +0100 |
commit | 00bfaa4ed7c45e7fa532cd21e73139a95eac41ed (patch) | |
tree | 60d82cb61f73d12f2329a6079daa76bf57a4c156 | |
parent | 9012e61bfb24eb3036f6d20c644ab4b00b4e3b9a (diff) | |
download | NetworkManager-00bfaa4ed7c45e7fa532cd21e73139a95eac41ed.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
(cherry picked from commit 5f9b8b887d36841bf8400c04527f4dce86585849)
-rw-r--r-- | clients/cli/settings.c | 17 |
1 files 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) |