diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2016-07-08 18:59:21 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2016-07-08 18:59:21 +0100 |
commit | d8365090b21c451894b49771959653683caf0f6e (patch) | |
tree | 7540b85d9f2f85a0ca38b539061dbfdc6ccd9227 | |
parent | ba2a2016a3f3c383b265a99deff8867d0d26ea56 (diff) | |
download | sos-d8365090b21c451894b49771959653683caf0f6e.tar.gz |
[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 <bmr@redhat.com>
-rw-r--r-- | sos/plugins/networking.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py index 83909570..93b88600 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 |