From 134c449cf6953187014af5d91d3b80f0f7ce82de Mon Sep 17 00:00:00 2001 From: Chao Luan Date: Tue, 1 Apr 2014 23:44:38 +1100 Subject: [PATCH] Remove extra quote from the mysqldump password argument The mysqldb Ansible module will fail if the state specified is import or dump with a '1045: Access Denied' mysql error for complex passwords. This is caused by the extra quote around the '--password' argument to mysqldump, as pipes.quotes already quotes the password string. >>> "--password='%s'" % pipes.quote('simple') "--password='simple'" >>> "--password='%s'" % pipes.quote('c0mplexp@ssword!') "--password=''c0mplexp@ssword!''" >>> "--password='%s'" % pipes.quote('password with space') "--password=''password with space''" --- library/database/mysql_db | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/database/mysql_db b/library/database/mysql_db index c9fd5b4e087..8eec1005893 100644 --- a/library/database/mysql_db +++ b/library/database/mysql_db @@ -124,7 +124,7 @@ def db_delete(cursor, db): def db_dump(module, host, user, password, db_name, target, port, socket=None): cmd = module.get_bin_path('mysqldump', True) - cmd += " --quick --user=%s --password='%s'" % (pipes.quote(user), pipes.quote(password)) + cmd += " --quick --user=%s --password=%s" % (pipes.quote(user), pipes.quote(password)) if socket is not None: cmd += " --socket=%s" % pipes.quote(socket) else: @@ -141,7 +141,7 @@ def db_dump(module, host, user, password, db_name, target, port, socket=None): def db_import(module, host, user, password, db_name, target, port, socket=None): cmd = module.get_bin_path('mysql', True) - cmd += " --user=%s --password='%s'" % (pipes.quote(user), pipes.quote(password)) + cmd += " --user=%s --password=%s" % (pipes.quote(user), pipes.quote(password)) if socket is not None: cmd += " --socket=%s" % pipes.quote(socket) else: