summaryrefslogtreecommitdiff
path: root/mail/imap-uw/patches/patch-al
blob: dfa397ab5c8181d05a36b0060704ded7e25c51f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
$NetBSD: patch-al,v 1.5 2004/05/13 18:14:34 adam Exp $

--- src/c-client/auth_gss.c.orig	2004-03-15 19:59:22.000000000 +0000
+++ src/c-client/auth_gss.c
@@ -18,6 +18,16 @@
  * CPYRIGHT, included with this Distribution.
  */
 
+#ifdef __NetBSD__
+/* This is really Heimdal specific, but . . . */
+#include <gssapi/gssapi.h>
+#include <krb5/krb5.h>
+
+#define gss_nt_service_name	GSS_C_NT_HOSTBASED_SERVICE
+#else
+#include <gssapi/gssapi_generic.h>
+#include <gssapi/gssapi_krb5.h>
+#endif
 
 long auth_gssapi_valid (void);
 long auth_gssapi_client (authchallenge_t challenger,authrespond_t responder,
@@ -56,15 +66,32 @@ long auth_gssapi_valid (void)
   OM_uint32 smn;
   gss_buffer_desc buf;
   gss_name_t name;
+  krb5_context ctx;
+  krb5_keytab kt;
+  krb5_kt_cursor csr;
+
+				/* make a context */
+  if (krb5_init_context (&ctx))
+   return NIL;
 				/* make service name */
   sprintf (tmp,"%s@%s",(char *) mail_parameters (NIL,GET_SERVICENAME,NIL),
 	   mylocalhost ());
   buf.length = strlen (buf.value = tmp);
 				/* see if can build a name */
   if (gss_import_name (&smn,&buf,GSS_C_NT_HOSTBASED_SERVICE,&name) !=
-      GSS_S_COMPLETE) return NIL;
-				/* remove server method if no keytab */
-  if (!kerberos_server_valid ()) auth_gss.server = NIL;
+      GSS_S_COMPLETE) {
+    krb5_free_context (ctx);	/* finished with context */
+    return NIL;
+  }
+
+				/* get default keytab */
+  if (!krb5_kt_default (ctx,&kt)) {
+				/* can do server if have good keytab */
+    if (!krb5_kt_start_seq_get (ctx,kt,&csr))
+	auth_gss.server = auth_gssapi_server;
+    krb5_kt_close (ctx,kt);	/* finished with keytab */
+  }
+  krb5_free_context (ctx);	/* finished with context */
   gss_release_name (&smn,&name);/* finished with name */
   return LONGT;
 }