Skip to content

postgresql::server::default_privileges does not quote role name correctly, leading to faulty SQL query in the "unless" clause #1665

@antaflos

Description

@antaflos

Describe the Bug

The postgresql::server::default_privileges defined type does not quote the role name, leading to a faulty SQL query for the unless clause when the role name contains a hyphen. This makes the ALTER DEFAULT PRIVILEGES grant fail with a Postgres error message like this, when the role name is something like monitoring-role:

Could not evaluate: Error evaluating 'unless' clause, returned pid 891642 exit 1: 'ERROR:  unrecognized key word: "monitoring"
LINE 1: ...amespace AS n ON da.defaclnamespace = n.oid WHERE 'monitori...
                                                             ^
HINT:  ACL key word must be "group" or "user".
'

Expected Behavior

The unless clause should quote the role name in the SQL query and not depend on the name being an SQL-compatible bare identifier. This module takes great care of quoting such role or database names throughout the many SQL commands it constructs, but this seems to have been missed.

I will submit a PR to fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions