Skip to content

Commit 7292027

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 2e3cc39 commit 7292027

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
@@ -1292,8 +1292,12 @@ get_set_pwd(void)
12921292
}
12931293
if (!fgets(pwdbuf, sizeof(pwdbuf), pwf))
12941294
{
1295-
fprintf(stderr, _("%s: could not read password from file \"%s\": %s\n"),
1296-
progname, pwfilename, strerror(errno));
1295+
if (ferror(pwf))
1296+
fprintf(stderr, _("%s: could not read password from file \"%s\": %s\n"),
1297+
progname, pwfilename, strerror(errno));
1298+
else
1299+
fprintf(stderr, _("%s: password file \"%s\" is empty\n"),
1300+
progname, pwfilename);
12971301
exit_nicely();
12981302
}
12991303
fclose(pwf);

0 commit comments

Comments
 (0)