Blame SOURCES/sos-bz1494420-postgresql-scl-path.patch

8b0807
From 0b93d1f69ccfcc76e1896ea0e5ff7854be69be13 Mon Sep 17 00:00:00 2001
8b0807
From: Pavel Moravec <pmoravec@redhat.com>
8b0807
Date: Sat, 25 Nov 2017 12:47:35 +0100
8b0807
Subject: [PATCH] [plugins] set proper PATH for SCL commands
8b0807
8b0807
As SCL packages are deployed under /opt/${provider}/${scl}/,
8b0807
calling a SCL command needs that prefix in any path in PATH.
8b0807
8b0807
Consequently, distro-specific SCL default path prefix of the provider must be
8b0807
defined in sos policies.
8b0807
8b0807
Relevant to: #1154
8b0807
8b0807
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
8b0807
---
8b0807
 sos/plugins/__init__.py  | 37 ++++++++++++++++++++++++++++++-------
8b0807
 sos/policies/__init__.py |  4 ++++
8b0807
 sos/policies/redhat.py   |  1 +
8b0807
 3 files changed, 35 insertions(+), 7 deletions(-)
8b0807
8b0807
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
8b0807
index aa69b19d..2a8bc516 100644
8b0807
--- a/sos/plugins/__init__.py
8b0807
+++ b/sos/plugins/__init__.py
8b0807
@@ -1066,25 +1066,48 @@ class SCLPlugin(RedHatPlugin):
8b0807
         output = sos_get_command_output("scl -l")["output"]
8b0807
         return [scl.strip() for scl in output.splitlines()]
8b0807
 
8b0807
+    def convert_cmd_scl(self, scl, cmd):
8b0807
+        """wrapping command in "scl enable" call and adds proper PATH
8b0807
+        """
8b0807
+        # load default SCL prefix to PATH
8b0807
+        prefix = self.policy().get_default_scl_prefix()
8b0807
+        # read prefix from /etc/scl/prefixes/${scl} and strip trailing '\n'
8b0807
+        try:
8b0807
+            prefix = open('/etc/scl/prefixes/%s' % scl, 'r').read()\
8b0807
+                     .rstrip('\n')
8b0807
+        except Exception as e:
8b0807
+            self._log_error("Failed to find prefix for SCL %s, using %s"
8b0807
+                            % (scl, prefix))
8b0807
+
8b0807
+        # expand PATH by equivalent prefixes under the SCL tree
8b0807
+        path = os.environ["PATH"]
8b0807
+        for p in path.split(':'):
8b0807
+            path = '%s/%s%s:%s' % (prefix, scl, p, path)
8b0807
+
8b0807
+        scl_cmd = "scl enable %s \"PATH=%s %s\"" % (scl, path, cmd)
8b0807
+        return scl_cmd
8b0807
+
8b0807
     def add_cmd_output_scl(self, scl, cmds, **kwargs):
8b0807
         """Same as add_cmd_output, except that it wraps command in
8b0807
-        "scl enable" call.
8b0807
+        "scl enable" call and sets proper PATH.
8b0807
         """
8b0807
         if isinstance(cmds, six.string_types):
8b0807
             cmds = [cmds]
8b0807
         scl_cmds = []
8b0807
-        scl_cmd_tpl = "scl enable %s \"%s\""
8b0807
         for cmd in cmds:
8b0807
-            scl_cmds.append(scl_cmd_tpl % (scl, cmd))
8b0807
+            scl_cmds.append(convert_cmd_scl(scl, cmd))
8b0807
         self.add_cmd_output(scl_cmds, **kwargs)
8b0807
 
8b0807
-    # config files for Software Collections are under /etc/opt/rh/${scl} and
8b0807
-    # var files are under /var/opt/rh/${scl}. So we need to insert the paths
8b0807
-    # after the appropriate root dir.
8b0807
+    # config files for Software Collections are under /etc/${prefix}/${scl} and
8b0807
+    # var files are under /var/${prefix}/${scl} where the ${prefix} is distro
8b0807
+    # specific path. So we need to insert the paths after the appropriate root
8b0807
+    # dir.
8b0807
     def convert_copyspec_scl(self, scl, copyspec):
