Enable GSSAPI to build using MSVC. Always build GSSAPI when Kerberos is
authorMagnus Hagander <magnus@hagander.net>
Thu, 12 Jul 2007 14:43:21 +0000 (14:43 +0000)
committerMagnus Hagander <magnus@hagander.net>
Thu, 12 Jul 2007 14:43:21 +0000 (14:43 +0000)
enabled, because the only Kerberos library supported always contains it.

src/backend/libpq/auth.c
src/include/libpq/libpq-be.h
src/interfaces/libpq/fe-auth.c
src/tools/msvc/Solution.pm

index 2b625d08a97bbc44aa9dd80641a50a58d8adcc93..fc77eb3adbfc28620b4eacbc47e6edeb7049ad53 100644 (file)
@@ -308,9 +308,9 @@ pg_krb5_recvauth(Port *port)
 #include <gssapi/gssapi.h>
 #endif
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(WIN32_ONLY_COMPILER)
 /*
- * MIT Kerberos GSSAPI DLL doesn't properly export the symbols
+ * MIT Kerberos GSSAPI DLL doesn't properly export the symbols for MingW
  * that contain the OIDs required. Redefine here, values copied
  * from src/athena/auth/krb5/src/lib/gssapi/generic/gssapi_generic.c
  */
@@ -381,8 +381,8 @@ pg_GSS_recvauth(Port *port)
                 */
                if (!getenv("KRB5_KTNAME"))
                {
-                       kt_path = palloc(PATH_MAX + 13);
-                       snprintf(kt_path, PATH_MAX + 13,
+                       kt_path = palloc(MAXPGPATH + 13);
+                       snprintf(kt_path, MAXPGPATH + 13,
                                        "KRB5_KTNAME=%s", pg_krb_server_keyfile);
                        putenv(kt_path);
                }
index 09103d531f9345d86959bfd3a5be05e99472585a..b337abd94edda85b8153d92629b96bba69a5d6c6 100644 (file)
 #include <gssapi.h>
 #else
 #include <gssapi/gssapi.h>
+#endif /* HAVE_GSSAPI_H */
+/* 
+ * GSSAPI brings in headers that set a lot of things in the global namespace on win32,
+ * that doesn't match the msvc build. It gives a bunch of compiler warnings that we ignore,
+ * but also defines a symbol that simply does not exist. Undefine it again.
+ */
+#ifdef WIN32_ONLY_COMPILER
+#undef HAVE_GETADDRINFO
 #endif
-#endif
+#endif /* ENABLE_GSS */
 
 #include "libpq/hba.h"
 #include "libpq/pqcomm.h"
index a3a6a5cb4b8500f30514a4006557025a5b29d1f9..57a529f52545fa89e58b2c2e609ccea3d55032f6 100644 (file)
@@ -335,9 +335,9 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname, const char *s
 #include <gssapi/gssapi.h>
 #endif
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(WIN32_ONLY_COMPILER)
 /*
- * MIT Kerberos GSSAPI DLL doesn't properly export the symbols
+ * MIT Kerberos GSSAPI DLL doesn't properly export the symbols for MingW
  * that contain the OIDs required. Redefine here, values copied
  * from src/athena/auth/krb5/src/lib/gssapi/generic/gssapi_generic.c
  */
index a9418a545f8c1a459b8fe7e4b6d9b3200b705f78..fa42e9555ae8071fb77ca9e700ea0bc5d252c93e 100644 (file)
@@ -125,6 +125,7 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY
             print O "#define HAVE_KRB5_TICKET_ENC_PART2 1\n";
             print O "#define HAVE_KRB5_FREE_UNPARSED_NAME 1\n";
             print O "#define PG_KRB_SRVNAM \"postgres\"\n";
+            print O "#define ENABLE_GSS\n";
         }
                if (my $port = $self->{options}->{"--with-pgport"})
                {
@@ -332,6 +333,7 @@ sub AddProject
         $proj->AddIncludeDir($self->{options}->{krb5} . '\inc\krb5');
         $proj->AddLibrary($self->{options}->{krb5} . '\lib\i386\krb5_32.lib');
         $proj->AddLibrary($self->{options}->{krb5} . '\lib\i386\comerr32.lib');
+        $proj->AddLibrary($self->{options}->{krb5} . '\lib\i386\gssapi32.lib');
     }
     if ($self->{options}->{xml})
     {