Give a proper error message if initdb password file is empty.
authorHeikki Linnakangas <[email protected]>
Fri, 5 Dec 2014 12:27:56 +0000 (14:27 +0200)
committerHeikki Linnakangas <[email protected]>
Fri, 5 Dec 2014 12:30:31 +0000 (14:30 +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 ed082409b7297944fe11e70fa2954b46ac19cfd5..3ca4f054b51e389ea9e11590311d1580726100db 100644 (file)
@@ -1663,8 +1663,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);