From 234d31bf725b98d428ba5ab9f5da73bede107c88 Mon Sep 17 00:00:00 2001 From: Mark Theunissen Date: Tue, 26 Feb 2013 16:27:23 -0600 Subject: [PATCH] Adding back support for pass= --- library/mysql_db | 16 ++++++++++++++-- library/mysql_user | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/library/mysql_db b/library/mysql_db index eac18c4aba..49badb20e3 100644 --- a/library/mysql_db +++ b/library/mysql_db @@ -131,8 +131,20 @@ def load_mycnf(): return False try: config.readfp(open(mycnf)) - creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'password')) - except (ConfigParser.NoOptionError, IOError): + except (IOError): + return False + # We support two forms of passwords in .my.cnf, both pass= and password=, + # as these are both supported by MySQL. + try: + passwd = config.get('client', 'password') + except (ConfigParser.NoOptionError): + try: + passwd = config.get('client', 'pass') + except (ConfigParser.NoOptionError): + return False + try: + creds = dict(user=config.get('client', 'user'),passwd=passwd) + except (ConfigParser.NoOptionError): return False return creds diff --git a/library/mysql_user b/library/mysql_user index 3f40411b0d..4330c35338 100644 --- a/library/mysql_user +++ b/library/mysql_user @@ -236,8 +236,20 @@ def load_mycnf(): return False try: config.readfp(open(mycnf)) - creds = dict(user=config.get('client', 'user'),password=config.get('client', 'password')) - except (ConfigParser.NoOptionError, IOError): + except (IOError): + return False + # We support two forms of passwords in .my.cnf, both pass= and password=, + # as these are both supported by MySQL. + try: + passwd = config.get('client', 'password') + except (ConfigParser.NoOptionError): + try: + passwd = config.get('client', 'pass') + except (ConfigParser.NoOptionError): + return False + try: + creds = dict(user=config.get('client', 'user'),passwd=passwd) + except (ConfigParser.NoOptionError): return False return creds