8b0807
+        scl_prefix = self.policy().get_default_scl_prefix()
8b0807
         for rootdir in ['etc', 'var']:
8b0807
             p = re.compile('^/%s/' % rootdir)
8b0807
-            copyspec = p.sub('/%s/opt/rh/%s/' % (rootdir, scl), copyspec)
8b0807
+            copyspec = p.sub('/%s/%s/%s/' % (rootdir, scl_prefix, scl),
8b0807
+                             copyspec)
8b0807
         return copyspec
8b0807
 
8b0807
     def add_copy_spec_scl(self, scl, copyspecs):
8b0807
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
8b0807
index dffd801c..dc043105 100644
8b0807
--- a/sos/policies/__init__.py
8b0807
+++ b/sos/policies/__init__.py
8b0807
@@ -194,6 +194,7 @@ No changes will be made to system configuration.
8b0807
     vendor_url = "http://www.example.com/"
8b0807
     vendor_text = ""
8b0807
     PATH = ""
8b0807
+    default_scl_prefix = ""
8b0807
 
8b0807
     _in_container = False
8b0807
     _host_sysroot = '/'
8b0807
@@ -271,6 +272,9 @@ No changes will be made to system configuration.
8b0807
             return tempfile.gettempdir()
8b0807
         return opt_tmp_dir
8b0807
 
8b0807
+    def get_default_scl_prefix(self):
8b0807
+        return self.default_scl_prefix
8b0807
+
8b0807
     def match_plugin(self, plugin_classes):
8b0807
         if len(plugin_classes) > 1:
8b0807
             for p in plugin_classes:
8b0807
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py
8b0807
index c7449439..2dfe0589 100644
8b0807
--- a/sos/policies/redhat.py
8b0807
+++ b/sos/policies/redhat.py
8b0807
@@ -44,6 +44,7 @@ class RedHatPolicy(LinuxPolicy):
8b0807
     _rpmv_filter = ["debuginfo", "-devel"]
8b0807
     _in_container = False
8b0807
     _host_sysroot = '/'
8b0807
+    default_scl_prefix = '/opt/rh'
8b0807
 
8b0807
     def __init__(self, sysroot=None):
8b0807
         super(RedHatPolicy, self).__init__(sysroot=sysroot)
8b0807
-- 
8b0807
2.13.6
8b0807
8b0807
From 419ebe48ea408b6596ff4d7d9837079dc3057fcf Mon Sep 17 00:00:00 2001
8b0807
From: Pavel Moravec <pmoravec@redhat.com>
8b0807
Date: Sat, 25 Nov 2017 12:58:16 +0100
8b0807
Subject: [PATCH] [postgresql] Call SCL pg_dump with proper path
8b0807
8b0807
Also stop storing pg_dump in an auxiliary tempdir but under regular
8b0807
sos_commands/postgresql directory.
8b0807
8b0807
Resolves: #1154
8b0807
8b0807
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
8b0807
---
8b0807
 sos/plugins/postgresql.py | 43 ++++++++-----------------------------------
8b0807
 1 file changed, 8 insertions(+), 35 deletions(-)
8b0807
8b0807
diff --git a/sos/plugins/postgresql.py b/sos/plugins/postgresql.py
8b0807
index 45c87e89..9ba696be 100644
8b0807
--- a/sos/plugins/postgresql.py
8b0807
+++ b/sos/plugins/postgresql.py
8b0807
@@ -34,8 +34,6 @@ class PostgreSQL(Plugin):
8b0807
 
8b0807
     packages = ('postgresql',)
8b0807
 
8b0807
-    tmp_dir = None
8b0807
-
8b0807
     password_warn_text = " (password visible in process listings)"
8b0807
 
8b0807
     option_list = [
8b0807
@@ -47,11 +45,9 @@ class PostgreSQL(Plugin):
8b0807
         ('dbport', 'database server port number', '', '5432')
8b0807
     ]
8b0807
 
8b0807
-    def pg_dump(self, pg_dump_command="pg_dump", filename="sos_pgdump.tar"):
8b0807
+    def do_pg_dump(self, scl=None, filename="pgdump.tar"):
8b0807
         if self.get_option("dbname"):
8b0807
             if self.get_option("password") or "PGPASSWORD" in os.environ:
