]> 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:54 +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 874775577a4ff992970af19190a8e35024b0f07c..1366174a5ec6e9f34ff3236f128694ea6b787119 100644 (file)
@@ -1656,8 +1656,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);