Opened 19 years ago
Closed 15 years ago
#2448 closed defect (fixed)
[patch] Trac does not allow spaces in postgres database passwords
Reported by: | Owned by: | John Hampton | |
---|---|---|---|
Priority: | normal | Milestone: | 0.12 |
Component: | general | Version: | devel |
Severity: | normal | Keywords: | |
Cc: | pacopablo@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Trac currently doesn't allow spaces in postgres database passwords; the following patch (against r2616) fixes it:
Index: trac/db/postgres_backend.py =================================================================== --- trac/db/postgres_backend.py (revision 2616) +++ trac/db/postgres_backend.py (working copy) @@ -91,7 +91,7 @@ if user: dsn.append('user=' + user) if password: - dsn.append('password=' + password) + dsn.append("password='%s'" % password) if host: dsn.append('host=' + host) if port:
Attachments (0)
Change History (10)
comment:1 by , 18 years ago
Keywords: | review added |
---|
comment:2 by , 18 years ago
Cc: | added |
---|
comment:3 by , 18 years ago
Owner: | changed from | to
---|
Jacob or John can you test this patch which quotes all parameters to the DSN:
-
trac/db/postgres_backend.py
119 119 if 'host' in params: 120 120 host = params['host'] 121 121 if psycopg: 122 dsn = [] 123 if path: 124 dsn.append('dbname=' + path) 125 if user: 126 dsn.append('user=' + user) 127 if password: 128 dsn.append('password=' + password) 129 if host: 130 dsn.append('host=' + host) 131 if port: 132 dsn.append('port=' + str(port)) 133 cnx = psycopg.connect(' '.join(dsn)) 122 dsn = {'dbname': path, 'user': user, 'password': password, 123 'host': host, 'port': port} 124 cnx = psycopg.connect(' '.join([("%s='%s'" % k,v) for k,v 125 in dsn.iteritems() if v])) 134 126 cnx.set_client_encoding('UNICODE') 135 127 else: 136 128 # Don't use chatty, inefficient server-side cursors.
comment:4 by , 18 years ago
Milestone: | → 0.11 |
---|
comment:5 by , 15 years ago
Keywords: | bitesized added |
---|
comment:6 by , 15 years ago
Keywords: | review bitesized removed |
---|---|
Milestone: | next-minor-0.12.x → 0.12 |
Owner: | changed from | to
Status: | new → assigned |
OK, so patch is mostly correct. The bigger issue is that enabling spaces also screws up the db uri parser. I'll start working on a patch for that.
comment:8 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:9 by , 15 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Meep.
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32 >>> from itertools import combinations Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: cannot import name combinations ActivePython 2.5.4.4 (ActiveState Software Inc.) based on Python 2.5.4 (r254:67916, Apr 27 2009, 15:41:14) [MSC v.1310 32 bit (Intel)] on win32 >>> from itertools import combinations Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name combinations
Plus note that itertools is riddled with memory issues, try to avoid it (ok, for the tests it's fine).
comment:10 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
See what I get for writing tests? :)
Test fixed in [9229]
patch attached, needs to be reviewed