Blame SOURCES/sos-bz1126001-obtain-mysql-password-from-env.patch

e75bc7
From 3d4cf0365d520be81abfe3435fa9a8a56a933961 Mon Sep 17 00:00:00 2001
e75bc7
From: "Bryn M. Reeves" <bmr@redhat.com>
e75bc7
Date: Mon, 20 Oct 2014 09:31:32 +0100
e75bc7
Subject: [PATCH 1/2] [mysql] obtain dbpass from the environment
e75bc7
e75bc7
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
e75bc7
---
e75bc7
 sos/plugins/mysql.py | 13 ++++++++++---
e75bc7
 1 file changed, 10 insertions(+), 3 deletions(-)
e75bc7
e75bc7
diff --git a/sos/plugins/mysql.py b/sos/plugins/mysql.py
e75bc7
index 8bc6e72..1203f5c 100644
e75bc7
--- a/sos/plugins/mysql.py
e75bc7
+++ b/sos/plugins/mysql.py
e75bc7
@@ -13,7 +13,7 @@
e75bc7
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
e75bc7
 
e75bc7
 from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
e75bc7
-
e75bc7
+import os
e75bc7
 
e75bc7
 class Mysql(Plugin):
e75bc7
     """MySQL and MariaDB RDBMS
e75bc7
@@ -25,7 +25,7 @@ class Mysql(Plugin):
e75bc7
 
e75bc7
     option_list = [
e75bc7
         ("dbuser", "username for database dumps", "", "mysql"),
e75bc7
-        ("dbpass", "password for database dumps", "", ""),
e75bc7
+        ("dbpass", "password for database dumps", "", False),
e75bc7
         ("dbdump", "collect a database dump", "", False)
e75bc7
     ]
e75bc7
 
e75bc7
@@ -44,7 +44,14 @@ class Mysql(Plugin):
e75bc7
         if self.get_option("dbdump"):
e75bc7
             dbuser = self.get_option("dbuser")
e75bc7
             dbpass = self.get_option("dbpass")
e75bc7
-            opts = "--user=%s --password=%s --all-databases" % (dbuser, dbpass)
e75bc7
+            if dbpass == False and 'MYSQL_PWD' in os.environ:
e75bc7
+                dbpass = os.environ['MYSQL_PWD']
e75bc7
+            else:
e75bc7
+                # no MySQL password
e75bc7
+                return
e75bc7
+            os.environ['MYSQL_PWD'] = dbpass
e75bc7
+
e75bc7
+            opts = "--user=%s --all-databases" % dbuser
e75bc7
             name = "mysqldump_--all-databases"
e75bc7
             self.add_cmd_output("mysqldump %s" % opts, suggest_filename=name)
e75bc7
 
e75bc7
-- 
e75bc7
1.9.3
e75bc7
e75bc7
e75bc7
From 6ce502113f550c027424fa477edc091283c32e50 Mon Sep 17 00:00:00 2001
e75bc7
From: "Bryn M. Reeves" <bmr@redhat.com>
e75bc7
Date: Mon, 20 Oct 2014 14:33:57 +0100
e75bc7
Subject: [PATCH 2/2] [mysql] fix pep8 violations
e75bc7
e75bc7
The previous commit had a couple of pep8 errors that were fixed
e75bc7
in the working tree but not added to the commit; fix them.
e75bc7
e75bc7
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
e75bc7
---
e75bc7
 sos/plugins/mysql.py | 3 ++-
e75bc7
 1 file changed, 2 insertions(+), 1 deletion(-)
e75bc7
e75bc7
diff --git a/sos/plugins/mysql.py b/sos/plugins/mysql.py
e75bc7
index 1203f5c..d148472 100644
e75bc7
--- a/sos/plugins/mysql.py
e75bc7
+++ b/sos/plugins/mysql.py
e75bc7
@@ -15,6 +15,7 @@
e75bc7
 from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
e75bc7
 import os
e75bc7
 
e75bc7
+
e75bc7
 class Mysql(Plugin):
e75bc7
     """MySQL and MariaDB RDBMS
e75bc7
     """
e75bc7
@@ -44,7 +45,7 @@ class Mysql(Plugin):
e75bc7
         if self.get_option("dbdump"):
e75bc7
             dbuser = self.get_option("dbuser")
e75bc7
             dbpass = self.get_option("dbpass")
e75bc7
-            if dbpass == False and 'MYSQL_PWD' in os.environ:
e75bc7
+            if dbpass is False and 'MYSQL_PWD' in os.environ:
e75bc7
                 dbpass = os.environ['MYSQL_PWD']
e75bc7
             else:
e75bc7
                 # no MySQL password
e75bc7
-- 
e75bc7
1.9.3
e75bc7