8b0807
-                self.tmp_dir = tempfile.mkdtemp()
8b0807
-                dest_file = os.path.join(self.tmp_dir, filename)
8b0807
                 # We're only modifying this for ourself and our children so
8b0807
                 # there is no need to save and restore environment variables if
8b0807
                 # the user decided to pass the password on the command line.
8b0807
@@ -59,30 +55,21 @@ class PostgreSQL(Plugin):
8b0807
                     os.environ["PGPASSWORD"] = str(self.get_option("password"))
8b0807
 
8b0807
                 if self.get_option("dbhost"):
8b0807
-                    cmd = "%s -U %s -h %s -p %s -w -f %s -F t %s" % (
8b0807
-                        pg_dump_command,
8b0807
+                    cmd = "pg_dump -U %s -h %s -p %s -w -F t %s" % (
8b0807
                         self.get_option("username"),
8b0807
                         self.get_option("dbhost"),
8b0807
                         self.get_option("dbport"),
8b0807
-                        dest_file,
8b0807
                         self.get_option("dbname")
8b0807
                     )
8b0807
                 else:
8b0807
-                    cmd = "%s -C -U %s -w -f %s -F t %s " % (
8b0807
-                        pg_dump_command,
8b0807
+                    cmd = "pg_dump -C -U %s -w -F t %s " % (
8b0807
                         self.get_option("username"),
8b0807
-                        dest_file,
8b0807
                         self.get_option("dbname")
8b0807
                     )
8b0807
 
8b0807
-                result = self.call_ext_prog(cmd)
8b0807
-                if (result['status'] == 0):
8b0807
-                    self.add_copy_spec(dest_file)
8b0807
-                else:
8b0807
-                    self._log_info(
8b0807
-                        "Unable to execute pg_dump. Error(%s)" %
8b0807
-                        (result['output'])
8b0807
-                    )
8b0807
+                if scl is not None:
8b0807
+                    cmd = self.convert_cmd_scl(scl, cmd)
8b0807
+                self.add_cmd_output(cmd, suggest_filename=filename)
8b0807
             else:  # no password in env or options
8b0807
                 self.soslog.warning(
8b0807
                     "password must be supplied to dump a database."
8b0807
@@ -92,18 +79,7 @@ class PostgreSQL(Plugin):
8b0807
                 )
8b0807
 
8b0807
     def setup(self):
8b0807
-        self.pg_dump()
8b0807
-
8b0807
-    def postproc(self):
8b0807
-        import shutil
8b0807
-        if self.tmp_dir:
8b0807
-            try:
8b0807
-                shutil.rmtree(self.tmp_dir)
8b0807
-            except shutil.Error:
8b0807
-                self.soslog.exception(
8b0807
-                    "Unable to remove %s." % (self.tmp_dir)
8b0807
-                )
8b0807
-                self.add_alert("ERROR: Unable to remove %s." % (self.tmp_dir))
8b0807
+        self.do_pg_dump()
8b0807
 
8b0807
 
8b0807
 class RedHatPostgreSQL(PostgreSQL, SCLPlugin):
8b0807
@@ -140,10 +116,7 @@ class RedHatPostgreSQL(PostgreSQL, SCLPlugin):
8b0807
         )
8b0807
 
8b0807
         if scl in self.scls_matched:
8b0807
-            self.pg_dump(
8b0807
-                pg_dump_command="scl enable rh-postgresql95 -- pg_dump",
8b0807
-                filename="sos_scl_pgdump.tar"
8b0807
-            )
8b0807
+            self.do_pg_dump(scl=scl, filename="pgdump-scl-%s.tar" % scl)
8b0807
 
8b0807
 
8b0807
 class DebianPostgreSQL(PostgreSQL, DebianPlugin, UbuntuPlugin):
8b0807
-- 
8b0807
2.13.6
8b0807
8b0807
From 3f0fa8ef20bcc8ec2fb1ff54815141813d07b033 Mon Sep 17 00:00:00 2001
8b0807
From: Pavel Moravec <pmoravec@redhat.com>
8b0807
Date: Wed, 20 Dec 2017 11:47:33 +0100
8b0807
Subject: [PATCH] [plugins] allow add_cmd_output to collect binary output
8b0807
8b0807
If a command output is a true binary data, allow add_cmd_output to
8b0807
collect the raw content and dont try to decode it as UTF-8.
8b0807
8b0807
Resolves: #1169
8b0807
8b0807
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
8b0807
---
8b0807
 sos/archive.py            | 11 ++++++++++
8b0807
 sos/plugins/__init__.py   | 51 +++++++++++++++++++++++++++++++----------------
8b0807
 sos/plugins/postgresql.py |  4 +++-
8b0807
 sos/utilities.py          |  5 +++--
8b0807
 4 files changed, 51 insertions(+), 20 deletions(-)
8b0807
8b0807
diff --git a/sos/archive.py b/sos/archive.py
8b0807
index 607312a71..80e27b846 100644
8b0807
--- a/sos/archive.py
8b0807
+++ b/sos/archive.py
8b0807
@@ -85,6 +85,9 @@ def add_file(self, src, dest=None):
8b0807
     def add_string(self, content, dest):
8b0807
         raise NotImplementedError
8b0807
 
8b0807
+    def add_binary(self, content, dest):
8b0807
+        raise NotImplementedError
8b0807
+
8b0807
     def add_link(self, source, link_name):
8b0807
         raise NotImplementedError
8b0807
 
8b0807
@@ -215,6 +218,14 @@ def add_string(self, content, dest):
8b0807
         self.log_debug("added string at '%s' to FileCacheArchive '%s'"
8b0807
                        % (src, self._archive_root))
8b0807
 
8b0807
+    def add_binary(self, content, dest):
8b0807
+        dest = self.dest_path(dest)
8b0807
+        self._check_path(dest)
8b0807
+        f = codecs.open(dest, 'wb', encoding=None)
8b0807
+        f.write(content)
8b0807
+        self.log_debug("added binary content at '%s' to FileCacheArchive '%s'"
8b0807
+                       % (dest, self._archive_root))
8b0807
+
8b0807
     def add_link(self, source, link_name):
8b0807
         dest = self.dest_path(link_name)
8b0807
         self._check_path(dest)
8b0807
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
8b0807
index 2a8bc516e..0eccd40a1 100644
8b0807
--- a/sos/plugins/__init__.py
8b0807
+++ b/sos/plugins/__init__.py
8b0807
@@ -222,6 +222,11 @@ def do_cmd_private_sub(self, cmd):
8b0807
             for called in self.executed_commands:
8b0807
                 if called['file'] is None:
8b0807
                     continue
8b0807
+                if called['binary'] == 'yes':
8b0807
+                    self._log_warn(("Command output '%s' collected as " +
8b0807
+                                    "binary, output isn't scrubbed despite " +
8b0807
+                                    "asked for") % called['exe'])
8b0807
+                    continue
8b0807
                 if fnmatch.fnmatch(called['exe'], globstr):
8b0807
                     path = os.path.join(self.commons['cmddir'], called['file'])
8b0807
                     readable = self.archive.open_file(path)
8b0807
@@ -260,6 +265,11 @@ def do_cmd_output_sub(self, cmd, regexp, subst):
8b0807
                 # was anything collected?
8b0807
                 if called['file'] is None:
8b0807
                     continue
8b0807
+                if called['binary'] == 'yes':
8b0807
+                    self._log_warn(("Command output '%s' collected as " +
8b0807
+                                    "binary, output isn't scrubbed despite " +
8b0807
+                                    "asked for") % called['exe'])
8b0807
+                    continue
8b0807
                 if fnmatch.fnmatch(called['exe'], globstr):
8b0807
                     path = os.path.join(self.commons['cmddir'], called['file'])
8b0807
                     self._log_debug("applying substitution to '%s'" % path)
8b0807
@@ -587,7 +597,8 @@ def getmtime(path):
8b0807
                 self.archive.add_link(link_path, _file)
8b0807
 
8b0807
     def get_command_output(self, prog, timeout=300, stderr=True,
8b0807
-                           chroot=True, runat=None, env=None):
8b0807
+                           chroot=True, runat=None, env=None,
8b0807
+                           binary=False):
8b0807
         if chroot or self.commons['cmdlineopts'].chroot == 'always':
