reorg / pg_repack

Reorganize tables in PostgreSQL databases with minimal locks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passwords in .pgpass with spaces cause error Unable to set up worker conn #0: missing "="

jschaf opened this issue · comments

I have a pgpass file that contains a password with spaces, like so:

my-host.com:5432:postgres:postgres:alpha bravo charlie

When running pg_repack, I see a warning in the logs that leaks the second word of the password, bravo

INFO: Dry run enabled, not executing repack
NOTICE: Setting up workers.conns
WARNING: Unable to set up worker conn #0: missing "=" after "bravo" in connection info string
INFO: repacking table "table1"
INFO: repacking table "table2"
...

It seems like the command still works, but reporting since pg_repack shouldn't leak partial passwords.

Taking a glance at the code, the problem seems to be that appending the password in setup_workers doesn't quote strings with whitespace at:

appendStringInfo(&buf, "password=%s ", password);

So the conn string parser sees something like:

host=my-host.com password=alpha bravo charlie

The parser attempts to interpret bravo as a key instead of part of the password string.

@jschaf thank you for the report.
This should be fixed by the PR #384. Would you have a chance to check it?

Fixed by the PR #384. Closing the issue.