aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-10-20 09:31:32 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-10-20 09:31:32 +0100
commit3d4cf0365d520be81abfe3435fa9a8a56a933961 (patch)
tree51b43053a0e11b513bb0ffb0eee7b82ff54428bc
parent874cc7d0889adf32b8c36bb218212d3304d43d5b (diff)
downloadsos-3d4cf0365d520be81abfe3435fa9a8a56a933961.tar.gz
[mysql] obtain dbpass from the environment
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/mysql.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/sos/plugins/mysql.py b/sos/plugins/mysql.py
index 8bc6e725..1203f5c8 100644
--- a/sos/plugins/mysql.py
+++ b/sos/plugins/mysql.py
@@ -13,7 +13,7 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
-
+import os
class Mysql(Plugin):
"""MySQL and MariaDB RDBMS
@@ -25,7 +25,7 @@ class Mysql(Plugin):
option_list = [
("dbuser", "username for database dumps", "", "mysql"),
- ("dbpass", "password for database dumps", "", ""),
+ ("dbpass", "password for database dumps", "", False),
("dbdump", "collect a database dump", "", False)
]
@@ -44,7 +44,14 @@ class Mysql(Plugin):
if self.get_option("dbdump"):
dbuser = self.get_option("dbuser")
dbpass = self.get_option("dbpass")
- opts = "--user=%s --password=%s --all-databases" % (dbuser, dbpass)
+ if dbpass == False and 'MYSQL_PWD' in os.environ:
+ dbpass = os.environ['MYSQL_PWD']
+ else:
+ # no MySQL password
+ return
+ os.environ['MYSQL_PWD'] = dbpass
+
+ opts = "--user=%s --all-databases" % dbuser
name = "mysqldump_--all-databases"
self.add_cmd_output("mysqldump %s" % opts, suggest_filename=name)