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