@@ -44,7 +44,7 @@ docker_create_db_directories() {
4444 chmod 775 /var/run/postgresql || :
4545
4646 # Create the transaction log directory before initdb is run so the directory is owned by the correct user
47- if [ " $POSTGRES_INITDB_XLOGDIR " ]; then
47+ if [ -n " $POSTGRES_INITDB_XLOGDIR " ]; then
4848 mkdir -p " $POSTGRES_INITDB_XLOGDIR "
4949 if [ " $user " = ' 0' ]; then
5050 find " $POSTGRES_INITDB_XLOGDIR " \! -user postgres -exec chown postgres ' {}' +
@@ -74,7 +74,7 @@ docker_init_database_dir() {
7474 echo " postgres:x:$( id -g) :" > " $NSS_WRAPPER_GROUP "
7575 fi
7676
77- if [ " $POSTGRES_INITDB_XLOGDIR " ]; then
77+ if [ -n " $POSTGRES_INITDB_XLOGDIR " ]; then
7878 set -- --xlogdir " $POSTGRES_INITDB_XLOGDIR " " $@ "
7979 fi
8080
@@ -121,6 +121,8 @@ docker_verify_minimum_env() {
121121 This will allow anyone with access to the
122122 Postgres port to access your database without
123123 a password, even if POSTGRES_PASSWORD is set.
124+ See PostgreSQL documentation about "trust":
125+ https://www.postgresql.org/docs/12/auth-trust.html
124126 In Docker's default configuration, this is
125127 effectively any other container on the same
126128 system.
@@ -207,12 +209,14 @@ docker_setup_env() {
207209# append md5 or trust auth to pg_hba.conf based on existence of POSTGRES_DISABLE_PASSWORDS
208210pg_setup_hba_conf () {
209211 local authMethod=' md5'
210- if [ -n " $POSTGRES_DISABLE_PASSWORDS " ]; then
211- authMethod=' trust'
212- fi
213212
214213 {
215214 echo
215+ if [ -n " $POSTGRES_DISABLE_PASSWORDS " ]; then
216+ authMethod=' trust'
217+ echo ' # warning trust is enabled for all connections'
218+ echo ' # see https://www.postgresql.org/docs/12/auth-trust.html'
219+ fi
216220 echo " host all all all $authMethod "
217221 } >> " $PGDATA /pg_hba.conf"
218222}
0 commit comments