8b0807
             root = self.sysroot
8b0807
         else:
8b0807
@@ -595,7 +606,7 @@ def get_command_output(self, prog, timeout=300, stderr=True,
8b0807
 
8b0807
         result = sos_get_command_output(prog, timeout=timeout, stderr=stderr,
8b0807
                                         chroot=root, chdir=runat,
8b0807
-                                        env=env)
8b0807
+                                        env=env, binary=binary)
8b0807
 
8b0807
         if result['status'] == 124:
8b0807
             self._log_warn("command '%s' timed out after %ds"
8b0807
@@ -611,7 +622,8 @@ def get_command_output(self, prog, timeout=300, stderr=True,
8b0807
                                    % (prog.split()[0], root))
8b0807
                     return self.get_command_output(prog, timeout=timeout,
8b0807
                                                    chroot=False, runat=runat,
8b0807
-                                                   env=env)
8b0807
+                                                   env=env,
8b0807
+                                                   binary=binary)
8b0807
             self._log_debug("could not run '%s': command not found" % prog)
8b0807
         return result
8b0807
 
8b0807
@@ -632,14 +644,14 @@ def check_ext_prog(self, prog):
8b0807
 
8b0807
     def _add_cmd_output(self, cmd, suggest_filename=None,
8b0807
                         root_symlink=None, timeout=300, stderr=True,
8b0807
-                        chroot=True, runat=None, env=None):
8b0807
+                        chroot=True, runat=None, env=None, binary=False):
8b0807
         """Internal helper to add a single command to the collection list."""
