puppetlabs / puppetlabs/puppetlabs-postgresql

unless check in postgresql::server::instance::passwd does not respect custom database name (missing --dbname option)

Open Beginner friendly
#1,639 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
232
Forks
610
Avg merge
5d 23h
Merged PRs (30d)
4

Description

Describe the Bug

The unless command in postgresql::server::instance::passwd does not include the --dbname option when the database name differs from the user name. This can cause the check to run against the wrong database, potentially resulting in incorrect behavior when setting the postgres password.

Expected Behavior

The unless command should always connect to the intended database by including the --dbname option when necessary, just like the main command. This ensures the password check is performed against the correct database.

Steps to Reproduce

  1. Set up a PostgreSQL instance where the database name is different from the user name.
  2. Apply the Puppet manifest to set the postgres password.
  3. Observe that the unless check may not work as intended, causing the password to be reset unnecessarily or not at all.

Environment

  • Version: puppetlabs-postgresql v10.5.0
  • Platform: -

Additional Context

A patch is proposed to add ${_dboption} to the unless command, ensuring consistent database selection:

unless => "${shell_escape($psql_path)}${_dboption} -h localhost -p ${port} -c 'select 1' > /dev/null",

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Find the declaration for postgresql::server::instance::passwd and compare the main command with its unless check, focusing on how the custom database name is represented. Reproduce the case where the database name differs from the user name, then verify that the generated unless command selects the intended database and no longer resets the password unnecessarily.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.