summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2022-02-21 11:00:13 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2022-02-21 17:57:31 +0100
commit5b4ce608d4db331cad0a891976a0bbce975e61f0 (patch)
treeadbf103b0715dc27c7b443e86a94641ea4f72916
parentb610bdf66e45cbae67930d7281993a42981bff0a (diff)
downloadNetworkManager-5b4ce608d4db331cad0a891976a0bbce975e61f0.tar.gz
cli: don't reset default values in interactive add
Since commit 40032f461415 ('cli: fix resetting values via property alias'), nmcli sets NULL properties during interactive add (nmcli -a connection add) when the user leaves the field blank. This can lead to an invalid connection for properties that can't be empty like infiniband.transport-mode; they should be left to the default value in case of no value entered. Fixes: 40032f461415 ('cli: fix resetting values via property alias') Fixes-test: @inf_create_port_novice_mode https://bugzilla.redhat.com/show_bug.cgi?id=2053603 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1111
-rw-r--r--src/nmcli/connections.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c
index 5a66b82f68..559dc7dbc0 100644
--- a/src/nmcli/connections.c
+++ b/src/nmcli/connections.c
@@ -4189,6 +4189,7 @@ set_option(NmCli *nmc,
NMConnection *connection,
const NMMetaAbstractInfo *abstract_info,
const char *value,
+ gboolean allow_reset,
GError **error)
{
const char *setting_name, *property_name, *option_name;
@@ -4209,7 +4210,7 @@ set_option(NmCli *nmc,
NULL);
if (option && option->check_and_set) {
return option->check_and_set(nmc, connection, option, value, error);
- } else {
+ } else if (value || allow_reset) {
set_property(nmc->client,
connection,
setting_name,
@@ -5199,7 +5200,7 @@ nmc_process_connection_properties(NmCli *nmc,
if (!*argc && nmc->complete)
complete_option(nmc, chosen, value ?: "", connection);
- if (!set_option(nmc, connection, chosen, value, error))
+ if (!set_option(nmc, connection, chosen, value, TRUE, error))
return FALSE;
} while (*argc);
@@ -5410,7 +5411,7 @@ again:
if (multi && !value)
return;
- if (!set_option(nmc, connection, abstract_info, value, &error)) {
+ if (!set_option(nmc, connection, abstract_info, value, FALSE, &error)) {
g_printerr("%s\n", error->message);
g_clear_error(&error);
goto again;