From: Heikki Linnakangas Date: Fri, 5 Dec 2014 12:27:56 +0000 (+0200) Subject: Give a proper error message if initdb password file is empty. X-Git-Tag: REL9_2_10~70 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b53d583de96e82d98b1f87c9fbc9f60aa292c9e;p=postgresql 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. --- diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 52fd39da84..b077bf8b8e 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1347,8 +1347,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);