From a008f9ba79aee8f1b24cae6865611d5b00c8b9fd Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Tue, 28 Feb 2023 13:29:42 +0530 Subject: [PATCH] Fixed an issue where the database server is not connected using a service file. #5889 --- docs/en_US/release_notes_6_21.rst | 2 ++ web/pgadmin/utils/driver/psycopg2/server_manager.py | 4 +++- web/pgadmin/utils/driver/psycopg3/connection.py | 4 ++-- web/pgadmin/utils/driver/psycopg3/server_manager.py | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/en_US/release_notes_6_21.rst b/docs/en_US/release_notes_6_21.rst index 2768aac57..4be740680 100644 --- a/docs/en_US/release_notes_6_21.rst +++ b/docs/en_US/release_notes_6_21.rst @@ -44,5 +44,7 @@ Bug fixes | `Issue #5803 `_ - Fix an issue where query tool is stripping spaces in grid cell. | `Issue #5810 `_ - Fix an issue where sequence owner is remove on sequence edit. | `Issue #5822 `_ - Do not allow to save invalid JSON in query tool JSON editor. + | `Issue #5833 `_ - Fixed an issue where user MFA entry was not getting delete after deleting a user. | `Issue #5847 `_ - Fixed an issue where pgAdmin failed to connect when the Postgres password included special characters. | `Issue #5872 `_ - Handle MERGE operation in query tool explain introduced in PostgreSQL 15. + | `Issue #5889 `_ - Fixed an issue where the database server is not connected using a service file. diff --git a/web/pgadmin/utils/driver/psycopg2/server_manager.py b/web/pgadmin/utils/driver/psycopg2/server_manager.py index e2a7bb9c4..300d05f4a 100644 --- a/web/pgadmin/utils/driver/psycopg2/server_manager.py +++ b/web/pgadmin/utils/driver/psycopg2/server_manager.py @@ -641,6 +641,8 @@ WHERE db.oid = {0}""".format(did)) self.local_bind_port if self.use_ssh_tunnel else self.port dsn_args['dbname'] = database dsn_args['user'] = user + if self.service is not None: + dsn_args['service'] = self.service # Make a copy to display the connection string on GUI. display_dsn_args = dsn_args.copy() @@ -657,7 +659,7 @@ WHERE db.oid = {0}""".format(did)) orig_value = value # Getting complete file path if the key is one of the below. if key in ['passfile', 'sslcert', 'sslkey', 'sslrootcert', - 'sslcrl', 'service', 'sslcrldir']: + 'sslcrl', 'sslcrldir']: with_complete_path = True value = get_complete_file_path(value) diff --git a/web/pgadmin/utils/driver/psycopg3/connection.py b/web/pgadmin/utils/driver/psycopg3/connection.py index e9190a750..edcaf571d 100644 --- a/web/pgadmin/utils/driver/psycopg3/connection.py +++ b/web/pgadmin/utils/driver/psycopg3/connection.py @@ -268,7 +268,7 @@ class Connection(BaseConnection): password, encpass, is_update_password = self._check_user_password( kwargs) - passfile = manager.get_connection_param_value('passfile') + passfile = kwargs['passfile'] if 'passfile' in kwargs else None tunnel_password = kwargs['tunnel_password'] if 'tunnel_password' in \ kwargs else '' @@ -305,7 +305,7 @@ class Connection(BaseConnection): # we will check for pgpass file availability from connection manager # if it's present then we will use it if not password and not encpass and not passfile: - passfile = manager.passfile if manager.passfile else None + passfile = manager.get_connection_param_value('passfile') if manager.passexec: password = manager.passexec.get() diff --git a/web/pgadmin/utils/driver/psycopg3/server_manager.py b/web/pgadmin/utils/driver/psycopg3/server_manager.py index 79a6cb143..68be36b5c 100644 --- a/web/pgadmin/utils/driver/psycopg3/server_manager.py +++ b/web/pgadmin/utils/driver/psycopg3/server_manager.py @@ -642,6 +642,8 @@ WHERE db.oid = {0}""".format(did)) self.local_bind_port if self.use_ssh_tunnel else self.port dsn_args['dbname'] = database dsn_args['user'] = user + if self.service is not None: + dsn_args['service'] = self.service # Make a copy to display the connection string on GUI. display_dsn_args = dsn_args.copy() @@ -658,7 +660,7 @@ WHERE db.oid = {0}""".format(did)) orig_value = value # Getting complete file path if the key is one of the below. if key in ['passfile', 'sslcert', 'sslkey', 'sslrootcert', - 'sslcrl', 'service', 'sslcrldir']: + 'sslcrl', 'sslcrldir']: with_complete_path = True value = get_complete_file_path(value)