1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-18 17:41:14 +03:00

Give a proper error message if initdb password file is empty.

Used to say just "could not read password from file "...": Success", which
isn't very informative.

Mats Erik Andersson. Backpatch to all supported versions.
This commit is contained in:
Heikki Linnakangas 2014-12-05 14:27:56 +02:00
parent 8571ecb24f
commit 2df66f01ab

View File

@ -1598,8 +1598,12 @@ get_set_pwd(void)
} }
if (!fgets(pwdbuf, sizeof(pwdbuf), pwf)) if (!fgets(pwdbuf, sizeof(pwdbuf), pwf))
{ {
fprintf(stderr, _("%s: could not read password from file \"%s\": %s\n"), if (ferror(pwf))
progname, pwfilename, strerror(errno)); fprintf(stderr, _("%s: could not read password from file \"%s\": %s\n"),
progname, pwfilename, strerror(errno));
else
fprintf(stderr, _("%s: password file \"%s\" is empty\n"),
progname, pwfilename);
exit_nicely(); exit_nicely();
} }
fclose(pwf); fclose(pwf);