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 ''
This commit is contained in:
Thomas Haller 2019-03-25 17:53:43 +01:00
parent 02ae0fd00a
commit 598ecbc482

View file

@ -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 '-'.