Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/auth/mech-gssapi.c @ 3695:4f8598b0ca62 HEAD
Use a bit larger initial pool sizes
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 28 Oct 2005 15:03:07 +0300 |
parents | 28cca6317829 |
children | 395bc6e93222 |
rev | line source |
---|---|
3683
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
1 /* |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 * GSSAPI Module |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 * |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 * Copyright (c) 2005 Jelmer Vernooij <jelmer@samba.org> |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 * |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 * Related standards: |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 * - draft-ietf-sasl-gssapi-03 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 * - RFC2222 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 * |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 * Some parts inspired by an older patch from Colin Walters |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 * |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 * it under the terms of the GNU Lesser General Public License as published |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 * by the Free Software Foundation; either version 2 of the License, or |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 * (at your option) any later version. |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 */ |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 #include "common.h" |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 #include "mech.h" |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 #include "passdb.h" |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 #include "str.h" |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 #include "str-sanitize.h" |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 #include "buffer.h" |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 #include "hex-binary.h" |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
25 #include "safe-memset.h" |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
26 #include "hostpid.h" |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
27 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 #ifdef HAVE_GSSAPI |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 #include <gssapi/gssapi.h> |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 /* Non-zero flags defined in RFC 2222 */ |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 enum sasl_gssapi_qop { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 SASL_GSSAPI_QOP_UNSPECIFIED = 0x00, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
35 SASL_GSSAPI_QOP_AUTH_ONLY = 0x01, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 SASL_GSSAPI_QOP_AUTH_INT = 0x02, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 SASL_GSSAPI_QOP_AUTH_CONF = 0x04 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 }; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 struct gssapi_auth_request { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 struct auth_request auth_request; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
42 gss_ctx_id_t gss_ctx; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
43 gss_cred_id_t service_cred; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 enum { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
46 GSS_STATE_SEC_CONTEXT, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 GSS_STATE_WRAP, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
48 GSS_STATE_UNWRAP |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
49 } sasl_gssapi_state; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
50 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
51 gss_name_t authn_name; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
52 gss_name_t authz_name; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
53 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
54 pool_t pool; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
55 }; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
57 static void auth_request_log_gss_error(struct auth_request *request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
58 OM_uint32 status_value, int status_type, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
59 const char *description) |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
60 { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
61 OM_uint32 message_context = 0; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
62 OM_uint32 major_status, minor_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
63 gss_buffer_desc status_string; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
64 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
65 do { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
66 major_status = gss_display_status(&minor_status, status_value, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
67 status_type, GSS_C_NO_OID, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
68 &message_context, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 &status_string); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
71 auth_request_log_error(request, "gssapi", |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
72 "While %s: %s", description, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
73 str_sanitize(status_string.value, (size_t)-1)); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
74 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
75 major_status = gss_release_buffer(&minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
76 &status_string); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
77 } while (message_context != 0); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
78 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
79 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
80 static struct auth_request *mech_gssapi_auth_new(void) |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
81 { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
82 struct gssapi_auth_request *request; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
83 pool_t pool; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
84 |
3695
4f8598b0ca62
Use a bit larger initial pool sizes
Timo Sirainen <tss@iki.fi>
parents:
3683
diff
changeset
|
85 pool = pool_alloconly_create("gssapi_auth_request", 1024); |
3683
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
86 request = p_new(pool, struct gssapi_auth_request, 1); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
87 request->pool = pool; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
88 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
89 request->gss_ctx = GSS_C_NO_CONTEXT; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
90 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
91 request->auth_request.pool = pool; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
92 return &request->auth_request; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
93 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
94 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
95 static OM_uint32 obtain_service_credentials(struct auth_request *request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
96 gss_cred_id_t *ret) |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
97 { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
98 OM_uint32 major_status, minor_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
99 string_t *principal_name; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
100 gss_buffer_desc inbuf; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
101 gss_name_t gss_principal; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
102 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
103 principal_name = t_str_new(128); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
104 str_append(principal_name, t_str_lcase(request->service)); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
105 str_append_c(principal_name, '@'); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
106 str_append(principal_name, my_hostname); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
107 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
108 auth_request_log_info(request, "gssapi", |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
109 "Obtaining credentials for %s", str_c(principal_name)); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
110 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
111 inbuf.length = str_len(principal_name); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
112 inbuf.value = str_c_modifyable(principal_name); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
113 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
114 major_status = gss_import_name(&minor_status, &inbuf, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
115 GSS_C_NT_HOSTBASED_SERVICE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
116 &gss_principal); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
117 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
118 str_free(principal_name); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
119 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
120 if (GSS_ERROR(major_status)) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
121 auth_request_log_gss_error(request, major_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
122 GSS_C_GSS_CODE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
123 "importing principal name"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
124 return major_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
125 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
126 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
127 major_status = gss_acquire_cred(&minor_status, gss_principal, 0, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
128 GSS_C_NULL_OID_SET, GSS_C_ACCEPT, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
129 ret, NULL, NULL); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
130 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
131 if (GSS_ERROR(major_status)) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
132 auth_request_log_gss_error(request, major_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
133 GSS_C_GSS_CODE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
134 "acquiring service credentials"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
135 auth_request_log_gss_error(request, minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
136 GSS_C_MECH_CODE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
137 "acquiring service credentials"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
138 return major_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
139 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
140 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
141 gss_release_name(&minor_status, gss_principal); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
142 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
143 return major_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
144 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
145 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
146 static gss_name_t |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
147 import_name(struct auth_request *request, void *str, size_t len) |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
148 { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
149 OM_uint32 major_status, minor_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
150 gss_buffer_desc name_buf; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
151 gss_name_t name; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
152 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
153 name_buf.value = str; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
154 name_buf.length = len; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
155 major_status = gss_import_name(&minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
156 &name_buf, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
157 GSS_C_NO_OID, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
158 &name); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
159 if (GSS_ERROR(major_status)) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
160 auth_request_log_gss_error(request, major_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
161 GSS_C_GSS_CODE, "gss_import_name"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
162 return GSS_C_NO_NAME; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
163 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
164 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
165 return name; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
166 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
167 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
168 static void gssapi_sec_context(struct gssapi_auth_request *request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
169 gss_buffer_desc inbuf) |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
170 { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
171 OM_uint32 major_status, minor_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
172 gss_buffer_desc outbuf; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
173 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
174 major_status = gss_accept_sec_context ( |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
175 &minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
176 &request->gss_ctx, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
177 request->service_cred, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
178 &inbuf, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
179 GSS_C_NO_CHANNEL_BINDINGS, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
180 &request->authn_name, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
181 NULL, /* mech_type */ |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
182 &outbuf, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
183 NULL, /* ret_flags */ |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
184 NULL, /* time_rec */ |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
185 NULL /* delegated_cred_handle */ |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
186 ); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
187 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
188 if (GSS_ERROR(major_status)) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
189 auth_request_log_gss_error(&request->auth_request, major_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
190 GSS_C_GSS_CODE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
191 "processing incoming data"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
192 auth_request_log_gss_error(&request->auth_request, minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
193 GSS_C_MECH_CODE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
194 "processing incoming data"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
195 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
196 auth_request_fail(&request->auth_request); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
197 return; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
198 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
199 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
200 if (major_status == GSS_S_COMPLETE) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
201 request->sasl_gssapi_state = GSS_STATE_WRAP; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
202 auth_request_log_info(&request->auth_request, "gssapi", |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
203 "security context state completed."); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
204 } else { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
205 auth_request_log_info(&request->auth_request, "gssapi", |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
206 "Processed incoming packet correctly, " |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
207 "waiting for another."); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
208 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
209 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
210 request->auth_request.callback(&request->auth_request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
211 AUTH_CLIENT_RESULT_CONTINUE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
212 outbuf.value, outbuf.length); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
213 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
214 major_status = gss_release_buffer(&minor_status, &outbuf); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
215 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
216 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
217 static void gssapi_wrap(struct gssapi_auth_request *request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
218 gss_buffer_desc inbuf) |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
219 { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
220 OM_uint32 major_status, minor_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
221 gss_buffer_desc outbuf; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
222 unsigned char ret[4]; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
223 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
224 /* The clients return data should be empty here */ |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
225 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
226 /* Only authentication, no integrity or confidentiality |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
227 protection (yet?) */ |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
228 ret[0] = (SASL_GSSAPI_QOP_UNSPECIFIED | |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
229 SASL_GSSAPI_QOP_AUTH_ONLY); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
230 ret[1] = 0xFF; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
231 ret[2] = 0xFF; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
232 ret[3] = 0xFF; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
233 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
234 inbuf.length = 4; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
235 inbuf.value = ret; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
236 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
237 major_status = gss_wrap(&minor_status, request->gss_ctx, 0, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
238 GSS_C_QOP_DEFAULT, &inbuf, NULL, &outbuf); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
239 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
240 if (GSS_ERROR(major_status)) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
241 auth_request_log_gss_error(&request->auth_request, major_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
242 GSS_C_GSS_CODE, "sending security layer negotiation"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
243 auth_request_log_gss_error(&request->auth_request, minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
244 GSS_C_MECH_CODE, "sending security layer negotiation"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
245 auth_request_fail(&request->auth_request); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
246 return; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
247 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
248 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
249 auth_request_log_info(&request->auth_request, "gssapi", |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
250 "Negotiated security layer"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
251 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
252 request->auth_request.callback(&request->auth_request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
253 AUTH_CLIENT_RESULT_CONTINUE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
254 outbuf.value, outbuf.length); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
255 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
256 major_status = gss_release_buffer(&minor_status, &outbuf); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
257 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
258 request->sasl_gssapi_state = GSS_STATE_UNWRAP; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
259 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
260 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
261 static void gssapi_unwrap(struct gssapi_auth_request *request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
262 gss_buffer_desc inbuf) |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
263 { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
264 OM_uint32 major_status, minor_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
265 gss_buffer_desc outbuf; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
266 int equal_authn_authz = 0; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
267 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
268 major_status = gss_unwrap(&minor_status, request->gss_ctx, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
269 &inbuf, &outbuf, NULL, NULL); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
270 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
271 if (GSS_ERROR(major_status)) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
272 auth_request_log_gss_error(&request->auth_request, major_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
273 GSS_C_GSS_CODE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
274 "final negotiation: gss_unwrap"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
275 auth_request_fail(&request->auth_request); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
276 return; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
277 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
278 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
279 if (outbuf.length <= 4) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
280 auth_request_log_error(&request->auth_request, "gssapi", |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
281 "Invalid response length"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
282 auth_request_fail(&request->auth_request); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
283 return; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
284 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
285 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
286 request->authz_name = import_name(&request->auth_request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
287 (unsigned char *)outbuf.value + 4, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
288 outbuf.length - 4); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
289 if ((request->authn_name == GSS_C_NO_NAME) || |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
290 (request->authz_name == GSS_C_NO_NAME)) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
291 /* XXX (pod): is this check necessary? */ |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
292 auth_request_log_error(&request->auth_request, "gssapi", |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
293 "one of authn_name or authz_name not determined"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
294 auth_request_fail(&request->auth_request); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
295 return; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
296 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
297 major_status = gss_compare_name(&minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
298 request->authn_name, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
299 request->authz_name, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
300 &equal_authn_authz); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
301 if (equal_authn_authz == 0) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
302 auth_request_log_error(&request->auth_request, "gssapi", |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
303 "authn_name and authz_name differ: not supported"); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
304 auth_request_fail(&request->auth_request); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
305 return; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
306 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
307 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
308 request->auth_request.user = |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
309 p_strndup(request->auth_request.pool, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
310 (unsigned char *)outbuf.value + 4, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
311 outbuf.length - 4); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
312 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
313 auth_request_success(&request->auth_request, NULL, 0); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
314 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
315 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
316 static void |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
317 mech_gssapi_auth_continue(struct auth_request *request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
318 const unsigned char *data, size_t data_size) |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
319 { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
320 struct gssapi_auth_request *gssapi_request = |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
321 (struct gssapi_auth_request *)request; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
322 gss_buffer_desc inbuf; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
323 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
324 inbuf.value = (void *)data; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
325 inbuf.length = data_size; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
326 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
327 switch (gssapi_request->sasl_gssapi_state) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
328 case GSS_STATE_SEC_CONTEXT: |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
329 gssapi_sec_context(gssapi_request, inbuf); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
330 break; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
331 case GSS_STATE_WRAP: |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
332 gssapi_wrap(gssapi_request, inbuf); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
333 break; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
334 case GSS_STATE_UNWRAP: |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
335 gssapi_unwrap(gssapi_request, inbuf); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
336 break; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
337 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
338 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
339 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
340 static void |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
341 mech_gssapi_auth_initial(struct auth_request *request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
342 const unsigned char *data, size_t data_size) |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
343 { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
344 OM_uint32 major_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
345 struct gssapi_auth_request *gssapi_request = |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
346 (struct gssapi_auth_request *)request; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
347 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
348 major_status = |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
349 obtain_service_credentials(request, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
350 &gssapi_request->service_cred); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
351 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
352 if (GSS_ERROR(major_status)) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
353 auth_request_internal_failure(request); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
354 return; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
355 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
356 gssapi_request->authn_name = GSS_C_NO_NAME; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
357 gssapi_request->authz_name = GSS_C_NO_NAME; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
358 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
359 gssapi_request->sasl_gssapi_state = GSS_STATE_SEC_CONTEXT; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
360 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
361 if (data_size == 0) { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
362 /* The client should go first */ |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
363 request->callback(request, AUTH_CLIENT_RESULT_CONTINUE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
364 NULL, 0); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
365 } else { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
366 mech_gssapi_auth_continue(request, data, data_size); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
367 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
368 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
369 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
370 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
371 static void |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
372 mech_gssapi_auth_free(struct auth_request *request) |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
373 { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
374 OM_uint32 major_status, minor_status; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
375 struct gssapi_auth_request *gssapi_request = |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
376 (struct gssapi_auth_request *)request; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
377 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
378 major_status = gss_delete_sec_context(&minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
379 &gssapi_request->gss_ctx, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
380 GSS_C_NO_BUFFER); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
381 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
382 major_status = gss_release_cred(&minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
383 &gssapi_request->service_cred); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
384 major_status = gss_release_name(&minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
385 &gssapi_request->authn_name); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
386 major_status = gss_release_name(&minor_status, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
387 &gssapi_request->authz_name); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
388 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
389 pool_unref(request->pool); |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
390 } |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
391 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
392 const struct mech_module mech_gssapi = { |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
393 "GSSAPI", |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
394 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
395 MEMBER(flags) 0, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
396 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
397 MEMBER(need_passdb) FALSE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
398 MEMBER(passdb_need_plain) FALSE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
399 MEMBER(passdb_need_credentials) FALSE, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
400 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
401 mech_gssapi_auth_new, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
402 mech_gssapi_auth_initial, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
403 mech_gssapi_auth_continue, |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
404 mech_gssapi_auth_free |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
405 }; |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
406 |
28cca6317829
Added GSSAPI support. Patch by Jelmer Vernooij and some fixes by
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
407 #endif |