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