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

Multiple-line pgpass file doesn't work #54

Open
pkaeding opened this issue Aug 29, 2018 · 3 comments
Open

Multiple-line pgpass file doesn't work #54

pkaeding opened this issue Aug 29, 2018 · 3 comments

Comments

@pkaeding
Copy link

If I have a .pgpass file with multiple lines, it seems only the first line is used.

I think this is due to the [0] in

pgpass = Hash[%i[hostname port database user password].zip(File.readlines(config[:pgpass])[0].strip.split(':'))]
(but I may be wrong there).

Given the postgres docs on the pgpass file format, I expected this to work the same way.

@pkaeding
Copy link
Author

pkaeding commented Aug 29, 2018

Oh, I just noticed that https://github.com/sensu-plugins/sensu-plugins-postgres#pgpass-file does document this issue, so I guess it is my fault for missing that initially. I suspect that this module is not really supporting the pgpass format in general, though, as wildcards in fields other than the database (eg the host or port) would be misinterpreted?

I'm also curious why this module needs to parse the pgpass file itself-- won't the pg gem use that file if it finds it? https://stackoverflow.com/a/18282613/4257 says it will, but I have not verified that.

@majormoses
Copy link
Member

@pkaeding honestly I am not too sure as I dont really use much postgres I can try to take a closer look, @phumpal do you have any insight before I try diving in? You touched this recently in #104 so figure you might have more context.

@phumpal
Copy link
Contributor

phumpal commented Oct 5, 2019

@majormoses I don't see any mention of libpq in either the original issue (#9) or the PR (#36) which added pgpass support.

I'm also curious why this module needs to parse the pgpass file itself.

As am I however I suspect this is a shortcoming of the pg gem and not libpq or sensu-plugins-postgres intentionally.

I suspect I should review the C library.

this module is not really supporting the pgpass format

The module supports a single line pgpass file w/multiple leading comments.

wildcards in fields other than the database (eg the host or port) would be misinterpreted?

According to https://www.postgresql.org/docs/11/libpq-pgpass.html all fields except password can be wildcards.

Coming full circle I'm not 100% certain what the issue is.

  • are you asking to add support for multiple-line pgpass files?
  • if so do you have a use case for multi-line support?
  • should we improve tests for pgpass files support?
  • can we remove the Pgpass module and rely on libpq somehow?

I'm happy to take this on but I'm not sure how to scope the work.

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

No branches or pull requests

3 participants