#
# Copyright (c) 1994, Regents of the University of California
#
-# $PostgreSQL: pgsql/src/backend/Makefile,v 1.122 2007/02/09 15:55:57 petere Exp $
+# $PostgreSQL: pgsql/src/backend/Makefile,v 1.123 2007/07/24 09:00:27 mha Exp $
#
#-------------------------------------------------------------------------
endif # cygwin
ifeq ($(PORTNAME), win32)
+LIBS += -lsecur32
postgres: $(OBJS) postgres.def libpostgres.a $(WIN32RES)
$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.154 2007/07/23 10:16:53 mha Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.155 2007/07/24 09:00:27 mha Exp $
*
*-------------------------------------------------------------------------
*/
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, r, 0, sysmsg, sizeof(sysmsg), NULL) == 0)
ereport(severity,
(errmsg_internal("%s", errmsg),
- errdetail("sspi error %x", r)));
+ errdetail("sspi error %x", (unsigned int)r)));
else
ereport(severity,
(errmsg_internal("%s", errmsg),
- errdetail("%s (%x)", sysmsg, r)));
+ errdetail("%s (%x)", sysmsg, (unsigned int)r)));
}
+typedef SECURITY_STATUS
+(WINAPI * QUERY_SECURITY_CONTEXT_TOKEN_FN)(
+ PCtxtHandle, void **);
static int
pg_SSPI_recvauth(Port *port)
DWORD accountnamesize = sizeof(accountname);
DWORD domainnamesize = sizeof(domainname);
SID_NAME_USE accountnameuse;
+ HMODULE secur32;
+ QUERY_SECURITY_CONTEXT_TOKEN_FN _QuerySecurityContextToken;
/*
*
* Get the name of the user that authenticated, and compare it to the
* pg username that was specified for the connection.
+ *
+ * MingW is missing the export for QuerySecurityContextToken in
+ * the secur32 library, so we have to load it dynamically.
*/
- r = QuerySecurityContextToken(sspictx, &token);
+ secur32 = LoadLibrary("SECUR32.DLL");
+ if (secur32 == NULL)
+ ereport(ERROR,
+ (errmsg_internal("could not load secur32.dll: %d",
+ (int)GetLastError())));
+
+ _QuerySecurityContextToken = (QUERY_SECURITY_CONTEXT_TOKEN_FN)
+ GetProcAddress(secur32, "QuerySecurityContextToken");
+ if (_QuerySecurityContextToken == NULL)
+ {
+ FreeLibrary(secur32);
+ ereport(ERROR,
+ (errmsg_internal("could not locate QuerySecurityContextToken in secur32.dll: %d",
+ (int)GetLastError())));
+ }
+
+ r = (_QuerySecurityContextToken)(sspictx, &token);
if (r != SEC_E_OK)
+ {
+ FreeLibrary(secur32);
pg_SSPI_error(ERROR,
gettext_noop("could not get security token from context"), r);
+ }
+
+ FreeLibrary(secur32);
/*
* No longer need the security context, everything from here on uses the
-/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.74 2007/04/06 05:36:51 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.75 2007/07/24 09:00:27 mha Exp $ */
#if defined(_MSC_VER) || defined(__BORLANDC__)
#define WIN32_ONLY_COMPILER
#endif
+/*
+ * Always build with SSPI support. Keep it as a #define in case
+ * we want a switch to disable it sometime in the future.
+ */
+#define ENABLE_SSPI 1
+
+
/* undefine and redefine after #include */
#undef mkdir
# Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
-# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.155 2007/07/10 13:14:21 mha Exp $
+# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.156 2007/07/24 09:00:27 mha Exp $
#
#-------------------------------------------------------------------------
SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi32 -lssl -lsocket -lnsl -lresolv -lintl $(PTHREAD_LIBS), $(LIBS)) $(LDAP_LIBS_FE)
endif
ifeq ($(PORTNAME), win32)
-SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
+SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
endif
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.130 2007/07/23 17:52:06 mha Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.131 2007/07/24 09:00:27 mha Exp $
*
*-------------------------------------------------------------------------
*/
{
char sysmsg[256];
- if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, r, 0, sysmsg, sizeof(sysmsg), NULL) == 0)
- printfPQExpBuffer(&conn->errorMessage, "%s: sspi error %x", mprefix, r);
+ if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, r, 0,
+ sysmsg, sizeof(sysmsg), NULL) == 0)
+ printfPQExpBuffer(&conn->errorMessage, "%s: sspi error %x",
+ mprefix, (unsigned int)r);
else
- printfPQExpBuffer(&conn->errorMessage, "%s: %s (%x)", mprefix, sysmsg, r);
+ printfPQExpBuffer(&conn->errorMessage, "%s: %s (%x)",
+ mprefix, sysmsg, (unsigned int)r);
}
/*
#
# Package that encapsulates a Visual C++ solution file generation
#
-# $PostgreSQL: pgsql/src/tools/msvc/Solution.pm,v 1.30 2007/07/23 10:16:54 mha Exp $
+# $PostgreSQL: pgsql/src/tools/msvc/Solution.pm,v 1.31 2007/07/24 09:00:27 mha Exp $
#
use Carp;
use strict;
print O "#define HAVE_KRB5_FREE_UNPARSED_NAME 1\n";
print O "#define ENABLE_GSS 1\n";
}
- print O "#define ENABLE_SSPI 1\n";
if (my $port = $self->{options}->{"--with-pgport"})
{
print O "#undef DEF_PGPORT\n";