public inbox for [email protected]help / color / mirror / Atom feed
[pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription 6+ messages / 3 participants [nested] [flat]
* [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription @ 2021-06-22 07:08 Pradip Parkale <[email protected]> 0 siblings, 1 reply; 6+ messages in thread From: Pradip Parkale @ 2021-06-22 07:08 UTC (permalink / raw) To: pgadmin-hackers 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: ^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription @ 2021-06-22 08:51 Fred <[email protected]> parent: Pradip Parkale <[email protected]> 0 siblings, 1 reply; 6+ messages in thread From: Fred @ 2021-06-22 08:51 UTC (permalink / raw) To: [email protected]; Pradip Parkale <[email protected]>; pgadmin-hackers 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 ^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription @ 2021-06-22 10:47 Pradip Parkale <[email protected]> parent: Fred <[email protected]> 0 siblings, 1 reply; 6+ messages in thread From: Pradip Parkale @ 2021-06-22 10:47 UTC (permalink / raw) To: pgadmin-hackers; +Cc: Aditya Toshniwal <[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: ^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription @ 2021-06-23 07:22 Akshay Joshi <[email protected]> parent: Pradip Parkale <[email protected]> 0 siblings, 1 reply; 6+ messages in thread From: Akshay Joshi @ 2021-06-23 07:22 UTC (permalink / raw) To: Pradip Parkale <[email protected]>; +Cc: pgadmin-hackers; Aditya Toshniwal <[email protected]> Thanks, the patch applied. On Tue, Jun 22, 2021 at 4:17 PM Pradip Parkale < [email protected]> wrote: > 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 > -- *Thanks & Regards* *Akshay Joshi* *pgAdmin Hacker | Principal Software Architect* *EDB Postgres <http://edbpostgres.com>* *Mobile: +91 976-788-8246* ^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription @ 2021-07-19 08:19 Pradip Parkale <[email protected]> parent: Akshay Joshi <[email protected]> 0 siblings, 1 reply; 6+ messages in thread From: Pradip Parkale @ 2021-07-19 08:19 UTC (permalink / raw) To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers; Aditya Toshniwal <[email protected]> Hi Akshay, Please find the updated patch.I have added a more reliable solution to solve this issue. On Wed, Jun 23, 2021 at 12:52 PM Akshay Joshi <[email protected]> wrote: > Thanks, the patch applied. > > On Tue, Jun 22, 2021 at 4:17 PM Pradip Parkale < > [email protected]> wrote: > >> 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 >> > > > -- > *Thanks & Regards* > *Akshay Joshi* > *pgAdmin Hacker | Principal Software Architect* > *EDB Postgres <http://edbpostgres.com>* > > *Mobile: +91 976-788-8246* > -- Thanks & Regards, Pradip Parkale Software Engineer | EnterpriseDB Corporation Attachments: [application/octet-stream] RM6448_v2.patch (871B, 3-RM6448_v2.patch) download | inline diff: diff --git a/web/pgadmin/tools/search_objects/utils.py b/web/pgadmin/tools/search_objects/utils.py index 407dc83f2..16cfefcd9 100644 --- a/web/pgadmin/tools/search_objects/utils.py +++ b/web/pgadmin/tools/search_objects/utils.py @@ -98,8 +98,12 @@ class SearchObjectsHelper: """ if obj_type == 'all': - status, error = conn.execute_dict('select * from pg_subscription') - if 'permission denied' in error: + status, error = conn.execute_dict( + "SELECT COUNT(1) FROM information_schema.table_privileges " + "WHERE table_name = 'pg_subscription' " + "AND privilege_type = 'SELECT'") + if 'count' in error['rows'][0] and \ + error['rows'][0]['count'] == '0': skip_obj_type.append('subscription') return skip_obj_type ^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription @ 2021-07-19 08:41 Akshay Joshi <[email protected]> parent: Pradip Parkale <[email protected]> 0 siblings, 0 replies; 6+ messages in thread From: Akshay Joshi @ 2021-07-19 08:41 UTC (permalink / raw) To: Pradip Parkale <[email protected]>; +Cc: pgadmin-hackers; Aditya Toshniwal <[email protected]> Thanks, the patch applied. On Mon, Jul 19, 2021 at 1:49 PM Pradip Parkale < [email protected]> wrote: > Hi Akshay, > Please find the updated patch.I have added a more reliable solution to > solve this issue. > > On Wed, Jun 23, 2021 at 12:52 PM Akshay Joshi < > [email protected]> wrote: > >> Thanks, the patch applied. >> >> On Tue, Jun 22, 2021 at 4:17 PM Pradip Parkale < >> [email protected]> wrote: >> >>> 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 >>> >> >> >> -- >> *Thanks & Regards* >> *Akshay Joshi* >> *pgAdmin Hacker | Principal Software Architect* >> *EDB Postgres <http://edbpostgres.com>* >> >> *Mobile: +91 976-788-8246* >> > > > -- > Thanks & Regards, > Pradip Parkale > Software Engineer | EnterpriseDB Corporation > -- *Thanks & Regards* *Akshay Joshi* *pgAdmin Hacker | Principal Software Architect* *EDB Postgres <http://edbpostgres.com>* *Mobile: +91 976-788-8246* ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2021-07-19 08:41 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-06-22 07:08 [pgAdmin][RM6448]: [search object] error displayed for non superuser because of right on pg_catalog.pg_subscription Pradip Parkale <[email protected]> 2021-06-22 08:51 ` Fred <[email protected]> 2021-06-22 10:47 ` Pradip Parkale <[email protected]> 2021-06-23 07:22 ` Akshay Joshi <[email protected]> 2021-07-19 08:19 ` Pradip Parkale <[email protected]> 2021-07-19 08:41 ` Akshay Joshi <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox