Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ea1a27

Browse files
committed
Use GSSAPI library for SSPI auth, when native SSPI is not available
This allows non-Windows clients to connect to a Windows server with SSPI authentication. Christian Ullrich, largely modified by me
1 parent 7f242d8 commit 4ea1a27

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/interfaces/libpq/fe-auth.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,10 @@ pg_fe_sendauth(AuthRequest areq, PGconn *conn)
831831

832832
#if defined(ENABLE_GSS) || defined(ENABLE_SSPI)
833833
case AUTH_REQ_GSS:
834+
#if !defined(ENABLE_SSPI)
835+
/* no native SSPI, so use GSSAPI library for it */
836+
case AUTH_REQ_SSPI:
837+
#endif
834838
{
835839
int r;
836840

@@ -888,13 +892,14 @@ pg_fe_sendauth(AuthRequest areq, PGconn *conn)
888892
pgunlock_thread();
889893
}
890894
break;
891-
#else
895+
#else /* defined(ENABLE_GSS) || defined(ENABLE_SSPI) */
896+
/* No GSSAPI *or* SSPI support */
892897
case AUTH_REQ_GSS:
893898
case AUTH_REQ_GSS_CONT:
894899
printfPQExpBuffer(&conn->errorMessage,
895900
libpq_gettext("GSSAPI authentication not supported\n"));
896901
return STATUS_ERROR;
897-
#endif
902+
#endif /* defined(ENABLE_GSS) || defined(ENABLE_SSPI) */
898903

899904
#ifdef ENABLE_SSPI
900905
case AUTH_REQ_SSPI:
@@ -914,11 +919,19 @@ pg_fe_sendauth(AuthRequest areq, PGconn *conn)
914919
pgunlock_thread();
915920
break;
916921
#else
922+
/*
923+
* No SSPI support. However, if we have GSSAPI but not SSPI
924+
* support, AUTH_REQ_SSPI will have been handled in the codepath
925+
* for AUTH_REQ_GSSAPI above, so don't duplicate the case label
926+
* in that case.
927+
*/
928+
#if !defined(ENABLE_GSS)
917929
case AUTH_REQ_SSPI:
918930
printfPQExpBuffer(&conn->errorMessage,
919931
libpq_gettext("SSPI authentication not supported\n"));
920932
return STATUS_ERROR;
921-
#endif
933+
#endif /* !define(ENABLE_GSSAPI) */
934+
#endif /* ENABLE_SSPI */
922935

923936

924937
case AUTH_REQ_CRYPT:

0 commit comments

Comments
 (0)