Skip to content

Commit c6741fb

Browse files
floriankissermart-e
authored andcommitted
[FIX] sql_db: don't log dsn with unmasked passwords
The dsn may contain the connection password of the database when not accessed from a psycopg connection object. Replace the unfiltered logs to use cxn.dsn avoiding password leakage in logs. Fixes odoo#1433
1 parent b95b134 commit c6741fb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

openerp/sql_db.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,6 @@ def _debug(self, msg, *args):
477477

478478
@locked
479479
def borrow(self, dsn):
480-
self._debug('Borrow connection to %r', dsn)
481-
482480
# free dead and leaked connections
483481
for i, (cnx, _) in tools.reverse_enumerate(self._connections):
484482
if cnx.closed:
@@ -503,7 +501,7 @@ def borrow(self, dsn):
503501
continue
504502
self._connections.pop(i)
505503
self._connections.append((cnx, True))
506-
self._debug('Existing connection found at index %d', i)
504+
self._debug('Borrow existing connection to %r at index %d', cnx.dsn, i)
507505

508506
return cnx
509507

@@ -546,11 +544,15 @@ def give_back(self, connection, keep_in_pool=True):
546544

547545
@locked
548546
def close_all(self, dsn=None):
549-
_logger.info('%r: Close all connections to %r', self, dsn)
547+
count = 0
548+
last = None
550549
for i, (cnx, used) in tools.reverse_enumerate(self._connections):
551550
if dsn is None or cnx._original_dsn == dsn:
552551
cnx.close()
553-
self._connections.pop(i)
552+
last = self._connections.pop(i)[0]
553+
count += 1
554+
_logger.info('%r: Closed %d connections %s', self, count,
555+
(dsn and last and 'to %r' % last.dsn) or '')
554556

555557

556558
class Connection(object):

0 commit comments

Comments
 (0)