]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Give nicer error message when connecting to a v10 server requiring SCRAM.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 5 May 2017 08:24:02 +0000 (11:24 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 5 May 2017 08:24:32 +0000 (11:24 +0300)
This is just to give the user a hint that they need to upgrade, if they try
to connect to a v10 server that uses SCRAM authentication, with an older
client.

Commit to all stable branches, but not master.

Discussion: https://www.postgresql.org/message-id/bbf45d92-3896-eeb7-7399-2111d517261b@pivotal.io

src/include/libpq/pqcomm.h
src/interfaces/libpq/fe-auth.c

index 4299458c2de51a87478510cdc3f3f077fb73e1dc..8d3f3401fe207c07a895859f58d628751a83192f 100644 (file)
@@ -172,6 +172,8 @@ extern bool Db_user_namespace;
 #define AUTH_REQ_GSS           7       /* GSSAPI without wrap() */
 #define AUTH_REQ_GSS_CONT      8       /* Continue GSS exchanges */
 #define AUTH_REQ_SSPI          9       /* SSPI negotiate without wrap() */
+#define AUTH_REQ_SASL     10   /* SASL authentication. Not supported before
+                                                                * libpq version 10. */
 
 typedef uint32 AuthRequest;
 
index c88da7ffcc218422b24d58d76129c02a96b6b43c..683cdcc302b838bb404f50841859c322fb3fb90c 100644 (file)
@@ -961,6 +961,19 @@ pg_fe_sendauth(AuthRequest areq, PGconn *conn)
                                return STATUS_ERROR;
                        break;
 
+                       /*
+                        * SASL authentication was introduced in version 10. Older
+                        * versions recognize the request only to give a nicer error
+                        * message. We call it "SCRAM authentication" in the error, rather
+                        * than SASL, because SCRAM is more familiar to users, and it's
+                        * the only SASL authentication mechanism that has been
+                        * implemented as of this writing, anyway.
+                        */
+               case AUTH_REQ_SASL:
+                       printfPQExpBuffer(&conn->errorMessage,
+                                                         libpq_gettext("SCRAM authentication requires libpq version 10 or above\n"));
+                       return STATUS_ERROR;
+
                default:
                        printfPQExpBuffer(&conn->errorMessage,
                        libpq_gettext("authentication method %u not supported\n"), areq);