puppetlabs / puppetlabs/puppetlabs-postgresql
Wrong privilege checks in postgresql::server::default_privileges (object_type => 'TABLES') for ALL and TRIGGER
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 232
- Forks
- 610
- Avg merge
- 5d 23h
- Merged PRs (30d)
- 4
Description
Describe the Bug
When using postgresql::server::default_privileges with object_type => 'TABLES' and privilege => 'ALL', ALL privileges are set in PostgreSQL, but the unless check failed because of an additional 'm' (MAINTAIN) privilege added by PostgreSQL 17.
A similar issue exists when granting TRIGGER. Here the $_check_privilege = 'd' matches for delete instead.
Expected Behavior
Puppet Agent recognizes, that "ALL" privileges are granted and does not apply the resource on every run.
Steps to Reproduce
What I did (some steps might be not necessary):
# create db
postgresql::server::database { 'testdb': }
# create roles
postgresql::server::database_grant { 'testrole_owner@testdb':
privilege => 'ALL',
db => 'testdb',
role => 'testrole_owner',
}
postgresql::server::database_grant { 'testrole_group@testdb':
privilege => 'ALL',
db => 'testdb',
role => 'testrole_group',
}
# create schema
postgresql::server::schema { 'testschema':
db => 'testdb',
owner => 'testrole_owner',
}
postgresql::server::default_privileges { 'testrole_group@testdb/testschema/*':
target_role => 'testrole_owner',
role => 'testrole_group',
db => 'testdb',
object_type => 'TABLES',
privilege => 'ALL',
schema => 'testschema',
require => Postgresql::Server::Database_grant['testrole_owner@testdb'],
}
Environment
- Platform: Debian Trixie
- PostgreSQL version: 17.10
- Module version: 10.6.1
Additional Context
- This needs to be
/^ALL$/: { $_check_privilege = 'arwdDxtm' }with PostgreSQL 17 (and above).
https://github.com/puppetlabs/puppetlabs-postgresql/blob/1bbeeb0229e20ff33f847d6894abc3ab380d148f/manifests/server/default_privileges.pp#L108 - While looking at it, this is also wrong, it needs to be
't'. The letter'd'meansDELETE.
https://github.com/puppetlabs/puppetlabs-postgresql/blob/1bbeeb0229e20ff33f847d6894abc3ab380d148f/manifests/server/default_privileges.pp#L113
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at manifests/server/default_privileges.pp around lines 108 and 113, where the issue identifies the ALL and TRIGGER privilege checks. Compare those checks with the PostgreSQL privilege letters described in the report, then inspect any corresponding tests. Done means Puppet recognizes these grants correctly and does not reapply the resource on every run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, ruby
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100