diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-12-05 14:27:56 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-12-05 14:31:51 +0200 |
commit | 2df66f01abe8b18e7e194989132dd263b5881b04 (patch) | |
tree | c54f148f52f67e6385f7ef76b0d306c375c7c047 | |
parent | 8571ecb24f57a3aefc412eaf775423f9e456e47f (diff) | |
download | postgresql-2df66f01abe8b18e7e194989132dd263b5881b04.tar.gz postgresql-2df66f01abe8b18e7e194989132dd263b5881b04.zip |
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.
-rw-r--r-- | src/bin/initdb/initdb.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 51e3035802a..335cbead89a 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1598,8 +1598,12 @@ get_set_pwd(void) } if (!fgets(pwdbuf, sizeof(pwdbuf), pwf)) { - fprintf(stderr, _("%s: could not read password from file \"%s\": %s\n"), - progname, pwfilename, strerror(errno)); + if (ferror(pwf)) + 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(); } fclose(pwf); |