Skip to content

Commit d67be55

Browse files
committed
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.
1 parent e655062 commit d67be55

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/bin/initdb/initdb.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,8 +1430,12 @@ get_set_pwd(void)
14301430
}
14311431
if (!fgets(pwdbuf, sizeof(pwdbuf), pwf))
14321432
{
1433-
fprintf(stderr, _("%s: could not read password from file \"%s\": %s\n"),
1434-
progname, pwfilename, strerror(errno));
1433+
if (ferror(pwf))
1434+
fprintf(stderr, _("%s: could not read password from file \"%s\": %s\n"),
1435+
progname, pwfilename, strerror(errno));
1436+
else
1437+
fprintf(stderr, _("%s: password file \"%s\" is empty\n"),
1438+
progname, pwfilename);
14351439
exit_nicely();
14361440
}
14371441
fclose(pwf);

0 commit comments

Comments
 (0)