]> granicus.if.org Git - postgresql/commitdiff
Give a proper error message if initdb password file is empty.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 5 Dec 2014 12:27:56 +0000 (14:27 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 5 Dec 2014 12:31:45 +0000 (14:31 +0200)
Used to say just "could not read password from file "...": Success", which
isn't very informative.

Mats Erik Andersson. Backpatch to all supported versions.

src/bin/initdb/initdb.c

index 52fd39da841b1511af51b9ffb33366999e6695cd..b077bf8b8ee3d6560a5e2ea859d3b18181e812ed 100644 (file)
@@ -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);