8b0807
         cmdt = (
8b0807
             cmd, suggest_filename,
8b0807
             root_symlink, timeout, stderr,
8b0807
-            chroot, runat, env
8b0807
+            chroot, runat, env, binary
8b0807
         )
8b0807
-        _tuplefmt = "('%s', '%s', '%s', %s, '%s', '%s', '%s', '%s')"
8b0807
+        _tuplefmt = "('%s', '%s', '%s', %s, '%s', '%s', '%s', '%s', '%s')"
8b0807
         _logstr = "packed command tuple: " + _tuplefmt
8b0807
         self._log_debug(_logstr % cmdt)
8b0807
         self.collect_cmds.append(cmdt)
8b0807
@@ -647,7 +659,7 @@ def _add_cmd_output(self, cmd, suggest_filename=None,
8b0807
 
8b0807
     def add_cmd_output(self, cmds, suggest_filename=None,
8b0807
                        root_symlink=None, timeout=300, stderr=True,
8b0807
-                       chroot=True, runat=None, env=None):
8b0807
+                       chroot=True, runat=None, env=None, binary=False):
8b0807
         """Run a program or a list of programs and collect the output"""
8b0807
         if isinstance(cmds, six.string_types):
8b0807
             cmds = [cmds]
8b0807
@@ -656,7 +668,7 @@ def add_cmd_output(self, cmds, suggest_filename=None,
8b0807
         for cmd in cmds:
8b0807
             self._add_cmd_output(cmd, suggest_filename,
8b0807
                                  root_symlink, timeout, stderr,
8b0807
-                                 chroot, runat, env)
8b0807
+                                 chroot, runat, env, binary)
8b0807
 
8b0807
     def get_cmd_output_path(self, name=None, make=True):
8b0807
         """Return a path into which this module should store collected
8b0807
@@ -712,14 +724,15 @@ def add_string_as_file(self, content, filename):
8b0807
 
8b0807
     def get_cmd_output_now(self, exe, suggest_filename=None,
8b0807
                            root_symlink=False, timeout=300, stderr=True,
8b0807
-                           chroot=True, runat=None, env=None):
8b0807
+                           chroot=True, runat=None, env=None,
8b0807
+                           binary=False):
8b0807
         """Execute a command and save the output to a file for inclusion in the
8b0807
         report.
8b0807
         """
8b0807
         start = time()
8b0807
         result = self.get_command_output(exe, timeout=timeout, stderr=stderr,
8b0807
                                          chroot=chroot, runat=runat,
8b0807
-                                         env=env)
8b0807
+                                         env=env, binary=binary)
8b0807
         self._log_debug("collected output of '%s' in %s"
8b0807
                         % (exe.split()[0], time() - start))
8b0807
 
8b0807
@@ -729,13 +742,17 @@ def get_cmd_output_now(self, exe, suggest_filename=None,
8b0807
             outfn = self._make_command_filename(exe)
8b0807
 
8b0807
         outfn_strip = outfn[len(self.commons['cmddir'])+1:]
8b0807
-        self.archive.add_string(result['output'], outfn)
8b0807
+        if binary:
8b0807
+            self.archive.add_binary(result['output'], outfn)
8b0807
+        else:
8b0807
+            self.archive.add_string(result['output'], outfn)
8b0807
         if root_symlink:
8b0807
             self.archive.add_link(outfn, root_symlink)
8b0807
 
8b0807
         # save info for later
8b0807
         # save in our list
8b0807
-        self.executed_commands.append({'exe': exe, 'file': outfn_strip})
8b0807
+        self.executed_commands.append({'exe': exe, 'file': outfn_strip,
8b0807
+                                       'binary': 'yes' if binary else 'no'})
8b0807
         self.commons['xmlreport'].add_command(cmdline=exe,
8b0807
                                               exitcode=result['status'],
8b0807
                                               f_stdout=outfn_strip)
8b0807
@@ -839,16 +856,16 @@ def _collect_cmd_output(self):
8b0807
                 timeout,
8b0807
                 stderr,
8b0807
                 chroot, runat,
8b0807
-                env
8b0807
+                env, binary
8b0807
             ) = progs[0]
8b0807
-            self._log_debug("unpacked command tuple: " +
8b0807
-                            "('%s', '%s', '%s', %s, '%s', '%s', '%s', '%s')" %
8b0807
-                            progs[0])
8b0807
+            self._log_debug(("unpacked command tuple: " +
8b0807
+                             "('%s', '%s', '%s', %s, '%s', '%s', '%s', '%s'," +
8b0807
+                             "'%s')") % progs[0])
8b0807
             self._log_info("collecting output of '%s'" % prog)
8b0807
             self.get_cmd_output_now(prog, suggest_filename=suggest_filename,
8b0807
                                     root_symlink=root_symlink, timeout=timeout,
8b0807
                                     stderr=stderr, chroot=chroot, runat=runat,
8b0807
-                                    env=env)
8b0807
+                                    env=env, binary=binary)
8b0807
 
8b0807
     def _collect_strings(self):
8b0807
         for string, file_name in self.copy_strings:
8b0807
diff --git a/sos/plugins/postgresql.py b/sos/plugins/postgresql.py
8b0807
index 9ba696be2..2e330c9b5 100644
8b0807
--- a/sos/plugins/postgresql.py
8b0807
+++ b/sos/plugins/postgresql.py
8b0807
@@ -69,7 +69,9 @@ def do_pg_dump(self, scl=None, filename="pgdump.tar"):
8b0807
 
8b0807
                 if scl is not None:
8b0807
                     cmd = self.convert_cmd_scl(scl, cmd)
8b0807
-                self.add_cmd_output(cmd, suggest_filename=filename)
8b0807
+                self.add_cmd_output(cmd, suggest_filename=filename,
8b0807
+                                    binary=True)
8b0807
+
8b0807
             else:  # no password in env or options
8b0807
                 self.soslog.warning(
8b0807
                     "password must be supplied to dump a database."
8b0807
diff --git a/sos/utilities.py b/sos/utilities.py
8b0807
index 55bb1dc96..b5aa571b7 100644
8b0807
--- a/sos/utilities.py
8b0807
+++ b/sos/utilities.py
8b0807
@@ -110,7 +110,8 @@ def is_executable(command):
8b0807
 
8b0807
 
8b0807
 def sos_get_command_output(command, timeout=300, stderr=False,
8b0807
-                           chroot=None, chdir=None, env=None):
8b0807
+                           chroot=None, chdir=None, env=None,
8b0807
+                           binary=False):
8b0807
     """Execute a command and return a dictionary of status and output,
8b0807
     optionally changing root or current working directory before
8b0807
     executing command.
8b0807
@@ -164,7 +165,7 @@ def _child_prep_fn():
8b0807
 
8b0807
     return {
8b0807
         'status': p.returncode,
8b0807
-        'output': stdout.decode('utf-8', 'ignore')
8b0807
+        'output': stdout if binary else stdout.decode('utf-8', 'ignore')
8b0807
     }
8b0807
 
8b0807