Skip to content

Commit 538724f

Browse files
Extend the private key stat checking error handling
If the stat operation on the private key failed, the code assumed it was due to an ENOENT, which may or may not be true. Extend the check by printing a different error message on non-ENOENT errors for easier debugging. Per suggestion by Tom Lane due to an issue with the fairywren animal in the buildfarm. Discussion: https://postgr.es/m/[email protected]
1 parent b637101 commit 538724f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/interfaces/libpq/fe-secure-openssl.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,9 +1235,14 @@ initialize_SSL(PGconn *conn)
12351235

12361236
if (stat(fnbuf, &buf) != 0)
12371237
{
1238-
appendPQExpBuffer(&conn->errorMessage,
1239-
libpq_gettext("certificate present, but not private key file \"%s\"\n"),
1240-
fnbuf);
1238+
if (errno == ENOENT)
1239+
appendPQExpBuffer(&conn->errorMessage,
1240+
libpq_gettext("certificate present, but not private key file \"%s\"\n"),
1241+
fnbuf);
1242+
else
1243+
appendPQExpBuffer(&conn->errorMessage,
1244+
libpq_gettext("could not stat private key file \"%s\": %m\n"),
1245+
fnbuf);
12411246
return -1;
12421247
}
12431248
#ifndef WIN32

0 commit comments

Comments
 (0)