Blame SOURCES/sos-bz1392038-network-name-with-quotemark.patch

2eebcf
From d8365090b21c451894b49771959653683caf0f6e Mon Sep 17 00:00:00 2001
2eebcf
From: "Bryn M. Reeves" <bmr@redhat.com>
2eebcf
Date: Fri, 8 Jul 2016 18:59:21 +0100
2eebcf
Subject: [PATCH] [networking] single quote innermost strings in nmcli commands
2eebcf
2eebcf
Network Manager names may contain embedded quotes (" and ').  These will
2eebcf
cause an exception in shlex.split() if the quotes are unbalanced. This
2eebcf
may happen with names like: "Foobar's Wireless Network". Although the
2eebcf
problen will occur for both single and double quote characters the
2eebcf
former is considerably more likely in object names since it is
2eebcf
syntactically valid in many human languages.
2eebcf
2eebcf
Reverse the normal sos quoting convention here and place double quotes
2eebcf
around the innermost quoted string.
2eebcf
2eebcf
RHBZ# 1353992
2eebcf
2eebcf
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
2eebcf
---
2eebcf
 sos/plugins/networking.py | 15 +++++++++++++--
2eebcf
 1 file changed, 13 insertions(+), 2 deletions(-)
2eebcf
2eebcf
diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py
2eebcf
index 8390957..93b8860 100644
2eebcf
--- a/sos/plugins/networking.py
2eebcf
+++ b/sos/plugins/networking.py
2eebcf
@@ -225,7 +225,17 @@ class Networking(Plugin):
2eebcf
                 for con in nmcli_con_show_result['output'].splitlines():
2eebcf
                     if con[0:7] == 'Warning':
2eebcf
                         continue
2eebcf
-                    self.add_cmd_output("%s '%s'" %
2eebcf
+                    # nm names may contain embedded quotes (" and '). These
2eebcf
+                    # will cause an exception in shlex.split() if the quotes
2eebcf
+                    # are unbalanced. This may happen with names like:
2eebcf
+                    # "Foobar's Wireless Network". Although the problen will
2eebcf
+                    # occur for both single and double quote characters the
2eebcf
+                    # former is considerably more likely in object names since
2eebcf
+                    # it is syntactically valid in many human languages.
2eebcf
+                    #
2eebcf
+                    # Reverse the normal sos quoting convention here and place
2eebcf
+                    # double quotes around the innermost quoted string.
2eebcf
+                    self.add_cmd_output('%s "%s"' %
2eebcf
                                         (nmcli_con_details_cmd, con))
2eebcf
 
2eebcf
             nmcli_dev_status_result = self.call_ext_prog(
2eebcf
@@ -234,7 +244,8 @@ class Networking(Plugin):
2eebcf
                 for dev in nmcli_dev_status_result['output'].splitlines():
2eebcf
                     if dev[0:7] == 'Warning':
2eebcf
                         continue
2eebcf
-                    self.add_cmd_output("%s '%s'" %
2eebcf
+                    # See above comment describing quoting conventions.
2eebcf
+                    self.add_cmd_output('%s "%s"' %
2eebcf
                                         (nmcli_dev_details_cmd, dev))
2eebcf
 
2eebcf
         # Get ethtool output for every device that does not exist in a
2eebcf
-- 
2eebcf
2.7.4
2eebcf