public inbox for [email protected]
help / color / mirror / Atom feedFrom: Pradip Parkale <[email protected]>
To: pgadmin-hackers <[email protected]>
Cc: Aditya Toshniwal <[email protected]>
Subject: Re: [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription
Date: Tue, 22 Jun 2021 16:17:03 +0530
Message-ID: <CAJ9T6SvJk6wW9qrGTURm+iGX=i5QzPoqQ=46950uFeu40AZdaQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAJ9T6SsKmtv8f4kXF=qdzXVWrV9EAB-QhOBFrZ80i0wNcNwRNg@mail.gmail.com>
<[email protected]>
Hi Hackers,
Please ignore my previous email and find the attached patch. I have fixed
some review comments given by Aditya.
On Tue, Jun 22, 2021 at 2:21 PM Fred <[email protected]> wrote:
> nice !
> thanks
>
> fred
>
>
> Le 22 juin 2021 09:08:05 GMT+02:00, Pradip Parkale <
> [email protected]> a écrit :
>>
>> 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
>>
>
--
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation
Attachments:
[application/octet-stream] RM6448_v2.patch (6.1K, 3-RM6448_v2.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..be4a47136 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 'subscription' not in skip_obj_type%}
{% 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..992b547ae 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 'subscription' not in skip_obj_type%}
{% 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..356509fd6 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 'subscription' not in skip_obj_type%}
{% 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..63273498b 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 'subscription' not in skip_obj_type%}
{% 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..407dc83f2 100644
--- a/web/pgadmin/tools/search_objects/utils.py
+++ b/web/pgadmin/tools/search_objects/utils.py
@@ -89,7 +89,23 @@ class SearchObjectsHelper:
**kwargs
)
+ def _check_permission(self, obj_type, conn, skip_obj_type):
+ """
+ This function return whether user has permission to see type
+ :param obj_type:
+ :param conn:
+ :return:
+ """
+
+ if obj_type == 'all':
+ status, error = conn.execute_dict('select * from pg_subscription')
+ if 'permission denied' in error:
+ skip_obj_type.append('subscription')
+
+ return skip_obj_type
+
def search(self, text, obj_type=None):
+ skip_obj_type = []
conn = self.manager.connection(did=self.did)
last_system_oid = (self.manager.db_info[self.did])['datlastsysoid'] \
if self.manager.db_info is not None and self.did in \
@@ -99,6 +115,8 @@ class SearchObjectsHelper:
node_labels = self.get_supported_types(skip_check=True)
# escape the single quote from search text
text = text.replace("'", "''")
+ skip_obj_type = self._check_permission(obj_type, conn,
+ skip_obj_type)
# Column catalog_level has values as
# N - Not a catalog schema
@@ -109,7 +127,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_obj_type=skip_obj_type)
)
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], [email protected]
Subject: Re: [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription
In-Reply-To: <CAJ9T6SvJk6wW9qrGTURm+iGX=i5QzPoqQ=46950uFeu40AZdaQ@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