diff -Nru sosreport-3.5/debian/changelog sosreport-3.5/debian/changelog --- sosreport-3.5/debian/changelog 2018-04-12 04:48:13.000000000 -0400 +++ sosreport-3.5/debian/changelog 2018-06-05 10:52:56.000000000 -0400 @@ -1,3 +1,11 @@ +sosreport (3.5-1ubuntu4) cosmic; urgency=medium + + * d/p/Fix-string-decoding-for-debug-log-output.patch: + Fix bug in _collect_strings that causes error trying to str.decode() + (LP: #1761442) + + -- Dan Streetman Tue, 05 Jun 2018 10:52:56 -0400 + sosreport (3.5-1ubuntu3) bionic; urgency=medium * Avoid using distutils during runtime. diff -Nru sosreport-3.5/debian/patches/Fix-string-decoding-for-debug-log-output.patch sosreport-3.5/debian/patches/Fix-string-decoding-for-debug-log-output.patch --- sosreport-3.5/debian/patches/Fix-string-decoding-for-debug-log-output.patch 1969-12-31 19:00:00.000000000 -0500 +++ sosreport-3.5/debian/patches/Fix-string-decoding-for-debug-log-output.patch 2018-06-05 10:51:36.000000000 -0400 @@ -0,0 +1,62 @@ +Origin: upstream, https://github.com/sosreport/sos/commit/476bd7f324dcfa8189860400bc83e7aaaa86f174 +From: Dan Streetman +Subject: [PATCH] [Plugin] Fix string decoding for debug log output +Bug: https://github.com/sosreport/sos/issues/1266 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1761442 + +In add_string_as_file and _collect_strings, the first line of each +string is printed to debug log, however there is a bug in +_collect_strings that tries to decode the first line of '...' +instead of the actual string; this causes a error like: + + File "/usr/share/sosreport/sos/sosreport.py", line 1300, in collect + plug.collect() + File "/usr/share/sosreport/sos/plugins/__init__.py", line 877, in collect + self._collect_strings() + File "/usr/share/sosreport/sos/plugins/__init__.py", line 860, in _collect_strings + (content.splitlines()[0]).decode('utf8', 'ignore')) +AttributeError: 'str' object has no attribute 'decode' + +This simplifies the (string or bytearray)-to-first-line-string of both +functions, which also fixes the bug using the wrong variable to decode. + +Signed-off-by: Dan Streetman +Signed-off-by: Bryn M. Reeves + +--- a/sos/plugins/__init__.py ++++ b/sos/plugins/__init__.py +@@ -703,12 +703,10 @@ + def add_string_as_file(self, content, filename): + """Add a string to the archive as a file named `filename`""" + self.copy_strings.append((content, filename)) +- if isinstance(content, six.string_types): +- content = "..." + content.splitlines()[0] +- else: +- content = ("..." + +- (content.splitlines()[0]).decode('utf8', 'ignore')) +- self._log_debug("added string '%s' as '%s'" % (content, filename)) ++ content = content.splitlines()[0] ++ if not isinstance(content, six.string_types): ++ content = content.decode('utf8', 'ignore') ++ self._log_debug("added string ...'%s' as '%s'" % (content, filename)) + + def get_cmd_output_now(self, exe, suggest_filename=None, + root_symlink=False, timeout=300, stderr=True, +@@ -852,13 +850,10 @@ + + def _collect_strings(self): + for string, file_name in self.copy_strings: +- content = "..." +- if isinstance(string, six.string_types): +- content = "..." + content.splitlines()[0] +- else: +- content = ("..." + +- (content.splitlines()[0]).decode('utf8', 'ignore')) +- self._log_info("collecting string '%s' as '%s'" ++ content = string.splitlines()[0] ++ if not isinstance(content, six.string_types): ++ content = content.decode('utf8', 'ignore') ++ self._log_info("collecting string ...'%s' as '%s'" + % (content, file_name)) + try: + self.archive.add_string(string, diff -Nru sosreport-3.5/debian/patches/series sosreport-3.5/debian/patches/series --- sosreport-3.5/debian/patches/series 2018-04-12 04:46:58.000000000 -0400 +++ sosreport-3.5/debian/patches/series 2018-06-05 10:43:50.000000000 -0400 @@ -2,3 +2,4 @@ 0002-reset-to-expected-variable-order-for-packagemanager.patch 0003-fix-name-containers-is-not-defined.patch avoid-distutils.diff +Fix-string-decoding-for-debug-log-output.patch