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

Problems with long passwords #507

Closed
pbillen opened this issue Oct 1, 2018 · 9 comments
Closed

Problems with long passwords #507

pbillen opened this issue Oct 1, 2018 · 9 comments
Labels

Comments

@pbillen
Copy link

pbillen commented Oct 1, 2018

I am seeing issues with a long passwords. The following works:

services:
  postgresql:
    image: postgres:10
    ports:
    - 127.0.0.1:5432:5432
    environment:
    - POSTGRES_USER=admin
    - POSTGRES_PASSWORD=4csTU5CuCQk8TtSJWpjCWTy7fAbY

Now I can login with psql:

docker run -it --rm --network=host -e PGPASSWORD=4csTU5CuCQk8TtSJWpjCWTy7fAbY postgres:10 psql -h localhost -U admin

However, when I introduce a longer password, I cannot login anymore:

services:
  postgresql:
    image: postgres:10
    ports:
    - 127.0.0.1:5432:5432
    environment:
    - POSTGRES_USER=admin
    - POSTGRES_PASSWORD=4csTU5CuCQk8TtSJWpjCWTy7fAbY4csTU5CuCQk8TtSJWpjCWTy7fAbY4csTU5CuCQk8TtSJWpjCWTy7fAbY4csTU5CuCQk8TtSJWpjCWTy7fAbY

In psql:

docker run -it --rm --network=host -e PGPASSWORD=4csTU5CuCQk8TtSJWpjCWTy7fAbY4csTU5CuCQk8TtSJWpjCWTy7fAbY4csTU5CuCQk8TtSJWpjCWTy7fAbY4csTU5CuCQk8TtSJWpjCWTy7fAbY postgres:10 psql -h localhost -U admin

FATAL:  password authentication failed for user "admin"

Although I did not verify this, I believe this was introduced in 3f585c5.

@pbillen
Copy link
Author

pbillen commented Oct 1, 2018

This is probably unrelated to the image, but to the behavior of initdb. More info to be found here: https://bugzilla.redhat.com/show_bug.cgi?id=785394.

Before 3f585c5, we did not use initdb but altered the role, so we did not face this limitation.

@pbillen pbillen closed this as completed Oct 1, 2018
@tianon
Copy link
Member

tianon commented Oct 1, 2018

Interesting limitation! IMO, we should probably have the script check the password length and warn if it's over 100, with some comments/links to the limitation in initdb (specifically, a link to https://www.postgresql.org/message-id/flat/E1Rqxp2-0004Qt-PL%40wrigleys.postgresql.org is probably warranted).

@tianon tianon reopened this Oct 1, 2018
@tianon
Copy link
Member

tianon commented Oct 1, 2018

Oh this is even more fun. initdb is fine, and gets the entire 101 character password (I was using 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789a so it was trivial for me to verify I had the right number of characters), and psql works fine if I type that password at the prompt, but if I set it via PGPASSWORD it does not work. So a warning is 100% sufficient here (since it only will affect users of psql).

@pbillen
Copy link
Author

pbillen commented Oct 2, 2018

Even more, if you first initialize the container with a short password, then login with psql, then alter role X with password '... long password ...', then psql with PGPASSWORD works again. Misteries.

I agree, a warning is granted here.

@Remigius2011
Copy link

Remigius2011 commented Nov 6, 2018

Even more, if you first initialize the container with a short password, then login with psql, then alter role X with password '... long password ...', then psql with PGPASSWORD works again. Misteries.

Couldn't this be automated in the container's initialization (e.g. create the role with a random password of length < 100, then execute alter role...) - if not in the Dockerfile, then on first startup?

@tianon
Copy link
Member

tianon commented Nov 6, 2018 via email

@pbillen
Copy link
Author

pbillen commented Nov 6, 2018

This all sounds to me like there's truncation happening somewhere -- I think a warning is appropriate until/if upstream fixes the truncation/limit issues.

I agree. I would be hesitant to introduce features/changes here which aren't backed by upstream components.

@gopackgo90
Copy link

gopackgo90 commented Dec 9, 2023

@tianon
Copy link
Member

tianon commented Dec 11, 2023

Nice, thanks for the pointer! I've opened #1166 to discuss further / adjust our warning 👍

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

No branches or pull requests

5 participants