1
0
mirror of https://github.com/docker-library/postgres.git synced 2025-07-28 10:42:06 +03:00

Add newline to POSTGRES_PASSWORD file for initdb

https://github.com/docker-library/postgres/issues/1024 converted all
`echo` calls to `printf`, but this change causes the password file
used by `initdb` to be blank rather than contain a single newline.
As a result, `initdb` will fail to start with an empty value with
the error:

```
initdb: error: password file "/dev/fd/63" is empty
```

`POSTGRES_PASSWORD` can be blank if `POSTGRES_HOST_AUTH_METHOD=trust`
is used. This change adds a newline to restore the original behavior.

Closes #1025
This commit is contained in:
Stan Hu
2022-12-22 13:29:17 -08:00
parent 7a852f46d3
commit 41bd7bf3f4
11 changed files with 22 additions and 11 deletions

View File

@ -88,7 +88,8 @@ docker_init_database_dir() {
set -- --waldir "$POSTGRES_INITDB_WALDIR" "$@"
fi
eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s" "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
# --pwfile refuses to handle a properly-empty file (hence the "\n"): https://github.com/docker-library/postgres/issues/1025
eval 'initdb --username="$POSTGRES_USER" --pwfile=<(printf "%s\n" "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
# unset/cleanup "nss_wrapper" bits
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then