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

Special symbols in passwords #246

Open
pozharski opened this issue Jun 5, 2017 · 2 comments
Open

Special symbols in passwords #246

pozharski opened this issue Jun 5, 2017 · 2 comments
Assignees
Labels
bug Bugs that need to get fixed. db/mysql high priority Priority issues

Comments

@pozharski
Copy link

dbbackup command fails when database password contains special symbols. I had spaces and the problem is that the mysqldump command does not put quotes around the password. This may go beyond mysql, but it seems like the culprit is this line in the db.mysql

cmd += ' --password={}'.format(self.settings['PASSWORD'])

Changing it to this

cmd += " --password='{}'".format(self.settings['PASSWORD'])

should fix it.

The workaround, of course, is to not use special characters in passwords.

What I did not understand is how this was not a problem before - I looked in the django.db.backends.mysql and the mysql command line is formed the same way and must fail if spaces are present in the password. The only difference is that the password is filtered by django.utils.encoding.force_str, but that shouldn't change anything.

Further look reveals that django.db.backends.mysql actually forms input for subprocess.Popen differently. Its args list is explicitly created, so '"--password=%s" % passwd' is appended to it in full, spaces and whatnot. In dbbackup the command line is first fully formed as a string and then converted into list of arguments by split().

@ZuluPro ZuluPro self-assigned this Aug 20, 2017
@ZuluPro ZuluPro added backup bug Bugs that need to get fixed. db/mysql labels Aug 20, 2017
@jonathan-s jonathan-s removed the backup label Sep 19, 2020
@jonathan-s jonathan-s added high priority Priority issues and removed database labels Dec 8, 2020
@adi-
Copy link
Contributor

adi- commented Apr 15, 2021

Same in postgres...

@enzedonline
Copy link

enzedonline commented Aug 17, 2021

I just wasted 4 hours on this - backup user has an exclamation in the password. Error message telling me no password supplied when it's right there in the config:

    raise exceptions.CommandConnectorError(
dbbackup.db.exceptions.CommandConnectorError: Error running:  pg_dump  
--host=localhost --port=5432 --username=db_backup --no-password --clean mydb      
pg_dump: error: connection to database "mydb" 
failed: FATAL:  password authentication failed for user "db_backup"

4 years after this was reported, at the very least, this needs to be in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs that need to get fixed. db/mysql high priority Priority issues
Projects
None yet
Development

No branches or pull requests

6 participants