Skip to content

Improve the rule for automatically assigning resource groups after altering users - #2362

Open
fairyfar wants to merge 1 commit into
apache:mainfrom
fairyfar:user_resgrp
Open

fairyfar wants to merge 1 commit into
apache:mainfrom
fairyfar:user_resgrp

Conversation

@fairyfar

Copy link
Copy Markdown
Collaborator

Improve the rule for automatically assigning resource groups after altering users

What does this PR do?

Currently, when modifying user permissions, a SUPERUSER is downgraded to NOSUPERUSER and automatically assigned from admin_group to default_group, which is reasonable from a security perspective. However, it would be a bit superfluous for a NOSUPERUSER to be elevated to SUPERUSER and automatically assigned to admin_group. Moreover, the above reassignment actions were carried out silently without any prompts or warnings.

So, make the following changs:

  1. A SUPERUSER is downgraded to NOSUPERUSER, automatically assigned from admin_group to default_group, and a prompt is given.
  2. NOSUPERUSER is elevated to SUPERUSER without reassigning resource group.

Phenomenon before modification:

[ff@fairyfar cloudberry]$ psql postgres
psql (16.9, server 16.9)
Type "help" for help.

-- 1. NOSUPERUSER cannot be assigned to admin_group
postgres=# create user testu NOSUPERUSER resource group admin_group;
ERROR:  only superuser can be assigned to admin resgroup
-- 2. Super user can be assigned to default_group
postgres=# create user testu SUPERUSER resource group default_group;
CREATE ROLE
postgres=# select * from gp_toolkit.gp_resgroup_role where rrrolname='testu';
 rrrolname |   rrrsgname
-----------+---------------
 testu     | default_group
(1 row)

-- 3. After the user is altered to SUPERUSER, it is automatically assigned to admin_group.
-- There is no prompt at all.
postgres=# alter user testu SUPERUSER;
ALTER ROLE
postgres=# select * from gp_toolkit.gp_resgroup_role where rrrolname='testu';
 rrrolname |  rrrsgname
-----------+-------------
 testu     | admin_group
(1 row)

-- 4. When the user is altered to a NOSUPERUSER, it is automatically assigned to default_group.
-- There is no prompt at all.
postgres=# alter user testu NOSUPERUSER;
ALTER ROLE
postgres=# select * from gp_toolkit.gp_resgroup_role where rrrolname='testu';
 rrrolname |   rrrsgname
-----------+---------------
 testu     | default_group
(1 row)

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


…tering users

Currently, when modifying user permissions, a SUPERUSER is downgraded
to NOSUPERUSER and automatically assigned from admin_group to
default_group, which is reasonable from a security perspective.
However, it would be a bit superfluous for a NOSUPERUSER to be
elevated to SUPERUSER and automatically assigned to admin_group.
Moreover, the above reassignment actions were carried out silently
without any prompts or warnings.

So, make the following changs:
1. A SUPERUSER is downgraded to NOSUPERUSER, automatically assigned
from admin_group to default_group, and a prompt is given.
2. NOSUPERUSER is elevated to SUPERUSER without reassigning resource
group.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant