Fixed an issue where privileges were revoked using SQL query on objects like tables that do not correctly show in SQL tab. Fixes #4567

This commit is contained in:
Nikhil Mohite 2021-08-27 12:54:14 +05:30 committed by Akshay Joshi
parent d38f520805
commit b764046587
6 changed files with 51 additions and 0 deletions

View File

@ -22,6 +22,7 @@ Housekeeping
Bug fixes
*********
| `Issue #4567 <https://redmine.postgresql.org/issues/4567>`_ - Fixed an issue where privileges were revoked using SQL query on objects like tables that do not correctly show in SQL tab.
| `Issue #5849 <https://redmine.postgresql.org/issues/5849>`_ - Ensure that trigger function SQL should have 'create or replace function' instead of 'create function' only.
| `Issue #6419 <https://redmine.postgresql.org/issues/6419>`_ - Fixed blank screen issue on windows and also made changes to use NWjs manifest for remembering window size.
| `Issue #6531 <https://redmine.postgresql.org/issues/6531>`_ - Fixed the export image issue where relation lines are over the nodes.

View File

@ -129,6 +129,11 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
{% endfor %}
{% endif %}
{### ACL on Table ###}
{% if data.revoke_all %}
{% for priv in data.revoke_all %}
{{ PRIVILEGE.UNSETALL(conn, "TABLE", priv, data.name, data.schema)}}
{% endfor %}
{% endif %}
{% if data.relacl %}
{% for priv in data.relacl %}

View File

@ -130,6 +130,11 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
{% endfor %}
{% endif %}
{### ACL on Table ###}
{% if data.revoke_all %}
{% for priv in data.revoke_all %}
{{ PRIVILEGE.UNSETALL(conn, "TABLE", priv, data.name, data.schema)}}
{% endfor %}
{% endif %}
{% if data.relacl %}
{% for priv in data.relacl %}

View File

@ -148,6 +148,11 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
{% endfor %}
{% endif %}
{### ACL on Table ###}
{% if data.revoke_all %}
{% for priv in data.revoke_all %}
{{ PRIVILEGE.UNSETALL(conn, "TABLE", priv, data.name, data.schema)}}
{% endfor %}
{% endif %}
{% if data.relacl %}
{% for priv in data.relacl %}

View File

@ -118,6 +118,11 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
{% endfor %}
{% endif %}
{### ACL on Table ###}
{% if data.revoke_all %}
{% for priv in data.revoke_all %}
{{ PRIVILEGE.UNSETALL(conn, "TABLE", priv, data.name, data.schema)}}
{% endfor %}
{% endif %}
{% if data.relacl %}
{% for priv in data.relacl %}

View File

@ -625,8 +625,32 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
elif not estimated_row_count:
res['rows'][0]['rows_cnt'] = estimated_row_count
# Fetch privileges
sql = render_template("/".join([self.table_template_path,
self._ACL_SQL]),
tid=tid, scid=scid)
status, tblaclres = self.conn.execute_dict(sql)
if not status:
return internal_server_error(errormsg=res)
# Get Formatted Privileges
res['rows'][0].update(self._format_tbacl_from_db(tblaclres['rows']))
return True, res
def _format_tbacl_from_db(self, tbacl):
"""
Returns privileges.
Args:
tbacl: Privileges Dict
"""
privileges = []
for row in tbacl:
priv = parse_priv_from_db(row)
privileges.append(priv)
return {"acl": privileges}
def _format_column_list(self, data):
# Now we have all lis of columns which we need
# to include in our create definition, Let's format them
@ -671,6 +695,12 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
if 'relacl' in data:
data['relacl'] = parse_priv_to_db(data['relacl'], self.acl)
if 'acl' in data:
for acl in data['acl']:
data.update({'revoke_all': []})
if len(acl['privileges']) > 1:
data['revoke_all'].append(acl['grantee'])
# if table is partitions then
if 'relispartition' in data and data['relispartition']:
table_sql = render_template("/".join([self.partition_template_path,