Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresql_privs: schema name is not quoted properly #381

Closed
betanummeric opened this issue Dec 6, 2022 · 1 comment · Fixed by #382
Closed

postgresql_privs: schema name is not quoted properly #381

betanummeric opened this issue Dec 6, 2022 · 1 comment · Fixed by #382

Comments

@betanummeric
Copy link
Member

bug in postgresql_privs

When trying to grant privileges on something in a schema, the schema is not quoted properly, which results in an error.

When the schema argument contains no special quoting, the postgres raises an syntax error.
When quotes are included in the schema argument, the module aborts because the check if the schema exists fails. (Error: Schema ""c.d"" does not exist.)

This is tested with community.postgresql 2.3.1 and postgresql 10-15.

steps to reproduce

tasks:
  - name: create db
    community.postgresql.postgresql_db:
      name: "a.b"
      login_unix_socket: /tmp
  - name: create schema
    community.postgresql.postgresql_schema:
      database: "a.b"
      name: '"c.d"'
      login_unix_socket: /tmp
  - name: create table
    community.postgresql.postgresql_table:
      db: "a.b"
      name: '"c.d"."e.f"'
      columns:  []
      login_unix_socket: /tmp
  - name: grant something on the database
    community.postgresql.postgresql_privs:
      login_unix_socket: /tmp
      database: "a.b"
      privs: CREATE
      roles: PUBLIC
      type: database
  - name: grant privileges on a schema
    community.postgresql.postgresql_privs:
      login_unix_socket: /tmp
      database: "a.b"
      privs: CREATE
      roles: PUBLIC
      type: schema
      objs: 'c.d'
  - name: grant privileges on a table in a schema
    community.postgresql.postgresql_privs:
      login_unix_socket: /tmp
      database: "a.b"
      privs: SELECT
      roles: PUBLIC
      type: table
      objs: ALL_IN_SCHEMA
      schema: "{{ item }}"
    loop:
      - 'c.d'
      - '"c.d"'
    ignore_errors: true # it fails
@Andersson007
Copy link
Collaborator

@betanummeric thanks for reporting the issue! Any help with fixing/investigating the case is welcome

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 a pull request may close this issue.

2 participants