|
17 | 17 | import secrets |
18 | 18 | import datetime |
19 | 19 | import asyncio |
20 | | -import copy |
21 | 20 | from collections import deque |
22 | 21 | import psycopg |
23 | 22 | from flask import g, current_app |
@@ -281,7 +280,6 @@ def connect(self, **kwargs): |
281 | 280 | password, encpass, is_update_password = \ |
282 | 281 | self._check_user_password(kwargs) |
283 | 282 |
|
284 | | - passfile = kwargs['passfile'] if 'passfile' in kwargs else None |
285 | 283 | tunnel_password = kwargs['tunnel_password'] if 'tunnel_password' in \ |
286 | 284 | kwargs else '' |
287 | 285 |
|
@@ -313,14 +311,22 @@ def connect(self, **kwargs): |
313 | 311 | if is_error: |
314 | 312 | return False, errmsg |
315 | 313 |
|
316 | | - # If no password credential is found then connect request might |
317 | | - # come from Query tool, ViewData grid, debugger etc tools. |
318 | | - # we will check for pgpass file availability from connection manager |
319 | | - # if it's present then we will use it |
320 | | - if not password and not encpass and not passfile: |
321 | | - passfile = manager.get_connection_param_value('passfile') |
322 | | - if manager.passexec: |
323 | | - password = manager.passexec.get() |
| 314 | + # If no password credential is found then connect request might come |
| 315 | + # from Query tool, ViewData grid, debugger, etc. In that case, fall |
| 316 | + # back to using the password returned from manager.passexec. |
| 317 | + passfile = manager.get_connection_param_value('passfile') |
| 318 | + if not password and not encpass and not passfile and manager.passexec: |
| 319 | + password = manager.passexec.get() |
| 320 | + |
| 321 | + # create_connection_string() automatically picks up the passfile from |
| 322 | + # connection parameters. Warn if that differs from the passfile kwarg. |
| 323 | + passfile_kwarg = kwargs.get('passfile', None) |
| 324 | + if passfile_kwarg and passfile_kwarg != passfile: |
| 325 | + current_app.logger.warning( |
| 326 | + "Using the first of two specified passfiles: {!r}, {!r}".format( |
| 327 | + passfile, passfile_kwarg |
| 328 | + ) |
| 329 | + ) |
324 | 330 |
|
325 | 331 | try: |
326 | 332 | database = self.db |
|
0 commit comments