Skip to content

[Bug]: Any spelling of "public" in a Database usage is treated as the PUBLIC pseudo-role #11955

Open

Description

@mnencia

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

Version

trunk (main)

What happened?

In the Database resource, the usage entries for schemas, foreign data wrappers and foreign servers treat any spelling of public (public, Public, PUBLIC) as the PUBLIC pseudo-role. The webhook folds the name to detect duplicates, and sanitizeGrantee (introduced by #10829) emits the bare PUBLIC keyword.

PostgreSQL only reserves the exact lowercase name. CREATE ROLE "Public" and CREATE ROLE "PUBLIC" succeed, and GRANT ... TO "Public" is a different ACL entry from GRANT ... TO PUBLIC. I checked this on PostgreSQL 15.20 and 18.7, with the same result:

create role public;    -- ERROR: role name "public" is reserved
create role "Public";  -- ok
create role "PUBLIC";  -- ok
revoke connect on database t from public;
grant connect on database t to "Public";
-- aclexplode: grantee 16385 ("Public") holds CONNECT, grantee 0 (PUBLIC) does not

A role with one of those names cannot be managed from the Database resource. A revoke entry meant for it revokes the privilege from every role instead.

Database-level permissions (#11906) follows the same rule, as the other usages do.

Changing this at once would break manifests that use PUBLIC today. A possible path: the webhook warns for any spelling other than lowercase public, saying that names will become case sensitive in a future release. After that window, sanitizeGrantee and the webhook match only the exact lowercase public.

Cluster resource

apiVersion: postgresql.cnpg.io/v1
kind: Database
metadata:
  name: db-example
spec:
  name: example
  owner: app
  cluster:
    name: cluster-example
  schemas:
    - name: app
      owner: app
      permissions:
        usage:
          - name: Public
            type: revoke

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions