Blob Blame History Raw
From 05466cd6d9d70321fc7a0097334ef36af8dfeb43 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Tue, 20 Jan 2015 16:16:17 +0000
Subject: [PATCH] [mysql] test for boolean values in user and password options

If sosreport is run with '-a' all options will be set to boolean
True. This causes an exception if an attempt is made to set an
environment variable to the option value:

  Traceback (most recent call last):
    File "/usr/sbin/sosreport", line 25, in <module>
      main(sys.argv[1:])
    File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1435, in main
      sos.execute()
  TypeError: must be string, not bool

  > /usr/lib64/python2.7/os.py(471)__setitem__()
  -> putenv(key, item)

Test both values with isinstance(val, bool) and do not attempt to
collect a database dump if either is a boolean.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/plugins/mysql.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sos/plugins/mysql.py b/sos/plugins/mysql.py
index edab6d0..dd899a3 100644
--- a/sos/plugins/mysql.py
+++ b/sos/plugins/mysql.py
@@ -45,6 +45,9 @@ class Mysql(Plugin):
         if self.get_option("dbdump"):
             dbuser = self.get_option("dbuser")
             dbpass = self.get_option("dbpass")
+            if isinstance(dbuser, bool) or isinstance(dbpass, bool):
+                # sosreport -a
+                return
             if 'MYSQL_PWD' in os.environ:
                 dbpass = os.environ['MYSQL_PWD']
             if not dbpass or dbpass is False:
-- 
1.9.3