Fix the MIT / Heimdal check for good
define HAVE_GSSMIT if <gssapi/{gssapi.h,gssapi_generic.h,gssapi_krb5.h}> are
available
otherwise define HAVE_GSSHEIMDAL if <gssapi.h> is available

Only define GSS_C_NT_HOSTBASED_SERVICE to gss_nt_service_name if
GSS_C_NT_HOSTBASED_SERVICE isn't declared by the gssapi headers. Should avoid
breakage if we wrongly recognize Heimdal as MIT.
Index: configure.ac
===================================================================
RCS file: /cvsroot/curl/curl/configure.ac,v
retrieving revision 1.282
diff -u -p -r1.282 configure.ac
--- configure.ac	31 Mar 2008 12:09:43 -0000	1.282
+++ configure.ac	4 Apr 2008 11:35:06 -0000
@@ -983,15 +983,14 @@ if test x"$want_gss" = xyes; then
       gnu_gss=yes
     ],
     [
-      dnl not found, check MIT
-      AC_CHECK_HEADER(gssapi/gssapi.h,
-        [
-          dnl found in the given dirs
-          AC_DEFINE(HAVE_GSSMIT, 1, [if you have the MIT gssapi libraries])
-        ],
-        [
-          dnl not found, check for Heimdal
-          AC_CHECK_HEADER(gssapi.h,
+      dnl not found, check Heimdal or MIT
+      AC_CHECK_HEADERS(
+        [gssapi/gssapi.h gssapi/gssapi_generic.h gssapi/gssapi_krb5.h],
+        [],
+        [not_mit=1])
+      if test "x$not_mit" = "x1"; then
+        dnl MIT not found, check for Heimdal
+        AC_CHECK_HEADER(gssapi.h,
             [
               dnl found
               AC_DEFINE(HAVE_GSSHEIMDAL, 1, [if you have the Heimdal gssapi libraries])
@@ -1002,13 +1001,36 @@ if test x"$want_gss" = xyes; then
               AC_MSG_WARN(disabling GSSAPI since no header files was found)
             ]
           )
-        ]
-      )
+      else
+        dnl MIT found
+        AC_DEFINE(HAVE_GSSMIT, 1, [if you have the MIT gssapi libraries])
+        dnl check if we have a really old MIT kerberos (<= 1.2)
+        AC_MSG_CHECKING([if gssapi headers declare GSS_C_NT_HOSTBASED_SERVICE])
+        AC_TRY_COMPILE([
+#include <gssapi/gssapi.h>
+#include <gssapi/gssapi_generic.h>
+#include <gssapi/gssapi_krb5.h>
+          ],[
+            gss_import_name(
+                            (OM_uint32 *)0,
+                            (gss_buffer_t)0,
+                            GSS_C_NT_HOSTBASED_SERVICE,
+                            (gss_name_t *)0);
+          ],[
+            AC_MSG_RESULT([yes])
+          ],[
+            AC_MSG_RESULT([no])
+            AC_DEFINE(HAVE_OLD_GSSMIT, 1, [if you have an old MIT gssapi library, lacking GSS_C_NT_HOSTBASED_SERVICE])
+          ]
+         )
+
+      fi
     ]
   )
 else
   AC_MSG_RESULT(no)
 fi
+
 if test x"$want_gss" = xyes; then
   AC_DEFINE(HAVE_GSSAPI, 1, [if you have the gssapi libraries])
 
Index: lib/http_negotiate.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/http_negotiate.c,v
retrieving revision 1.25
diff -u -p -r1.25 http_negotiate.c
--- lib/http_negotiate.c	1 Mar 2008 22:32:03 -0000	1.25
+++ lib/http_negotiate.c	4 Apr 2008 11:35:06 -0000
@@ -23,7 +23,7 @@
 #include "setup.h"
 
 #ifdef HAVE_GSSAPI
-#ifdef HAVE_GSSMIT
+#ifdef HAVE_OLD_GSSMIT
 #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
 #endif
 
Index: lib/krb5.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/krb5.c,v
retrieving revision 1.4
diff -u -p -r1.4 krb5.c
--- lib/krb5.c	8 Aug 2007 10:37:07 -0000	1.4
+++ lib/krb5.c	4 Apr 2008 11:35:06 -0000
@@ -36,7 +36,7 @@
 #ifndef CURL_DISABLE_FTP
 #ifdef HAVE_GSSAPI
 
-#ifdef HAVE_GSSMIT
+#ifdef HAVE_OLD_GSSMIT
 #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
 #endif
 


