public inbox for [email protected]
help / color / mirror / Atom feedFrom: Pradip Parkale <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription
Date: Tue, 22 Jun 2021 12:38:05 +0530
Message-ID: <CAJ9T6SsKmtv8f4kXF=qdzXVWrV9EAB-QhOBFrZ80i0wNcNwRNg@mail.gmail.com> (raw)
Hi Hackers,
Please find the attached patch for # 6448. I have added a check to ignore
the subscription when the search type is 'All type' if the user doesn't
have access to subscription.
--
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation
Attachments:
[application/octet-stream] RM6448.patch (5.9K, 3-RM6448.patch)
download | inline diff:
diff --git a/web/pgadmin/tools/search_objects/templates/search_objects/sql/pg/10_plus/search.sql b/web/pgadmin/tools/search_objects/templates/search_objects/sql/pg/10_plus/search.sql
index 1a472230b..0c5764ea0 100644
--- a/web/pgadmin/tools/search_objects/templates/search_objects/sql/pg/10_plus/search.sql
+++ b/web/pgadmin/tools/search_objects/templates/search_objects/sql/pg/10_plus/search.sql
@@ -330,6 +330,7 @@ FROM (
UNION
{% endif %}
+{% if not skip_search %}
{% if all_obj or obj_type in ['subscription'] %}
SELECT 'subscription'::text AS obj_type, subname AS obj_name, ':subscription.'||pub.oid||':/' || subname AS obj_path, ''::text AS schema_name,
{{ show_node_prefs['subscription'] }} AS show_node, NULL AS other_info
@@ -338,6 +339,7 @@ FROM (
{% if all_obj %}
UNION
{% endif %}
+{% endif %}
{% if all_obj or obj_type in ['language'] %}
SELECT 'language'::text AS obj_type, lanname AS obj_name, ':language.'||lan.oid||':/' || lanname AS obj_path, ''::text AS schema_name,
{{ show_node_prefs['language'] }} AS show_node, NULL AS other_info
diff --git a/web/pgadmin/tools/search_objects/templates/search_objects/sql/pg/11_plus/search.sql b/web/pgadmin/tools/search_objects/templates/search_objects/sql/pg/11_plus/search.sql
index 26fc238aa..2f48d1a23 100644
--- a/web/pgadmin/tools/search_objects/templates/search_objects/sql/pg/11_plus/search.sql
+++ b/web/pgadmin/tools/search_objects/templates/search_objects/sql/pg/11_plus/search.sql
@@ -346,7 +346,7 @@ FROM (
{% if all_obj %}
UNION
{% endif %}
-
+{% if not skip_search %}
{% if all_obj or obj_type in ['subscription'] %}
SELECT 'subscription'::text AS obj_type, subname AS obj_name, ':subscription.'||pub.oid||':/' || subname AS obj_path, ''::text AS schema_name,
{{ show_node_prefs['subscription'] }} AS show_node, NULL AS other_info
@@ -355,6 +355,7 @@ FROM (
{% if all_obj %}
UNION
{% endif %}
+{% endif %}
{% if all_obj or obj_type in ['language'] %}
SELECT 'language'::text AS obj_type, lanname AS obj_name, ':language.'||lan.oid||':/' || lanname AS obj_path, ''::text AS schema_name,
{{ show_node_prefs['language'] }} AS show_node, NULL AS other_info
diff --git a/web/pgadmin/tools/search_objects/templates/search_objects/sql/ppas/10_plus/search.sql b/web/pgadmin/tools/search_objects/templates/search_objects/sql/ppas/10_plus/search.sql
index b5fc01b51..2649e07ff 100644
--- a/web/pgadmin/tools/search_objects/templates/search_objects/sql/ppas/10_plus/search.sql
+++ b/web/pgadmin/tools/search_objects/templates/search_objects/sql/ppas/10_plus/search.sql
@@ -371,6 +371,7 @@ FROM (
UNION
{% endif %}
+{% if not skip_search %}
{% if all_obj or obj_type in ['subscription'] %}
SELECT 'subscription'::text AS obj_type, subname AS obj_name, ':subscription.'||pub.oid||':/' || subname AS obj_path, ''::text AS schema_name,
{{ show_node_prefs['subscription'] }} AS show_node, NULL AS other_info
@@ -379,6 +380,7 @@ FROM (
{% if all_obj %}
UNION
{% endif %}
+{% endif %}
{% if all_obj or obj_type in ['language'] %}
SELECT 'language'::text AS obj_type, lanname AS obj_name, ':language.'||lan.oid||':/' || lanname AS obj_path, ''::text AS schema_name,
diff --git a/web/pgadmin/tools/search_objects/templates/search_objects/sql/ppas/12_plus/search.sql b/web/pgadmin/tools/search_objects/templates/search_objects/sql/ppas/12_plus/search.sql
index 1a6165836..6c3bb9954 100644
--- a/web/pgadmin/tools/search_objects/templates/search_objects/sql/ppas/12_plus/search.sql
+++ b/web/pgadmin/tools/search_objects/templates/search_objects/sql/ppas/12_plus/search.sql
@@ -378,6 +378,7 @@ FROM (
UNION
{% endif %}
+{% if not skip_search %}
{% if all_obj or obj_type in ['subscription'] %}
SELECT 'subscription'::text AS obj_type, subname AS obj_name, ':subscription.'||pub.oid||':/' || subname AS obj_path, ''::text AS schema_name,
{{ show_node_prefs['subscription'] }} AS show_node, NULL AS other_info
@@ -386,6 +387,7 @@ FROM (
{% if all_obj %}
UNION
{% endif %}
+{% endif %}
{% if all_obj or obj_type in ['language'] %}
SELECT 'language'::text AS obj_type, lanname AS obj_name, ':language.'||lan.oid||':/' || lanname AS obj_path, ''::text AS schema_name,
diff --git a/web/pgadmin/tools/search_objects/utils.py b/web/pgadmin/tools/search_objects/utils.py
index a7d556853..d1e70570b 100644
--- a/web/pgadmin/tools/search_objects/utils.py
+++ b/web/pgadmin/tools/search_objects/utils.py
@@ -89,6 +89,22 @@ class SearchObjectsHelper:
**kwargs
)
+ def _check_for_permission(self, obj_type, conn):
+ """
+ This function return whether user has permission to see subscription
+ :param obj_type:
+ :param conn:
+ :return:
+ """
+ skip_search = False
+
+ if obj_type == 'all':
+ status, error = conn.execute_dict('select * from pg_subscription')
+ if 'permission denied' in error:
+ skip_search = True
+
+ return skip_search
+
def search(self, text, obj_type=None):
conn = self.manager.connection(did=self.did)
last_system_oid = (self.manager.db_info[self.did])['datlastsysoid'] \
@@ -99,6 +115,7 @@ class SearchObjectsHelper:
node_labels = self.get_supported_types(skip_check=True)
# escape the single quote from search text
text = text.replace("'", "''")
+ skip_search = self._check_for_permission(obj_type, conn)
# Column catalog_level has values as
# N - Not a catalog schema
@@ -109,7 +126,8 @@ class SearchObjectsHelper:
search_text=text.lower(), obj_type=obj_type,
show_system_objects=self.show_system_objects,
show_node_prefs=show_node_prefs, _=gettext,
- last_system_oid=last_system_oid)
+ last_system_oid=last_system_oid,
+ skip_search=skip_search)
)
if not status:
view thread (6+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription
In-Reply-To: <CAJ9T6SsKmtv8f4kXF=qdzXVWrV9EAB-QhOBFrZ80i0wNcNwRNg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox