cli: fix crash in nmcli device wifi with multiple wifi devices (rh #1159408)

https://bugzilla.redhat.com/show_bug.cgi?id=1159408
This commit is contained in:
Jiří Klimeš 2014-11-06 08:56:24 +01:00
parent a3ae10b400
commit 85596bf315
2 changed files with 120 additions and 1 deletions

View File

@ -0,0 +1,114 @@
From 45358f51fc0cc29d26cd70dcd16c884fb02d210d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
Date: Mon, 18 Aug 2014 12:41:01 +0200
Subject: [PATCH] cli: fix crash in `nmcli device wifi` with multiple wifi
devices (bgo #734466)
And separate details for particular devices with an empty line.
https://bugzilla.gnome.org/show_bug.cgi?id=734466
Reported-by: Martin Pitt <martinpitt@gnome.org>
(cherry picked from commit cc67c72b5e36a5776fa5665c61afdb8d33afc134)
---
cli/src/devices.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/cli/src/devices.c b/cli/src/devices.c
index a493387..d2e4c4f 100644
--- a/cli/src/devices.c
+++ b/cli/src/devices.c
@@ -1839,6 +1839,8 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
goto error;
}
} else {
+ gboolean empty_line = FALSE;
+
/* List APs for all devices */
if (bssid_user) {
/* Specific AP requested - list only that */
@@ -1850,6 +1852,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
/* Main header name */
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr, nm_device_get_iface (dev));
+ nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, FALSE, NULL, NULL);
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
g_ptr_array_add (nmc->output_data, arr);
@@ -1875,8 +1878,11 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
}
g_free (bssid_up);
}
+ if (empty_line)
+ printf ("\n"); /* Empty line between devices' APs */
print_data (nmc); /* Print all data */
nmc_empty_output_fields (nmc);
+ empty_line = TRUE;
}
if (!ap) {
g_string_printf (nmc->return_text, _("Error: Access point with bssid '%s' not found."),
@@ -1891,8 +1897,14 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
/* Main header name */
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr,
nm_device_get_iface (dev));
- if (NM_IS_DEVICE_WIFI (dev))
+ nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, FALSE, NULL, NULL);
+
+ if (NM_IS_DEVICE_WIFI (dev)) {
+ if (empty_line)
+ printf ("\n"); /* Empty line between devices' APs */
show_acces_point_info (dev, nmc);
+ empty_line = TRUE;
+ }
}
}
}
@@ -2572,6 +2584,8 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
goto error;
}
} else {
+ gboolean empty_line = FALSE;
+
/* List NSPs for all devices */
if (nsp_user) {
/* Specific NSP requested - list only that */
@@ -2584,6 +2598,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
/* Main header name */
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr, nm_device_get_iface (dev));
+ nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, FALSE, NULL, NULL);
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
g_ptr_array_add (nmc->output_data, arr);
@@ -2601,8 +2616,11 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
}
g_free (nsp_up);
}
+ if (empty_line)
+ printf ("\n"); /* Empty line between devices' NSPs */
print_data (nmc); /* Print all data */
nmc_empty_output_fields (nmc);
+ empty_line = TRUE;
}
if (!nsp) {
g_string_printf (nmc->return_text, _("Error: Access point with nsp '%s' not found."), nsp_user);
@@ -2616,9 +2634,14 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
/* Main header name */
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr,
nm_device_get_iface (dev));
+ nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, FALSE, NULL, NULL);
- if (NM_IS_DEVICE_WIMAX (dev))
+ if (NM_IS_DEVICE_WIMAX (dev)) {
+ if (empty_line)
+ printf ("\n"); /* Empty line between devices' NSPs */
show_nsp_info (dev, nmc);
+ empty_line = TRUE;
+ }
}
}
}
--
1.7.11.7

View File

@ -13,7 +13,7 @@
%define snapshot .git20140704
%define git_sha 6eb82acd
%define realversion 0.9.10.0
%define release_version 12
%define release_version 13
%define epoch_version 1
%define obsoletes_nmver 1:0.9.9.95-1
@ -88,6 +88,7 @@ Patch3: 0003-bluez-track-adapter-address-in-NMBluezDevice.patch
Patch4: 0004-bluez-re-add-DUN-support-for-Bluez5.patch
Patch5: 0005-core-only-set-IPv6-hop_limit-for-values-greater-than.patch
Patch6: 0006-platform-deal-with-default-route-being-passed-to-rou.patch
Patch7: 0007-rh1159408-cli-multiple-wifi-devices-fix.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -332,6 +333,7 @@ by nm-connection-editor and nm-applet in a non-graphical environment.
%patch4 -p1 -b .bluez-re-add-DUN-support-for-Bluez5.orig
%patch5 -p1 -b .core-only-set-IPv6-hop_limit-for-values-greater-than.orig
%patch6 -p1 -b .default-route-spam
%patch7 -p1 -b .rh1159408-cli-multiple-wifi-devices-fix.orig
%build
@ -603,6 +605,9 @@ fi
%endif
%changelog
* Thu Nov 6 2014 Jiří Klimeš <jklimes@redhat.com> - 1:0.9.10.0-13.git20140704
- cli: fix crash in `nmcli device wifi` with multiple wifi devices (rh #1159408)
* Wed Oct 29 2014 Dan Winship <danw@redhat.com> - 1:0.9.10.0-12.git20140704
- platform: fix a routing-related bug that could cause NM and other apps to spin (rh #1151665)