From 598ecbc482edda7a571645cc91216f216285c601 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 25 Mar 2019 17:53:43 +0100 Subject: [PATCH] cli: fix accepting %NULL value for '+' modifier I find it questionable, how nmcli likes to coerce the empty input to NULL to indicate resetting the value. If nmcli would like to set a default, it should use a different way of signalling that. Anyway, the assertion was too strict. $ nmcli connection modify "$PROFILE" +ipv4.addresses '' --- clients/cli/settings.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index aa0a7ff23c..d050e24e28 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -543,13 +543,18 @@ nmc_setting_set_property (NMClient *client, g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (NM_IN_SET (modifier, '\0', '-', '+'), FALSE); - g_return_val_if_fail (value || modifier == '\0', FALSE); if (!(property_info = nm_meta_property_info_find_by_setting (setting, prop))) goto out_fail_read_only; if (!property_info->property_type->set_fcn) goto out_fail_read_only; + if ( NM_IN_SET (modifier, '+', '-') + && !value) { + /* nothing to do. */ + return TRUE; + } + if ( modifier == '-' && !property_info->property_type->set_supports_remove) { /* The property is a plain property. It does not support '-'.