From 14a5d05b80209a17f7b88bb03eba24254e4f9118 Mon Sep 17 00:00:00 2001 From: Khushboo Vashi Date: Fri, 30 Oct 2020 15:03:18 +0530 Subject: [PATCH] Ensure that non-superuser should be able to debug the function. Fixes #5760 --- docs/en_US/release_notes_4_28.rst | 1 + web/pgadmin/tools/debugger/__init__.py | 48 ++++++++++++++------------ 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/docs/en_US/release_notes_4_28.rst b/docs/en_US/release_notes_4_28.rst index d274117ad..9a0234b82 100644 --- a/docs/en_US/release_notes_4_28.rst +++ b/docs/en_US/release_notes_4_28.rst @@ -23,6 +23,7 @@ Bug fixes | `Issue #4639 `_ - Ensure that some fields should be disabled for the trigger in edit mode. | `Issue #5736 `_ - Fixed an issue where the validation error message is shown twice. +| `Issue #5760 `_ - Ensure that non-superuser should be able to debug the function. | `Issue #5842 `_ - Ensure that query history should be listed by date/time in descending order. | `Issue #5858 `_ - Ensure that search object functionality works with case insensitive string. | `Issue #5895 `_ - Fixed an issue where the suffix for Toast table size is not visible in the Statistics tab. diff --git a/web/pgadmin/tools/debugger/__init__.py b/web/pgadmin/tools/debugger/__init__.py index 422a8aefb..5adc7e3f6 100644 --- a/web/pgadmin/tools/debugger/__init__.py +++ b/web/pgadmin/tools/debugger/__init__.py @@ -686,32 +686,34 @@ def validate_debug(conn, debug_type, is_superuser): :param is_superuser: :return: """ - if debug_type == 'indirect' and not is_superuser: - # If user is super user then we should check debugger library is - # loaded or not - msg = gettext("You must be a superuser to set a global breakpoint" - " and perform indirect debugging.") - return False, internal_server_error(errormsg=msg) + if debug_type == 'indirect': + if not is_superuser: + # If user is super user then we should check debugger library is + # loaded or not + msg = gettext("You must be a superuser to set a global breakpoint" + " and perform indirect debugging.") + return False, internal_server_error(errormsg=msg) - status, rid_pre = conn.execute_scalar( - "SHOW shared_preload_libraries" - ) - if not status: - return False, internal_server_error( - gettext("Could not fetch debugger plugin information.") + status, rid_pre = conn.execute_scalar( + "SHOW shared_preload_libraries" ) - # Need to check if plugin is really loaded or not with - # "plugin_debugger" string - if debug_type == 'indirect' and "plugin_debugger" not in rid_pre: - msg = gettext( - "The debugger plugin is not enabled. " - "Please add the plugin to the shared_preload_libraries " - "setting in the postgresql.conf file and restart the " - "database server for indirect debugging." - ) - current_app.logger.debug(msg) - return False, internal_server_error(msg) + if not status: + return False, internal_server_error( + gettext("Could not fetch debugger plugin information.") + ) + + # Need to check if plugin is really loaded or not with + # "plugin_debugger" string + if "plugin_debugger" not in rid_pre: + msg = gettext( + "The debugger plugin is not enabled. " + "Please add the plugin to the shared_preload_libraries " + "setting in the postgresql.conf file and restart the " + "database server for indirect debugging." + ) + current_app.logger.debug(msg) + return False, internal_server_error(msg) # Check debugger extension version for EPAS 11 and above. # If it is 1.0 then return error to upgrade the extension.