Ensure that non-superuser should be able to debug the function. Fixes #5760

This commit is contained in:
Khushboo Vashi 2020-10-30 15:03:18 +05:30 committed by Akshay Joshi
parent 183c83f0d2
commit 14a5d05b80
2 changed files with 26 additions and 23 deletions

View File

@ -23,6 +23,7 @@ Bug fixes
| `Issue #4639 <https://redmine.postgresql.org/issues/4639>`_ - Ensure that some fields should be disabled for the trigger in edit mode.
| `Issue #5736 <https://redmine.postgresql.org/issues/5736>`_ - Fixed an issue where the validation error message is shown twice.
| `Issue #5760 <https://redmine.postgresql.org/issues/5760>`_ - Ensure that non-superuser should be able to debug the function.
| `Issue #5842 <https://redmine.postgresql.org/issues/5842>`_ - Ensure that query history should be listed by date/time in descending order.
| `Issue #5858 <https://redmine.postgresql.org/issues/5858>`_ - Ensure that search object functionality works with case insensitive string.
| `Issue #5895 <https://redmine.postgresql.org/issues/5895>`_ - Fixed an issue where the suffix for Toast table size is not visible in the Statistics tab.

View File

@ -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.