yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #74305
[Bug 1695299] Re: Glance installation fails if password contains '@' symbol
Reviewed: https://review.openstack.org/499410
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=f601cfccf1d8e2e314a270943d91e8aa1932f2a4
Submitter: Zuul
Branch: master
commit f601cfccf1d8e2e314a270943d91e8aa1932f2a4
Author: Ian Wienand <iwienand@xxxxxxxxxx>
Date: Thu Aug 31 11:06:28 2017 +1000
Support RFC1738 quoted chars in passwords
In the bug, a user tried setting a devstack password with a "@" in it.
As it turns out, sqlalchmey turns the connection-string into a
sqlalchemy.engine.url.URL object [1] which returns a RFC1738 quoted
string.
However, alembic's set_main_option [2] uses python
string-interpolation which interprets '%' characters. This means you
end up with an interpolation traceback when using any quoted character
(':@/') in a user/password (more likely password).
Avoid this by ensuring the URL is safe for python interpolation in
set_main_option by replacing '%' -> '%%'.
I convinced myself this is safe because sqlalchemy correctly parses
the quoted and unquoted versions just the same
---
>>> str(sqlalchemy.engine.url.make_url('mysql+pymysql://foo:crazy:@/pw@/moo'))
'mysql+pymysql://foo:crazy%3A%40%2Fpw@/moo'
>>> str(sqlalchemy.engine.url.make_url('mysql+pymysql://foo:crazy%3A%40%2Fpw@/moo'))
'mysql+pymysql://foo:crazy%3A%40%2Fpw@/moo'
---
A test is added
[1] https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/engine/url.py
[2] http://alembic.zzzcomputing.com/en/latest/api/config.html#alembic.config.Config.set_main_option
Change-Id: I3ef7e3e539e35ce040573f2044ab6eb3c990200a
Closes-Bug: #1695299
** Changed in: glance
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1695299
Title:
Glance installation fails if password contains '@' symbol
Status in Glance:
Fix Released
Status in Glance rocky series:
Fix Released
Bug description:
I was doing a fresh installation of devstack today and had set the
admin password as "Test@321" in local.conf file. The installation
started failing for Glance and when I had a look at the backtrace, it
looks like it converts '@' to '%40' and starts failing.
Either this needs to be fixed or proper note needs to be added in
devstack setup stating that one cannot use '@' symbol in passwords.
ubuntu@openstack:~/devstack$ glance --version
2.6.0
ubuntu@openstack:~/devstack$
CRITICAL glance [-] Unhandled error: ValueError: invalid interpolation syntax in 'mysql+pymysql://root:Test%40321@127.0.0.1/glance?charset=utf8' at position 27
ERROR glance Traceback (most recent call last):
ERROR glance File "/usr/local/bin/glance-manage", line 10, in <module>
ERROR glance sys.exit(main())
ERROR glance File "/opt/stack/glance/glance/cmd/manage.py", line 452, in main
ERROR glance return CONF.command.action_fn()
ERROR glance File "/opt/stack/glance/glance/cmd/manage.py", line 291, in sync
ERROR glance self.command_object.sync(CONF.command.version)
ERROR glance File "/opt/stack/glance/glance/cmd/manage.py", line 117, in sync
ERROR glance alembic_migrations.place_database_under_alembic_control()
ERROR glance File "/opt/stack/glance/glance/db/sqlalchemy/alembic_migrations/__init__.py", line 73, in place_database_under_alembic_control
ERROR glance a_config = get_alembic_config()
ERROR glance File "/opt/stack/glance/glance/db/sqlalchemy/alembic_migrations/__init__.py", line 37, in get_alembic_config
ERROR glance config.set_main_option('sqlalchemy.url', str(engine.url))
ERROR glance File "/usr/local/lib/python2.7/dist-packages/alembic/config.py", line 218, in set_main_option
ERROR glance self.set_section_option(self.config_ini_section, name, value)
ERROR glance File "/usr/local/lib/python2.7/dist-packages/alembic/config.py", line 245, in set_section_option
ERROR glance self.file_config.set(section, name, value)
ERROR glance File "/usr/lib/python2.7/ConfigParser.py", line 752, in set
ERROR glance "position %d" % (value, tmp_value.find('%')))
ERROR glance ValueError: invalid interpolation syntax in 'mysql+pymysql://root:Test%40321@127.0.0.1/glance?charset=utf8' at position 27
ERROR glance
+lib/glance:init_glance:1 exit_trap
+./stack.sh:exit_trap:492 local r=1
++./stack.sh:exit_trap:493 jobs -p
+./stack.sh:exit_trap:493 jobs=
+./stack.sh:exit_trap:496 [[ -n '' ]]
+./stack.sh:exit_trap:502 kill_spinner
+./stack.sh:kill_spinner:388 '[' '!' -z '' ']'
+./stack.sh:exit_trap:504 [[ 1 -ne 0 ]]
+./stack.sh:exit_trap:505 echo 'Error on exit'
Error on exit
+./stack.sh:exit_trap:506 generate-subunit 1496417170 632 fail
+./stack.sh:exit_trap:507 [[ -z /opt/stack/logs ]]
+./stack.sh:exit_trap:510 /home/ubuntu/devstack/tools/worlddump.py -d /opt/stack/logs
World dumping... see /opt/stack/logs/worlddump-2017-06-02-153642.txt for details
+./stack.sh:exit_trap:516 exit 1
ubuntu@openstack:~/devstack$
To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/1695299/+subscriptions
References