summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2011-07-16 19:58:53 +0200
committerMagnus Hagander <magnus@hagander.net>2011-07-16 20:02:34 +0200
commit821c07244ace805445648188d07043a74ea6aad0 (patch)
treee427c5f32865ce16f7abfc2111b62354e66a0caa
parentdea11bd9d5fa5db4e3df08acbcb2357031e5132a (diff)
Fix SSPI login when multiple roundtrips are required
This fixes SSPI login failures showing "The function requested is not supported", often showing up when connecting to localhost. The reason was not properly updating the SSPI handle when multiple roundtrips were required to complete the authentication sequence. Report and analysis by Ahmed Shinwari, patch by Magnus Hagander
-rw-r--r--src/backend/libpq/auth.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index a3651be744f..88d809faff9 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -807,16 +807,22 @@ pg_SSPI_recvauth(Port *port)
gettext_noop("could not accept SSPI security context"), r);
}
+ /*
+ * Overwrite the current context with the one we just received.
+ * If sspictx is NULL it was the first loop and we need to allocate
+ * a buffer for it. On subsequent runs, we can just overwrite the
+ * buffer contents since the size does not change.
+ */
if (sspictx == NULL)
{
sspictx = malloc(sizeof(CtxtHandle));
if (sspictx == NULL)
ereport(ERROR,
(errmsg("out of memory")));
-
- memcpy(sspictx, &newctx, sizeof(CtxtHandle));
}
+ memcpy(sspictx, &newctx, sizeof(CtxtHandle));
+
if (r == SEC_I_CONTINUE_NEEDED)
elog(DEBUG4, "SSPI continue needed");