Suggestion : support for environment variable in initdb to set the superuser password - Mailing list pgsql-hackers

From Reda Agaoua
Subject Suggestion : support for environment variable in initdb to set the superuser password
Date
Msg-id CAN+XrdW3PH8kmbUAtfKduycuPDOPQ-KSfVXBgGzx=unJ_O_nGg@mail.gmail.com
Whole thread Raw
Responses Re: Suggestion : support for environment variable in initdb to set the superuser password
List pgsql-hackers
Hi,

The initdb command currently supports prompting for the superuser password using --pwprompt or reading it from a file using --pwfile. I’m wondering if it might also make sense to allow specifying the password via an environment variable.

I do believe it can be useful in a variety of settings, but I'm not sure whether this is secure. Specifically, the documentation advises against using PGPASSWORD for connecting to postgres :

"Use of this environment variable is not recommended for security reasons, as some operating systems allow non-root users to see process environment variables via ps; instead consider using a password file (see Section 32.16)." (32.15. Environment Variables)

In my opinion, the context for using PGPASSWORD (i.e. connecting to an instance) is very different from that of initdb, where the password is only used once during cluster initialization. So I think the security concerns from section 32.16 may not necessarily apply here.

I'm looking to contribute to postgres and I'm pretty sure this would be a good opportunity for getting into the code, but I'm not sure if this idea is relevant and I’d appreciate your thoughts on whether it's worth pursuing.

Best regards,
Reda AGAOUA

pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly
Next
From: wenhui qiu
Date:
Subject: Re: Standardize the definition of the subtype field of AlterDomainStmt