From 53aa34047696808806dcba88360cd39b1dff6893 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 26 Oct 2017 19:00:22 +0200 Subject: [PATCH] nmcli: fix wrongly adding a generic setting when constructing connection nmc_read_connection_properties() iterates over the input arguments, and completes the connection. Initially, the type is not yet known, in that case, we should not wrongly assume that this is a generic connection. Later, when the type is specified, con_settings() will return the correct settings. Previously, this would wrongly add a [generic] section: $ nmcli connection add type ethernet ifname eth1 con-name ethie autoconnect no ipv4.method auto ethernet.cloned-mac-address random With the fix, it still works to specify the type later: $ nmcli connection add ifname eth1 con-name ethie autoconnect no ipv4.method auto type ethernet but it doesn't work, to specify the type after type-specific options: $ nmcli connection add ifname eth1 con-name ethie autoconnect no ipv4.method auto ethernet.cloned-mac-address random type ethernet Error: invalid or not allowed setting 'ethernet': 'ethernet' not among [connection, ipv4, ipv6, proxy]. The patch doesn't change the latter limitation. Fixes: c5324ed285aff7d6d58212e4b030a0fc556eb43b --- clients/cli/connections.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 5ef82a4e48..a13af882e2 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -3638,8 +3638,6 @@ con_settings (NMConnection *connection, const NMMetaSettingValidPartItem *const* } con_type = nm_setting_connection_get_connection_type (s_con); - if (!con_type) - con_type = NM_SETTING_GENERIC_SETTING_NAME; *type_settings = get_valid_settings_array (con_type); if (!*type_settings) { g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,