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

Entering a blank password causes infinite loop #299

Closed
egashira-yusuke opened this issue Jan 7, 2022 · 2 comments
Closed

Entering a blank password causes infinite loop #299

egashira-yusuke opened this issue Jan 7, 2022 · 2 comments
Assignees

Comments

@egashira-yusuke
Copy link

pg_repack hangs when entering an empty or blank string at the password prompt of pg_repack.
It does not return until interrupt with Ctrl+C.
Also, during this, pg_repack is continuously trying to connect to the database.
This causes outputting a large amount of connection log if log_connections=on was specified in the database.
I found this problem in PostgreSQL 14.1 and pg_repack 1.4.7.

[Reproduce procedure]

  1. Create a password authenticated user on the database.
  2. Run pg_repack specifing 1.'s user. (Do not specify -w option)
  3. When the password prompt appears, press Enter without entering anything or with entering only blank.

According to my research, this problem seems to start from #184.
In pgut_connect()'s connection loop, if PQconnectionNeedsPassword(conn) is true,
the password prompt is appeared by prompt_for_password() and it requires input of password.
prompt_for_password() remembers the password.
In pgut_connect(), the password obtained from prompt_for_password() is appended to the connection string as "password=%s" format.
Then, the connection string will end with "password=" because the entered password was empty string.
On the other hand, PostgreSQL Server seems to request the password again if the connection string ends with "password=".
Therefore, PQconnectionNeedsPassword(conn) is still true during reconnect loop of pgut_connect(), and it causes infinite loop.

@MichaelDBA
Copy link
Collaborator

MichaelDBA commented Mar 15, 2023

Validated the hanging condition using v1.4.8 and PG version 14...

za-arthur added a commit that referenced this issue May 31, 2023
This fixes infinite loop in case of an empty password.
Issue #299.
andreasscherbaum pushed a commit that referenced this issue Jun 14, 2023
This fixes infinite loop in case of an empty password.
Issue #299.
@andreasscherbaum
Copy link
Collaborator

Fixed in #354

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants