public inbox for [email protected]
help / color / mirror / Atom feedFrom: Murtuza Zabuawala <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: PATCH: To fix issue using PUBLIC as role (pgAdmin4)
Date: Wed, 13 Jul 2016 16:10:07 +0530
Message-ID: <CAKKotZTxai6NywDRkMnkoUB3JeqOwk012N==aLAya_KL7_BOcA@mail.gmail.com> (raw)
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
Hi,
PFA patch to fix the issue where user was not able to select 'PUBLIC' as
role in privileges.
(RM#1416)
This issue was due to previous commit: b78b3904cd7e5a8edf
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] RM_1416.patch (10.5K, 3-RM_1416.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/macros/privilege.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/macros/privilege.macros
index 7eafd60..7fe81e5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/macros/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/macros/privilege.macros
@@ -1,13 +1,13 @@
{% macro APPLY(conn, schema_name, table_object, column_object, role, privs, with_grant_privs) -%}
{% if privs %}
GRANT {% for p in privs %}{% if loop.index != 1 %}, {% endif %}{{p}}({{conn|qtIdent(column_object)}}){% endfor %}
- ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ conn|qtIdent(role) }};
+ ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
GRANT {% for p in with_grant_privs %}{% if loop.index != 1 %}, {% endif %}{{p}}({{conn|qtIdent(column_object)}}){% endfor %}
- ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+ ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro RESETALL(conn, schema_name, table_object, column_object, role) -%}
-REVOKE ALL({{ conn|qtIdent(column_object) }}) ON {{ conn|qtIdent(schema_name, table_object) }} FROM {{ conn|qtIdent(role) }};
+REVOKE ALL({{ conn|qtIdent(column_object) }}) ON {{ conn|qtIdent(schema_name, table_object) }} FROM {{ role }};
{%- endmacro %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/macros/privilege.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/macros/privilege.macros
index 7eafd60..7fe81e5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/macros/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/macros/privilege.macros
@@ -1,13 +1,13 @@
{% macro APPLY(conn, schema_name, table_object, column_object, role, privs, with_grant_privs) -%}
{% if privs %}
GRANT {% for p in privs %}{% if loop.index != 1 %}, {% endif %}{{p}}({{conn|qtIdent(column_object)}}){% endfor %}
- ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ conn|qtIdent(role) }};
+ ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
GRANT {% for p in with_grant_privs %}{% if loop.index != 1 %}, {% endif %}{{p}}({{conn|qtIdent(column_object)}}){% endfor %}
- ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+ ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro RESETALL(conn, schema_name, table_object, column_object, role) -%}
-REVOKE ALL({{ conn|qtIdent(column_object) }}) ON {{ conn|qtIdent(schema_name, table_object) }} FROM {{ conn|qtIdent(role) }};
+REVOKE ALL({{ conn|qtIdent(column_object) }}) ON {{ conn|qtIdent(schema_name, table_object) }} FROM {{ role }};
{%- endmacro %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/functions/privilege.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/functions/privilege.macros
index 08d1198..3a55908 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/functions/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/functions/privilege.macros
@@ -3,12 +3,12 @@
{##############################################}
{% macro SET(conn, type, role, param, privs, with_grant_privs, schema, func_args) -%}
{% if privs %}
-GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) TO {{conn|qtIdent(role) }};
+GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) TO {{role }};
{% endif %}
{% if with_grant_privs %}
-GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro UNSETALL(conn, type, role, param, schema, func_args) -%}
-REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) FROM {{conn|qtIdent(role) }};
+REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) FROM {{role }};
{%- endmacro %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
index dc18a31..5211b00 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
@@ -3,16 +3,16 @@
{##########################################}
{% macro SET(conn, type, role, param, privs, with_grant_privs, schema) -%}
{% if privs %}
-GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }};
+GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
{% if privs %}
{# This empty if is to add new line in between #}
{% endif %}
-GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro UNSETALL(conn, type, role, param, schema) -%}
-REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }} FROM {{ conn|qtIdent(role) }};
+REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }} FROM {{ role }};
{%- endmacro %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros b/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros
index 5135d61..6372d6b 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros
@@ -1,29 +1,29 @@
{% macro APPLY(conn, type, role, privs, with_grant_privs) -%}
{% if privs %}
ALTER DEFAULT PRIVILEGES
-GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }};
+GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
ALTER DEFAULT PRIVILEGES
-GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro RESETALL(conn, type, role) -%}
ALTER DEFAULT PRIVILEGES
- REVOKE ALL ON {{ type }} FROM {{ conn|qtIdent(role) }};
+ REVOKE ALL ON {{ type }} FROM {{ role }};
{%- endmacro %}
{### To allow create macro for specific database object ###}
{% macro SET(conn, db_object_type, db_object_name, type, role, privs, with_grant_privs) -%}
{% if privs %}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
-GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }};
+GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
-GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro UNSET(conn, db_object_type, db_object_name, type, role) -%}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
- REVOKE ALL ON {{ type }} FROM {{ conn|qtIdent(role) }};
+ REVOKE ALL ON {{ type }} FROM {{ role }};
{%- endmacro %}
diff --git a/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros b/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
index 31b5e38..77ec540 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
@@ -1,11 +1,11 @@
{% macro APPLY(conn, type, role, param, privs, with_grant_privs) -%}
{% if privs %}
-GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIdent(role) }};
+GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
-GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro RESETALL(conn, type, role, param) -%}
-REVOKE ALL ON {{ type }} {{ conn|qtIdent(param) }} FROM {{ conn|qtIdent(role) }};
+REVOKE ALL ON {{ type }} {{ conn|qtIdent(param) }} FROM {{ role }};
{%- endmacro %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/utils.py b/web/pgadmin/browser/server_groups/servers/utils.py
index 02fab9e..356b808 100644
--- a/web/pgadmin/browser/server_groups/servers/utils.py
+++ b/web/pgadmin/browser/server_groups/servers/utils.py
@@ -37,6 +37,10 @@ def parse_priv_to_db(str_privileges, allowed_acls=[]):
"""
Common utility function to parse privileges before sending to database.
"""
+ from pgadmin.utils.driver import get_driver
+ from config import PG_DEFAULT_DRIVER
+ driver = get_driver(PG_DEFAULT_DRIVER)
+
db_privileges = {
'c': 'CONNECT',
'C': 'CREATE',
@@ -82,7 +86,8 @@ def parse_priv_to_db(str_privileges, allowed_acls=[]):
priv_without_grant = ['ALL']
# Appending and returning all ACL
privileges.append({
- 'grantee': priv['grantee'],
+ 'grantee': driver.qtIdent(None, priv['grantee'])
+ if priv['grantee'] != 'PUBLIC' else 'PUBLIC',
'with_grant': priv_with_grant,
'without_grant': priv_without_grant
})
view thread (2+ 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: PATCH: To fix issue using PUBLIC as role (pgAdmin4)
In-Reply-To: <CAKKotZTxai6NywDRkMnkoUB3JeqOwk012N==aLAya_KL7_BOcA@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