Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql_db import fails with special characters in password #63955

Closed
paulbadcock opened this issue Oct 25, 2019 · 10 comments · Fixed by ansible-collections/community.general#428
Closed
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. collection:community.general collection Related to Ansible Collections work database Database category has_pr This issue has an associated PR. module This issue/PR relates to a module. mysql needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md support:community This issue/PR relates to code supported by the Ansible community.

Comments

@paulbadcock
Copy link

SUMMARY

mysql_db import fails when using special characters in the password parameter.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

mysql_db

ANSIBLE VERSION
ansible 2.8.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/var/lib/awx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /var/lib/awx/venv/ansible-2.8-nonroot/lib/python2.7/site-packages/ansible
  executable location = /var/lib/awx/venv/ansible-2.8-nonroot/bin/ansible
  python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
CONFIGURATION
Nothing
OS / ENVIRONMENT

RHEL 7.6

STEPS TO REPRODUCE

You can reproduce the problem by attempting to use a ! in the password field of the login_password

 - mysql_db:
    name: "db"
    state: import
    target: /tmp/sql_dump.sql.bz2
    login_host: "db.tld"
    login_user: "user"
    login_password: "pass!word"
EXPECTED RESULTS

Database to import with no errors

ACTUAL RESULTS

Failure to import with permission denied error

ERROR 1045 (28000): Access denied for user 'user'@'db.tld' (using password: YES)\n"
@ansibot
Copy link
Contributor

ansibot commented Oct 25, 2019

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. database Database category module This issue/PR relates to a module. mysql needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. labels Oct 25, 2019
@paulbadcock
Copy link
Author

paulbadcock commented Oct 25, 2019

The issue is on line 225 of the module

        cmd.append("--password=%s" % shlex_quote(password))

Removing the shlex_quote from the password and saving the new file to my library folder allows the password to work correctly with no errors from mysql shell command

@paulbadcock paulbadcock changed the title mysql_db import fails with special characters mysql_db import fails with special characters in password Oct 25, 2019
@winem
Copy link
Contributor

winem commented Nov 7, 2019

I will also take a look at the code. Removing shlex_quote can already be the fix but this can also be highly dangerous. This depends on the further handling of the password.

@ansibot ansibot added collection Related to Ansible Collections work collection:community.general needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md labels Apr 29, 2020
@Andersson007
Copy link
Contributor

this unfortunately can't be removed because of security reasons https://docs.python.org/3/library/shlex.html#shlex.quote.
There's a good example why

@Andersson007
Copy link
Contributor

I'll add an option for that

@Andersson007
Copy link
Contributor

Andersson007 commented May 28, 2020

ansible-collections/community.general#428
One thing i'm worried about is that i can't reproduce Access denied neither in my local environment nor in ansible CI tests.

@ansibot ansibot added the has_pr This issue has an associated PR. label May 28, 2020
@Andersson007
Copy link
Contributor

can be closed via ansible-collections/community.general#428

@Akasurde
Copy link
Member

Akasurde commented Jun 2, 2020

resolved_by_pr #ansible-collections/community.general#428

Marking it as resolved. Thanks @Andersson007

@Akasurde Akasurde closed this as completed Jun 2, 2020
@Andersson007
Copy link
Contributor

@Akasurde thanks for marking and closing!

@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Jun 2, 2020
@ansible ansible locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. collection:community.general collection Related to Ansible Collections work database Database category has_pr This issue has an associated PR. module This issue/PR relates to a module. mysql needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants