Give a proper error message if initdb password file is empty.
authorHeikki Linnakangas
Fri, 5 Dec 2014 12:27:56 +0000 (14:27 +0200)
committerHeikki Linnakangas
Fri, 5 Dec 2014 12:31:51 +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 51e3035802a1aa1364dbbec5b5559be31488c61c..335cbead89affd6d63a2d630a345b00db05dd269 100644 (file)
@@ -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);