From 3f9fdcbca2966ba2d4a64f2914ce7b0740787c17 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Apr 2016 14:44:09 +0200 Subject: [PATCH 01/10] utils: refactor _nm_utils_ascii_str_to_int64() To allow for trailing whitespace, we don't need to copy and trunacate the input string. g_ascii_strtoll() conveniently returns the location via the endptr argument. (cherry picked from commit 05478e4f4cb1bf8600f3211a9b2983b9e4c43152) --- shared/nm-shared-utils.c | 47 ++++++++++------------------------------ 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/shared/nm-shared-utils.c b/shared/nm-shared-utils.c index 932b7432c3..38f6529d2a 100644 --- a/shared/nm-shared-utils.c +++ b/shared/nm-shared-utils.c @@ -45,8 +45,7 @@ gint64 _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 max, gint64 fallback) { gint64 v; - size_t len; - char buf[64], *s, *str_free = NULL; + char *s = NULL; if (str) { while (g_ascii_isspace (str[0])) @@ -57,46 +56,24 @@ _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 ma return fallback; } - len = strlen (str); - if (g_ascii_isspace (str[--len])) { - /* backward search the first non-ws character. - * We already know that str[0] is non-ws. */ - while (g_ascii_isspace (str[--len])) - ; - - /* str[len] is now the last non-ws character... */ - len++; - - if (len >= sizeof (buf)) - s = str_free = g_malloc (len + 1); - else - s = buf; - - memcpy (s, str, len); - s[len] = 0; - - nm_assert (len > 0 && len < strlen (str) && len == strlen (s)); - nm_assert (!g_ascii_isspace (str[len-1]) && g_ascii_isspace (str[len])); - nm_assert (strncmp (str, s, len) == 0); - - str = s; - } - errno = 0; v = g_ascii_strtoll (str, &s, base); if (errno != 0) - v = fallback; - else if (s[0] != 0) { - errno = EINVAL; - v = fallback; - } else if (v > max || v < min) { + return fallback; + if (s[0] != '\0') { + while (g_ascii_isspace (s[0])) + s++; + if (s[0] != '\0') { + errno = EINVAL; + return fallback; + } + } + if (v > max || v < min) { errno = ERANGE; - v = fallback; + return fallback; } - if (G_UNLIKELY (str_free)) - g_free (str_free); return v; } From 7c135d57d040773c2f5f372d7548976217ed552c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Apr 2016 11:53:33 +0200 Subject: [PATCH 02/10] device: allow reapply if connection.id differs (cherry picked from commit ad38a1acb8827dd2906c8d593313c6f9f931e55f) --- src/devices/nm-device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 692ffa7ba4..1ec648a62c 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7317,6 +7317,7 @@ reapply_connection (NMDevice *self, if (!_hash_check_invalid_keys (diffs ? g_hash_table_lookup (diffs, NM_SETTING_CONNECTION_SETTING_NAME) : NULL, NM_SETTING_CONNECTION_SETTING_NAME, error, + NM_SETTING_CONNECTION_ID, NM_SETTING_CONNECTION_ZONE, NM_SETTING_CONNECTION_METERED)) return FALSE; From ffb757083c345ea4f2bf09898e7c9e039fe5a41c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Apr 2016 12:14:31 +0200 Subject: [PATCH 03/10] device: allow reapply with a different connection.uuid (cherry picked from commit ec840b0331e93faab6ad2e04fb0796b19caa52ee) --- src/devices/nm-device.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 1ec648a62c..8a7eb7d558 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7314,10 +7314,16 @@ reapply_connection (NMDevice *self, NM_SETTING_CONNECTION_SETTING_NAME)) return FALSE; + /* whitelist allowed properties from "connection" setting which are allowed to differ. + * + * This includes UUID, there is no principal problem with reapplying a connection + * and changing it's UUID. In fact, disallowing it makes it cumbersome for the user + * to reapply any connection but the original settings-connection. */ if (!_hash_check_invalid_keys (diffs ? g_hash_table_lookup (diffs, NM_SETTING_CONNECTION_SETTING_NAME) : NULL, NM_SETTING_CONNECTION_SETTING_NAME, error, NM_SETTING_CONNECTION_ID, + NM_SETTING_CONNECTION_UUID, NM_SETTING_CONNECTION_ZONE, NM_SETTING_CONNECTION_METERED)) return FALSE; From ba3f9879dcf05f174ae881581b732c9f317a52b8 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Apr 2016 12:34:17 +0200 Subject: [PATCH 04/10] device: clear secrets from applied connection during reapply The applied connection must have no secrets. It's unclear whether there are any secrets at this point (possibly). To be sure, clear them. (cherry picked from commit b52d25e129e30e15ee8d63792d3549fb3ec1ab04) --- src/devices/nm-device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 8a7eb7d558..cc9dda266e 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7352,6 +7352,7 @@ reapply_connection (NMDevice *self, con_old = applied_clone = nm_simple_connection_new_clone (applied); con_new = applied; nm_connection_replace_settings_from_connection (applied, connection); + nm_connection_clear_secrets (applied); } else con_old = con_new = applied; From 16d0cc332a58c83894868ee373d87c45aca56bbb Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Apr 2016 12:49:43 +0200 Subject: [PATCH 05/10] device: fix check for invalid keys during reapply Was completely wrong and failed to find first_invalid_key. As a consequence, hit the assertion at the end. (cherry picked from commit a51b947f252953e2c5ea75dea60fc38de101872b) --- src/devices/nm-device.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index cc9dda266e..7c1e0471fe 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7178,14 +7178,10 @@ _hash_check_invalid_keys_impl (GHashTable *hash, const char *setting_name, GErro g_hash_table_iter_init (&iter, hash); while (g_hash_table_iter_next (&iter, (gpointer *) &k, NULL)) { - for (i = 0; argv[i]; i++) { - if (!strcmp (argv[i], k)) { - first_invalid_key = k; - break; - } - } - if (first_invalid_key) + if (_nm_utils_strv_find_first ((char **) argv, -1, k) < 0) { + first_invalid_key = k; break; + } } g_set_error (error, NM_DEVICE_ERROR, From 4a1b7f40c63c08a1d4ea0ebb61e2aaa79bf50994 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Apr 2016 12:56:25 +0200 Subject: [PATCH 06/10] device: improve error message for failure to reapply (cherry picked from commit c71bd9df82531e00940602ac91c78675336fecbe) --- src/devices/nm-device.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 7c1e0471fe..226e8f5970 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7183,13 +7183,20 @@ _hash_check_invalid_keys_impl (GHashTable *hash, const char *setting_name, GErro break; } } - g_set_error (error, - NM_DEVICE_ERROR, - NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, - "Can't reapply changes to '%s%s%s' setting", - setting_name ? : "", - setting_name ? "." : "", - first_invalid_key ? : ""); + if (setting_name) { + g_set_error (error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + "Can't reapply changes to '%s.%s' setting", + setting_name, + first_invalid_key); + } else { + g_set_error (error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + "Can't reapply any changes to '%s' setting", + first_invalid_key); + } g_return_val_if_fail (first_invalid_key, FALSE); return FALSE; } From fb67273dc5b70dd4431f1f3442b8b0e5405d102c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Apr 2016 13:46:18 +0200 Subject: [PATCH 07/10] cli: refactor cleanup in do_device_reapply() (cherry picked from commit b217b68b8084d68d1b1a72b7a0a1d4382a1587ec) --- clients/cli/devices.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/clients/cli/devices.c b/clients/cli/devices.c index ec8d235b9c..0ffaa2b899 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -1847,7 +1847,7 @@ reapply_device_cb (GObject *object, GAsyncResult *result, gpointer user_data) if (nmc->print_output == NMC_PRINT_PRETTY) nmc_terminal_erase_line (); g_print (_("Connection successfully reapplied to device '%s'.\n"), - nm_device_get_iface (device)); + nm_device_get_iface (device)); device_cb_info_finish (info, device); } } @@ -1855,11 +1855,12 @@ reapply_device_cb (GObject *object, GAsyncResult *result, gpointer user_data) static NMCResultCode do_device_reapply (NmCli *nmc, int argc, char **argv) { - NMDevice **devices; + gs_free NMDevice **devices = NULL; NMDevice *device; DeviceCbInfo *info = NULL; - GSList *queue = NULL, *iter; - char **arg_arr = NULL; + gs_free_slist GSList *queue = NULL; + GSList *iter; + gs_strfreev char **arg_arr = NULL; char **arg_ptr = argv; int arg_num = argc; int i; @@ -1878,7 +1879,7 @@ do_device_reapply (NmCli *nmc, int argc, char **argv) if (arg_num == 0) { g_string_printf (nmc->return_text, _("Error: No interface specified.")); nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; - goto error; + return nmc->return_value; } } @@ -1906,12 +1907,11 @@ do_device_reapply (NmCli *nmc, int argc, char **argv) /* Take next argument */ next_arg (&arg_num, &arg_ptr); } - g_free (devices); if (!queue) { g_string_printf (nmc->return_text, _("Error: no valid device provided.")); nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND; - goto error; + return nmc->return_value; } queue = g_slist_reverse (queue); @@ -1930,9 +1930,6 @@ do_device_reapply (NmCli *nmc, int argc, char **argv) nm_device_reapply_async (device, NULL, 0, 0, NULL, reapply_device_cb, info); } -error: - g_strfreev (arg_arr); - g_slist_free (queue); return nmc->return_value; } From 4877a76d1c229e1ab15f5ce52d6050a57301b79f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Apr 2016 14:14:31 +0200 Subject: [PATCH 08/10] cli: don't allow multiple arguments to device-reapply Just like `nmcli device connect` only allows one argument, don't allow multiple device arguments for reapply. Allowing multiple device names makes it more complicated to add additional options to the command. For example, it would be useful to have a nmcli device reapply eth0 connection id other-connection but when allowing multiple device names, it gets more complicated in documentation, command line parsing and bash completion. Note that the user can achieve a very similar outcome by using the shell: for DEV in eth0 eth1 eth2; do nmcli device reapply $DEV & done wait argubaly, this doesn't report the exit status properly. To properly handle that would require more effort. Also, it is somewhat less efficient, but well. This is an API change, however it is very new API that probably nobody is using much. Also, the documentation (man nmcli) didn't mention the possibility to pass multiple device names. (cherry picked from commit d742ea78178726ea22a7f112a26a461f33b95265) --- clients/cli/devices.c | 81 ++++++++++++++---------------------- clients/cli/nmcli-completion | 2 +- 2 files changed, 32 insertions(+), 51 deletions(-) diff --git a/clients/cli/devices.c b/clients/cli/devices.c index 0ffaa2b899..d14807b48c 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -286,7 +286,7 @@ usage (void) " show []\n\n" " set [ifname] [autoconnect yes|no] [managed yes|no]\n\n" " connect \n\n" - " reapply ...\n\n" + " reapply \n\n" " disconnect ...\n\n" " delete ...\n\n" " monitor ...\n\n" @@ -342,7 +342,7 @@ usage_device_reapply (void) { g_printerr (_("Usage: nmcli device reapply { ARGUMENTS | help }\n" "\n" - "ARGUMENTS := ...\n" + "ARGUMENTS := \n" "\n" "Attempts to update device with changes to the currently active connection\n" "made since it was last applied.\n\n")); @@ -1835,11 +1835,10 @@ reapply_device_cb (GObject *object, GAsyncResult *result, gpointer user_data) GError *error = NULL; if (!nm_device_reapply_finish (device, result, &error)) { - g_string_printf (nmc->return_text, _("Error: not all connections reapplied.")); - g_printerr (_("Error: Reapplying connection to device '%s' (%s) failed: %s\n"), - nm_device_get_iface (device), - nm_object_get_path (NM_OBJECT (device)), - error->message); + g_string_printf (nmc->return_text, _("Error: Reapplying connection to device '%s' (%s) failed: %s"), + nm_device_get_iface (device), + nm_object_get_path (NM_OBJECT (device)), + error->message); g_error_free (error); nmc->return_value = NMC_RESULT_ERROR_DEV_DISCONNECT; device_cb_info_finish (info, device); @@ -1856,14 +1855,13 @@ static NMCResultCode do_device_reapply (NmCli *nmc, int argc, char **argv) { gs_free NMDevice **devices = NULL; - NMDevice *device; + NMDevice *device = NULL; DeviceCbInfo *info = NULL; - gs_free_slist GSList *queue = NULL; - GSList *iter; - gs_strfreev char **arg_arr = NULL; char **arg_ptr = argv; int arg_num = argc; int i; + gs_free char *device_name_free = NULL; + const char *device_name = NULL; /* Set default timeout for reapply operation. */ if (nmc->timeout == -1) @@ -1871,64 +1869,47 @@ do_device_reapply (NmCli *nmc, int argc, char **argv) if (argc == 0) { if (nmc->ask) { - char *line = nmc_readline (PROMPT_INTERFACES); - nmc_string_to_arg_array (line, NULL, FALSE, &arg_arr, &arg_num); - g_free (line); - arg_ptr = arg_arr; + device_name_free = nmc_readline (PROMPT_INTERFACE); + device_name = device_name_free; } - if (arg_num == 0) { + if (!device_name) { g_string_printf (nmc->return_text, _("Error: No interface specified.")); nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; return nmc->return_value; } + } else if (argc == 1) { + device_name = arg_ptr[0]; + next_arg (&arg_num, &arg_ptr); + } else { + next_arg (&arg_num, &arg_ptr); + g_string_printf (nmc->return_text, _("Error: unsupported argument '%s'."), *arg_ptr); + nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; + return nmc->return_value; } devices = get_devices_sorted (nmc->client); - while (arg_num > 0) { - device = NULL; - for (i = 0; devices[i]; i++) { - if (!g_strcmp0 (nm_device_get_iface (devices[i]), *arg_ptr)) { - device = devices[i]; - break; - } + for (i = 0; devices[i]; i++) { + if (!g_strcmp0 (nm_device_get_iface (devices[i]), device_name)) { + device = devices[i]; + break; } - - if (device) { - if (!g_slist_find (queue, device)) - queue = g_slist_prepend (queue, device); - else - g_printerr (_("Warning: argument '%s' is duplicated.\n"), *arg_ptr); - } else { - g_printerr (_("Error: Device '%s' not found.\n"), *arg_ptr); - g_string_printf (nmc->return_text, _("Error: not all devices found.")); - nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND; - } - - /* Take next argument */ - next_arg (&arg_num, &arg_ptr); } - if (!queue) { - g_string_printf (nmc->return_text, _("Error: no valid device provided.")); + if (!device) { + g_string_printf (nmc->return_text, _("Error: device '%s' not found."), device_name); nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND; return nmc->return_value; } - queue = g_slist_reverse (queue); - - info = g_slice_new0 (DeviceCbInfo); - info->nmc = nmc; nmc->nowait_flag = (nmc->timeout == 0); nmc->should_wait = TRUE; - for (iter = queue; iter; iter = g_slist_next (iter)) { - device = iter->data; + info = g_slice_new0 (DeviceCbInfo); + info->nmc = nmc; + info->queue = g_slist_prepend (info->queue, g_object_ref (device)); - info->queue = g_slist_prepend (info->queue, g_object_ref (device)); - - /* Now reapply the connection to the device */ - nm_device_reapply_async (device, NULL, 0, 0, NULL, reapply_device_cb, info); - } + /* Now reapply the connection to the device */ + nm_device_reapply_async (device, NULL, 0, 0, NULL, reapply_device_cb, info); return nmc->return_value; } diff --git a/clients/cli/nmcli-completion b/clients/cli/nmcli-completion index 1b1dce3322..3c87f6f9d4 100644 --- a/clients/cli/nmcli-completion +++ b/clients/cli/nmcli-completion @@ -1425,12 +1425,12 @@ _nmcli() fi ;; sh|sho|show| \ + r|re|rea|reap|reapp|reappl|reapply| \ c|co|con|conn|conne|connec|connect) if [[ ${#words[@]} -eq 3 ]]; then _nmcli_compl_COMMAND_nl "${words[2]}" "$(_nmcli_dev_status DEVICE)" fi ;; - r|re|rea|reap|reapp|reappl|reapply| \ d|di|dis|disc|disco|discon|disconn|disconne|disconnec|disconnect| \ de|del|dele|delet|delete| \ m|mo|mon|moni|monit|monito|monitor) From 325edfb0fed6d8dda11d3379ce39f971c4286b5f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Apr 2016 14:32:56 +0200 Subject: [PATCH 09/10] cli: remove unused functions (cherry picked from commit a9908c012c89ee8a306825074de706b0ac55b70d) --- clients/cli/utils.c | 71 --------------------------------------------- clients/cli/utils.h | 3 -- 2 files changed, 74 deletions(-) diff --git a/clients/cli/utils.c b/clients/cli/utils.c index 87b37bb1a5..a406eee459 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -181,60 +181,6 @@ ssid_to_hex (const char *str, gsize len) return printable_str; } -/* - * Converts IPv4 address from guint32 in network-byte order to text representation. - * Returns: text form of the IP or NULL (then error is set) - */ -char * -nmc_ip4_address_as_string (guint32 ip, GError **error) -{ - guint32 tmp_addr; - char buf[INET_ADDRSTRLEN]; - - g_return_val_if_fail (error == NULL || *error == NULL, NULL); - - memset (&buf, '\0', sizeof (buf)); - tmp_addr = ip; - - if (inet_ntop (AF_INET, &tmp_addr, buf, INET_ADDRSTRLEN)) { - return g_strdup (buf); - } else { - g_set_error (error, NMCLI_ERROR, 0, _("Error converting IP4 address '0x%X' to text form"), - ntohl (tmp_addr)); - return NULL; - } -} - -/* - * Converts IPv6 address in in6_addr structure to text representation. - * Returns: text form of the IP or NULL (then error is set) - */ -char * -nmc_ip6_address_as_string (const struct in6_addr *ip, GError **error) -{ - char buf[INET6_ADDRSTRLEN]; - - g_return_val_if_fail (error == NULL || *error == NULL, NULL); - - memset (&buf, '\0', sizeof (buf)); - - if (inet_ntop (AF_INET6, ip, buf, INET6_ADDRSTRLEN)) { - return g_strdup (buf); - } else { - if (error) { - int j; - GString *ip6_str = g_string_new (NULL); - g_string_append_printf (ip6_str, "%02X", ip->s6_addr[0]); - for (j = 1; j < 16; j++) - g_string_append_printf (ip6_str, " %02X", ip->s6_addr[j]); - g_set_error (error, NMCLI_ERROR, 0, _("Error converting IP6 address '%s' to text form"), - ip6_str->str); - g_string_free (ip6_str, TRUE); - } - return NULL; - } -} - /* * Erase terminal line using ANSI escape sequences. * It prints [2K sequence to erase the line and then \r to return back @@ -706,23 +652,6 @@ finish: return ret; } -/* - * Convert string array (char **) to GSList. - * - * Returns: pointer to newly created GSList. Caller should free it. - */ -GSList * -nmc_util_strv_to_slist (char **strv) -{ - GSList *list = NULL; - guint i = 0; - - while (strv && strv[i]) - list = g_slist_prepend (list, g_strdup (strv[i++])); - - return g_slist_reverse (list); -} - /* * Convert string array (char **) to description string in the form of: * "[string1, string2, ]" diff --git a/clients/cli/utils.h b/clients/cli/utils.h index 224acb0cb3..eab60d3a10 100644 --- a/clients/cli/utils.h +++ b/clients/cli/utils.h @@ -69,8 +69,6 @@ gboolean nmc_string_to_uint (const char *str, unsigned long int *value); gboolean nmc_string_to_bool (const char *str, gboolean *val_bool, GError **error); gboolean nmc_string_to_tristate (const char *str, NMCTriStateValue *val, GError **error); -char *nmc_ip4_address_as_string (guint32 ip, GError **error); -char *nmc_ip6_address_as_string (const struct in6_addr *ip, GError **error); void nmc_terminal_erase_line (void); void nmc_terminal_show_progress (const char *str); const char *nmc_term_color_sequence (NmcTermColor color); @@ -83,7 +81,6 @@ char *nmc_get_user_input (const char *ask_str); int nmc_string_to_arg_array (const char *line, const char *delim, gboolean unquote, char ***argv, int *argc); const char *nmc_string_is_valid (const char *input, const char **allowed, GError **error); -GSList *nmc_util_strv_to_slist (char **strv); char * nmc_util_strv_for_display (const char **strv, gboolean brackets); char **nmc_strsplit_set (const char *str, const char *delimiter, int max_tokens); int nmc_string_screen_width (const char *start, const char *end); From 81b05ade70f0f0dff8f4139cc5acac2afba03835 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 30 Apr 2016 15:02:53 +0200 Subject: [PATCH 10/10] cli: declare external variable nm_cli in header (cherry picked from commit 7752f390c217455dece4aba6ffdd4854c568fcd2) --- clients/cli/common.c | 4 ---- clients/cli/connections.c | 3 --- clients/cli/devices.c | 3 --- clients/cli/nmcli.h | 3 ++- clients/cli/settings.c | 7 ------- 5 files changed, 2 insertions(+), 18 deletions(-) diff --git a/clients/cli/common.c b/clients/cli/common.c index 0aa5efc260..0888f0630c 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -1170,10 +1170,6 @@ nmc_set_in_readline (gboolean in_readline) pthread_mutex_unlock (&readline_mutex); } -/* Global variable defined in nmcli.c */ -extern NmCli nm_cli; - - static char * nmc_readline_helper (const char *prompt) { diff --git a/clients/cli/connections.c b/clients/cli/connections.c index d01e38efba..1f1dae5981 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -261,9 +261,6 @@ typedef struct { } TabCompletionInfo; static TabCompletionInfo nmc_tab_completion = {NULL, NULL, NULL, NULL}; -/* Global variable defined in nmcli.c - used for TAB completion */ -extern NmCli nm_cli; - static char *gen_connection_types (const char *text, int state); static void diff --git a/clients/cli/devices.c b/clients/cli/devices.c index d14807b48c..65c4be7286 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -3572,9 +3572,6 @@ is_single_word (const char* line) return FALSE; } -/* Global variable defined in nmcli.c */ -extern NmCli nm_cli; - static char * gen_func_ifnames (const char *text, int state) { diff --git a/clients/cli/nmcli.h b/clients/cli/nmcli.h index 9048a69f7e..34100f0026 100644 --- a/clients/cli/nmcli.h +++ b/clients/cli/nmcli.h @@ -161,6 +161,8 @@ typedef struct _NmCli { NmcTermColor editor_prompt_color; /* Color of prompt in connection editor */ } NmCli; +extern NmCli nm_cli; + /* Error quark for GError domain */ #define NMCLI_ERROR (nmcli_error_quark ()) GQuark nmcli_error_quark (void); @@ -169,5 +171,4 @@ gboolean nmc_seen_sigint (void); void nmc_clear_sigint (void); void nmc_set_sigquit_internal (void); - #endif /* NMC_NMCLI_H */ diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 06e9fb4722..1651aab226 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -2082,13 +2082,6 @@ typedef struct { NmcPropertyFuncsFields } NmcPropertyFuncs; -/* - * We need NmCli in some _set_property functions, and they aren't passed NmCli. - * So use the global variable. - */ -/* Global variable defined in nmcli.c */ -extern NmCli nm_cli; - NMSetting * nmc_setting_new_for_name (const char *name) {