openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #14887
[Bug 1041712] Re: sql_db.py does not support spaces in passwords
The DSN string can contain a password; this is how sql_db.borrow()
connects to the database, vis:
try:
result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
except psycopg2.Error:
_logger.exception('Connection to the database failed')
raise
If the dsn here didn't have a password in it, the call to
psycopg2.connect() wouldn't work.
In dsn_are_equals(), you'll note that directly after doing the dict()
call, there is:
k.pop('password', None) # password is not relevant
indicating that if the password is part of either first or second, it
gets discarded before returning the dictionary. Why discard something
that isn't there?
This was also previously a bug in psycopg, fixed in version 2.4.3, as
per:
http://psycopg.lighthouseapp.com/projects/62710/tickets/87
-psycopg2connect-fails-when-using-spaces-in-password-keyword
** Description changed:
In version 6.1: in this sql_db.py code:
def dsn_are_equals(first, second):
- def key(dsn):
- k = dict(x.split('=', 1) for x in dsn.strip().split())
- k.pop('password', None) # password is not relevant
- return k
- return key(first) == key(second)
+ def key(dsn):
+ k = dict(x.split('=', 1) for x in dsn.strip().split())
+ k.pop('password', None) # password is not relevant
+ return k
+ return key(first) == key(second)
- if the password in the DSN contains spaces, the dsn.split().split() does
+ if the password in the DSN contains spaces, the dsn.strip().split() does
not work correctly, and means that the dict is called with an update()
containing only one item, instead of 2, giving this error:
dictionary update sequence element #2 has length 1; 2 is required
This affects many processes, including initial database creation. It's
an obscure error, so it's not immediately obvious that a space in the
server password is the cause.
--
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/1041712
Title:
sql_db.py does not support spaces in passwords
Status in OpenERP Server:
Incomplete
Bug description:
In version 6.1: in this sql_db.py code:
def dsn_are_equals(first, second):
def key(dsn):
k = dict(x.split('=', 1) for x in dsn.strip().split())
k.pop('password', None) # password is not relevant
return k
return key(first) == key(second)
if the password in the DSN contains spaces, the dsn.strip().split()
does not work correctly, and means that the dict is called with an
update() containing only one item, instead of 2, giving this error:
dictionary update sequence element #2 has length 1; 2 is required
This affects many processes, including initial database creation. It's
an obscure error, so it's not immediately obvious that a space in the
server password is the cause.
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/1041712/+subscriptions
References