xref: /openbsd-src/usr.bin/ssh/gss-serv.c (revision 264cfea27cdb63c29ca0527d3faff3a0af37672d)
1*264cfea2Sdjm /* $OpenBSD: gss-serv.c,v 1.32 2020/03/13 03:17:07 djm Exp $ */
2c9017d5dSmarkus 
3c9017d5dSmarkus /*
4c9017d5dSmarkus  * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
5c9017d5dSmarkus  *
6c9017d5dSmarkus  * Redistribution and use in source and binary forms, with or without
7c9017d5dSmarkus  * modification, are permitted provided that the following conditions
8c9017d5dSmarkus  * are met:
9c9017d5dSmarkus  * 1. Redistributions of source code must retain the above copyright
10c9017d5dSmarkus  *    notice, this list of conditions and the following disclaimer.
11c9017d5dSmarkus  * 2. Redistributions in binary form must reproduce the above copyright
12c9017d5dSmarkus  *    notice, this list of conditions and the following disclaimer in the
13c9017d5dSmarkus  *    documentation and/or other materials provided with the distribution.
14c9017d5dSmarkus  *
15c9017d5dSmarkus  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
16c9017d5dSmarkus  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17c9017d5dSmarkus  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18c9017d5dSmarkus  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19c9017d5dSmarkus  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20c9017d5dSmarkus  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21c9017d5dSmarkus  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22c9017d5dSmarkus  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23c9017d5dSmarkus  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24c9017d5dSmarkus  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25c9017d5dSmarkus  */
26c9017d5dSmarkus 
27bd9502d5Sderaadt #include <sys/types.h>
282a54096dSdjm #include <sys/queue.h>
29c9017d5dSmarkus 
30c9017d5dSmarkus #ifdef GSSAPI
31c9017d5dSmarkus 
320deb6794Sstevesk #include <string.h>
330deb6794Sstevesk 
34bd9502d5Sderaadt #include "xmalloc.h"
35234e08abSmarkus #include "sshkey.h"
36bd9502d5Sderaadt #include "hostfile.h"
37c9017d5dSmarkus #include "auth.h"
38c9017d5dSmarkus #include "log.h"
39c9017d5dSmarkus #include "channels.h"
40c9017d5dSmarkus #include "session.h"
414fad3025Sdjm #include "misc.h"
4231ac6ab2Sdjm #include "servconf.h"
43c9017d5dSmarkus 
44c9017d5dSmarkus #include "ssh-gss.h"
45c9017d5dSmarkus 
4631ac6ab2Sdjm extern ServerOptions options;
4731ac6ab2Sdjm 
48c9017d5dSmarkus static ssh_gssapi_client gssapi_client =
49c9017d5dSmarkus     { GSS_C_EMPTY_BUFFER, GSS_C_EMPTY_BUFFER,
50c21abc57Sdjm     GSS_C_NO_CREDENTIAL, NULL, {NULL, NULL, NULL, NULL}};
51c9017d5dSmarkus 
52c9017d5dSmarkus ssh_gssapi_mech gssapi_null_mech =
53c9017d5dSmarkus     { NULL, NULL, {0, NULL}, NULL, NULL, NULL, NULL};
54c9017d5dSmarkus 
55c9017d5dSmarkus #ifdef KRB5
56c9017d5dSmarkus extern ssh_gssapi_mech gssapi_kerberos_mech;
57c9017d5dSmarkus #endif
58c9017d5dSmarkus 
59c9017d5dSmarkus ssh_gssapi_mech* supported_mechs[]= {
60c9017d5dSmarkus #ifdef KRB5
61c9017d5dSmarkus 	&gssapi_kerberos_mech,
62c9017d5dSmarkus #endif
63c9017d5dSmarkus 	&gssapi_null_mech,
64c9017d5dSmarkus };
65c9017d5dSmarkus 
661909bf1dSdjm /*
671909bf1dSdjm  * ssh_gssapi_supported_oids() can cause sandbox violations, so prepare the
681909bf1dSdjm  * list of supported mechanisms before privsep is set up.
691909bf1dSdjm  */
701909bf1dSdjm static gss_OID_set supported_oids;
711909bf1dSdjm 
721909bf1dSdjm void
ssh_gssapi_prepare_supported_oids(void)731909bf1dSdjm ssh_gssapi_prepare_supported_oids(void)
741909bf1dSdjm {
751909bf1dSdjm 	ssh_gssapi_supported_oids(&supported_oids);
761909bf1dSdjm }
771909bf1dSdjm 
781909bf1dSdjm OM_uint32
ssh_gssapi_test_oid_supported(OM_uint32 * ms,gss_OID member,int * present)791909bf1dSdjm ssh_gssapi_test_oid_supported(OM_uint32 *ms, gss_OID member, int *present)
801909bf1dSdjm {
811909bf1dSdjm 	if (supported_oids == NULL)
821909bf1dSdjm 		ssh_gssapi_prepare_supported_oids();
831909bf1dSdjm 	return gss_test_oid_set_member(ms, member, supported_oids, present);
841909bf1dSdjm }
85f22381e8Sdjm 
86f22381e8Sdjm /*
87f22381e8Sdjm  * Acquire credentials for a server running on the current host.
88f22381e8Sdjm  * Requires that the context structure contains a valid OID
89f22381e8Sdjm  */
90f22381e8Sdjm 
91f22381e8Sdjm /* Returns a GSSAPI error code */
92f22381e8Sdjm /* Privileged (called from ssh_gssapi_server_ctx) */
93f22381e8Sdjm static OM_uint32
ssh_gssapi_acquire_cred(Gssctxt * ctx)94f22381e8Sdjm ssh_gssapi_acquire_cred(Gssctxt *ctx)
95f22381e8Sdjm {
96f22381e8Sdjm 	OM_uint32 status;
97e6da133eSdjm 	char lname[NI_MAXHOST];
98f22381e8Sdjm 	gss_OID_set oidset;
99f22381e8Sdjm 
10031ac6ab2Sdjm 	if (options.gss_strict_acceptor) {
101f22381e8Sdjm 		gss_create_empty_oid_set(&status, &oidset);
102f22381e8Sdjm 		gss_add_oid_set_member(&status, ctx->oid, &oidset);
103f22381e8Sdjm 
10431ac6ab2Sdjm 		if (gethostname(lname, MAXHOSTNAMELEN)) {
105f22381e8Sdjm 			gss_release_oid_set(&status, &oidset);
106f22381e8Sdjm 			return (-1);
107f22381e8Sdjm 		}
108f22381e8Sdjm 
109f22381e8Sdjm 		if (GSS_ERROR(ssh_gssapi_import_name(ctx, lname))) {
110f22381e8Sdjm 			gss_release_oid_set(&status, &oidset);
111f22381e8Sdjm 			return (ctx->major);
112f22381e8Sdjm 		}
113f22381e8Sdjm 
114f22381e8Sdjm 		if ((ctx->major = gss_acquire_cred(&ctx->minor,
11531ac6ab2Sdjm 		    ctx->name, 0, oidset, GSS_C_ACCEPT, &ctx->creds,
11631ac6ab2Sdjm 		    NULL, NULL)))
117f22381e8Sdjm 			ssh_gssapi_error(ctx);
118f22381e8Sdjm 
119f22381e8Sdjm 		gss_release_oid_set(&status, &oidset);
120f22381e8Sdjm 		return (ctx->major);
12131ac6ab2Sdjm 	} else {
12231ac6ab2Sdjm 		ctx->name = GSS_C_NO_NAME;
12331ac6ab2Sdjm 		ctx->creds = GSS_C_NO_CREDENTIAL;
12431ac6ab2Sdjm 	}
12531ac6ab2Sdjm 	return GSS_S_COMPLETE;
126f22381e8Sdjm }
127f22381e8Sdjm 
128f22381e8Sdjm /* Privileged */
129f22381e8Sdjm OM_uint32
ssh_gssapi_server_ctx(Gssctxt ** ctx,gss_OID oid)130f22381e8Sdjm ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid)
131f22381e8Sdjm {
132f22381e8Sdjm 	if (*ctx)
133f22381e8Sdjm 		ssh_gssapi_delete_ctx(ctx);
134f22381e8Sdjm 	ssh_gssapi_build_ctx(ctx);
135f22381e8Sdjm 	ssh_gssapi_set_oid(*ctx, oid);
136f22381e8Sdjm 	return (ssh_gssapi_acquire_cred(*ctx));
137f22381e8Sdjm }
138f22381e8Sdjm 
13976e7022eSstevesk /* Unprivileged */
140c9017d5dSmarkus void
ssh_gssapi_supported_oids(gss_OID_set * oidset)141c9017d5dSmarkus ssh_gssapi_supported_oids(gss_OID_set *oidset)
142c9017d5dSmarkus {
143c9017d5dSmarkus 	int i = 0;
144c9017d5dSmarkus 	OM_uint32 min_status;
145c9017d5dSmarkus 	int present;
146c9017d5dSmarkus 	gss_OID_set supported;
147c9017d5dSmarkus 
148c9017d5dSmarkus 	gss_create_empty_oid_set(&min_status, oidset);
149c9017d5dSmarkus 	gss_indicate_mechs(&min_status, &supported);
150c9017d5dSmarkus 
151c9017d5dSmarkus 	while (supported_mechs[i]->name != NULL) {
152c9017d5dSmarkus 		if (GSS_ERROR(gss_test_oid_set_member(&min_status,
153c9017d5dSmarkus 		    &supported_mechs[i]->oid, supported, &present)))
154c9017d5dSmarkus 			present = 0;
155c9017d5dSmarkus 		if (present)
156c9017d5dSmarkus 			gss_add_oid_set_member(&min_status,
157c9017d5dSmarkus 			    &supported_mechs[i]->oid, oidset);
158c9017d5dSmarkus 		i++;
159c9017d5dSmarkus 	}
1609a6f79e6Sdjm 
1619a6f79e6Sdjm 	gss_release_oid_set(&min_status, &supported);
162c9017d5dSmarkus }
163c9017d5dSmarkus 
164c9017d5dSmarkus 
165c9017d5dSmarkus /* Wrapper around accept_sec_context
166c9017d5dSmarkus  * Requires that the context contains:
167c9017d5dSmarkus  *    oid
168c9017d5dSmarkus  *    credentials	(from ssh_gssapi_acquire_cred)
169c9017d5dSmarkus  */
17076e7022eSstevesk /* Privileged */
171c9017d5dSmarkus OM_uint32
ssh_gssapi_accept_ctx(Gssctxt * ctx,gss_buffer_desc * recv_tok,gss_buffer_desc * send_tok,OM_uint32 * flags)172c9017d5dSmarkus ssh_gssapi_accept_ctx(Gssctxt *ctx, gss_buffer_desc *recv_tok,
173c9017d5dSmarkus     gss_buffer_desc *send_tok, OM_uint32 *flags)
174c9017d5dSmarkus {
175c9017d5dSmarkus 	OM_uint32 status;
176c9017d5dSmarkus 	gss_OID mech;
177c9017d5dSmarkus 
178c9017d5dSmarkus 	ctx->major = gss_accept_sec_context(&ctx->minor,
179c9017d5dSmarkus 	    &ctx->context, ctx->creds, recv_tok,
180c9017d5dSmarkus 	    GSS_C_NO_CHANNEL_BINDINGS, &ctx->client, &mech,
181c9017d5dSmarkus 	    send_tok, flags, NULL, &ctx->client_creds);
182c9017d5dSmarkus 
183c9017d5dSmarkus 	if (GSS_ERROR(ctx->major))
184c9017d5dSmarkus 		ssh_gssapi_error(ctx);
185c9017d5dSmarkus 
186c9017d5dSmarkus 	if (ctx->client_creds)
187c9017d5dSmarkus 		debug("Received some client credentials");
188c9017d5dSmarkus 	else
189c9017d5dSmarkus 		debug("Got no client credentials");
190c9017d5dSmarkus 
191c9017d5dSmarkus 	status = ctx->major;
192c9017d5dSmarkus 
193c9017d5dSmarkus 	/* Now, if we're complete and we have the right flags, then
194c9017d5dSmarkus 	 * we flag the user as also having been authenticated
195c9017d5dSmarkus 	 */
196c9017d5dSmarkus 
197c9017d5dSmarkus 	if (((flags == NULL) || ((*flags & GSS_C_MUTUAL_FLAG) &&
198c9017d5dSmarkus 	    (*flags & GSS_C_INTEG_FLAG))) && (ctx->major == GSS_S_COMPLETE)) {
199c9017d5dSmarkus 		if (ssh_gssapi_getclient(ctx, &gssapi_client))
200c9017d5dSmarkus 			fatal("Couldn't convert client name");
201c9017d5dSmarkus 	}
202c9017d5dSmarkus 
203c9017d5dSmarkus 	return (status);
204c9017d5dSmarkus }
205c9017d5dSmarkus 
206c9017d5dSmarkus /*
207c9017d5dSmarkus  * This parses an exported name, extracting the mechanism specific portion
208c9017d5dSmarkus  * to use for ACL checking. It verifies that the name belongs the mechanism
209c9017d5dSmarkus  * originally selected.
210c9017d5dSmarkus  */
211c9017d5dSmarkus static OM_uint32
ssh_gssapi_parse_ename(Gssctxt * ctx,gss_buffer_t ename,gss_buffer_t name)212c9017d5dSmarkus ssh_gssapi_parse_ename(Gssctxt *ctx, gss_buffer_t ename, gss_buffer_t name)
213c9017d5dSmarkus {
214d7d07780Sdjm 	u_char *tok;
215c9017d5dSmarkus 	OM_uint32 offset;
216c9017d5dSmarkus 	OM_uint32 oidl;
217c9017d5dSmarkus 
218c9017d5dSmarkus 	tok = ename->value;
219c9017d5dSmarkus 
220c9017d5dSmarkus 	/*
221c9017d5dSmarkus 	 * Check that ename is long enough for all of the fixed length
222c9017d5dSmarkus 	 * header, and that the initial ID bytes are correct
223c9017d5dSmarkus 	 */
224c9017d5dSmarkus 
225c9017d5dSmarkus 	if (ename->length < 6 || memcmp(tok, "\x04\x01", 2) != 0)
226c9017d5dSmarkus 		return GSS_S_FAILURE;
227c9017d5dSmarkus 
228c9017d5dSmarkus 	/*
229c9017d5dSmarkus 	 * Extract the OID, and check it. Here GSSAPI breaks with tradition
230c9017d5dSmarkus 	 * and does use the OID type and length bytes. To confuse things
231c9017d5dSmarkus 	 * there are two lengths - the first including these, and the
232c9017d5dSmarkus 	 * second without.
233c9017d5dSmarkus 	 */
234c9017d5dSmarkus 
2354fad3025Sdjm 	oidl = get_u16(tok+2); /* length including next two bytes */
236c9017d5dSmarkus 	oidl = oidl-2; /* turn it into the _real_ length of the variable OID */
237c9017d5dSmarkus 
238c9017d5dSmarkus 	/*
239c9017d5dSmarkus 	 * Check the BER encoding for correct type and length, that the
240c9017d5dSmarkus 	 * string is long enough and that the OID matches that in our context
241c9017d5dSmarkus 	 */
242c9017d5dSmarkus 	if (tok[4] != 0x06 || tok[5] != oidl ||
243c9017d5dSmarkus 	    ename->length < oidl+6 ||
244c9017d5dSmarkus 	    !ssh_gssapi_check_oid(ctx, tok+6, oidl))
245c9017d5dSmarkus 		return GSS_S_FAILURE;
246c9017d5dSmarkus 
247c9017d5dSmarkus 	offset = oidl+6;
248c9017d5dSmarkus 
249c9017d5dSmarkus 	if (ename->length < offset+4)
250c9017d5dSmarkus 		return GSS_S_FAILURE;
251c9017d5dSmarkus 
2524fad3025Sdjm 	name->length = get_u32(tok+offset);
253c9017d5dSmarkus 	offset += 4;
254c9017d5dSmarkus 
2557b9be3eaSmarkus 	if (UINT_MAX - offset < name->length)
2567b9be3eaSmarkus 		return GSS_S_FAILURE;
257c9017d5dSmarkus 	if (ename->length < offset+name->length)
258c9017d5dSmarkus 		return GSS_S_FAILURE;
259c9017d5dSmarkus 
2609b650511Smarkus 	name->value = xmalloc(name->length+1);
261c9017d5dSmarkus 	memcpy(name->value, tok+offset, name->length);
2629b650511Smarkus 	((char *)name->value)[name->length] = 0;
263c9017d5dSmarkus 
264c9017d5dSmarkus 	return GSS_S_COMPLETE;
265c9017d5dSmarkus }
266c9017d5dSmarkus 
267c9017d5dSmarkus /* Extract the client details from a given context. This can only reliably
268c9017d5dSmarkus  * be called once for a context */
269c9017d5dSmarkus 
27076e7022eSstevesk /* Privileged (called from accept_secure_ctx) */
271c9017d5dSmarkus OM_uint32
ssh_gssapi_getclient(Gssctxt * ctx,ssh_gssapi_client * client)272c9017d5dSmarkus ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client)
273c9017d5dSmarkus {
274c9017d5dSmarkus 	int i = 0;
275c9017d5dSmarkus 
276c9017d5dSmarkus 	gss_buffer_desc ename;
277c9017d5dSmarkus 
278c9017d5dSmarkus 	client->mech = NULL;
279c9017d5dSmarkus 
280c9017d5dSmarkus 	while (supported_mechs[i]->name != NULL) {
281c9017d5dSmarkus 		if (supported_mechs[i]->oid.length == ctx->oid->length &&
282c9017d5dSmarkus 		    (memcmp(supported_mechs[i]->oid.elements,
283c9017d5dSmarkus 		    ctx->oid->elements, ctx->oid->length) == 0))
284c9017d5dSmarkus 			client->mech = supported_mechs[i];
285c9017d5dSmarkus 		i++;
286c9017d5dSmarkus 	}
287c9017d5dSmarkus 
288c9017d5dSmarkus 	if (client->mech == NULL)
289c9017d5dSmarkus 		return GSS_S_FAILURE;
290c9017d5dSmarkus 
291c9017d5dSmarkus 	if ((ctx->major = gss_display_name(&ctx->minor, ctx->client,
292c9017d5dSmarkus 	    &client->displayname, NULL))) {
293c9017d5dSmarkus 		ssh_gssapi_error(ctx);
294c9017d5dSmarkus 		return (ctx->major);
295c9017d5dSmarkus 	}
296c9017d5dSmarkus 
297c9017d5dSmarkus 	if ((ctx->major = gss_export_name(&ctx->minor, ctx->client,
298c9017d5dSmarkus 	    &ename))) {
299c9017d5dSmarkus 		ssh_gssapi_error(ctx);
300c9017d5dSmarkus 		return (ctx->major);
301c9017d5dSmarkus 	}
302c9017d5dSmarkus 
303c9017d5dSmarkus 	if ((ctx->major = ssh_gssapi_parse_ename(ctx,&ename,
304c9017d5dSmarkus 	    &client->exportedname))) {
305c9017d5dSmarkus 		return (ctx->major);
306c9017d5dSmarkus 	}
307c9017d5dSmarkus 
308c9017d5dSmarkus 	/* We can't copy this structure, so we just move the pointer to it */
309c9017d5dSmarkus 	client->creds = ctx->client_creds;
310c9017d5dSmarkus 	ctx->client_creds = GSS_C_NO_CREDENTIAL;
311c9017d5dSmarkus 	return (ctx->major);
312c9017d5dSmarkus }
313c9017d5dSmarkus 
314b8b8936dSmarkus /* As user - called on fatal/exit */
315c9017d5dSmarkus void
ssh_gssapi_cleanup_creds(void)316b8b8936dSmarkus ssh_gssapi_cleanup_creds(void)
317c9017d5dSmarkus {
318c9017d5dSmarkus 	if (gssapi_client.store.filename != NULL) {
319c9017d5dSmarkus 		/* Unlink probably isn't sufficient */
320784730b0Sstevesk 		debug("removing gssapi cred file\"%s\"",
321784730b0Sstevesk 		    gssapi_client.store.filename);
322c9017d5dSmarkus 		unlink(gssapi_client.store.filename);
323c9017d5dSmarkus 	}
324c9017d5dSmarkus }
325c9017d5dSmarkus 
326c9017d5dSmarkus /* As user */
327c9017d5dSmarkus void
ssh_gssapi_storecreds(void)328c9017d5dSmarkus ssh_gssapi_storecreds(void)
329c9017d5dSmarkus {
330c9017d5dSmarkus 	if (gssapi_client.mech && gssapi_client.mech->storecreds) {
331c9017d5dSmarkus 		(*gssapi_client.mech->storecreds)(&gssapi_client);
332c9017d5dSmarkus 	} else
333c9017d5dSmarkus 		debug("ssh_gssapi_storecreds: Not a GSSAPI mechanism");
334c9017d5dSmarkus }
335c9017d5dSmarkus 
336*264cfea2Sdjm /* This allows GSSAPI methods to do things to the child's environment based
337c9017d5dSmarkus  * on the passed authentication process and credentials.
338c9017d5dSmarkus  */
339c9017d5dSmarkus /* As user */
340c9017d5dSmarkus void
ssh_gssapi_do_child(char *** envp,u_int * envsizep)341c9017d5dSmarkus ssh_gssapi_do_child(char ***envp, u_int *envsizep)
342c9017d5dSmarkus {
343c9017d5dSmarkus 
344c9017d5dSmarkus 	if (gssapi_client.store.envvar != NULL &&
345c9017d5dSmarkus 	    gssapi_client.store.envval != NULL) {
346c9017d5dSmarkus 		debug("Setting %s to %s", gssapi_client.store.envvar,
347c9017d5dSmarkus 		    gssapi_client.store.envval);
348c9017d5dSmarkus 		child_set_env(envp, envsizep, gssapi_client.store.envvar,
349c9017d5dSmarkus 		    gssapi_client.store.envval);
350c9017d5dSmarkus 	}
351c9017d5dSmarkus }
352c9017d5dSmarkus 
353fb98d756Sdjm /* Privileged */
354c9017d5dSmarkus int
ssh_gssapi_userok(char * user)355c9017d5dSmarkus ssh_gssapi_userok(char *user)
356c9017d5dSmarkus {
357fd10e266Sdjm 	OM_uint32 lmin;
358fd10e266Sdjm 
359c9017d5dSmarkus 	if (gssapi_client.exportedname.length == 0 ||
360c9017d5dSmarkus 	    gssapi_client.exportedname.value == NULL) {
361c9017d5dSmarkus 		debug("No suitable client data");
362c9017d5dSmarkus 		return 0;
363c9017d5dSmarkus 	}
364c9017d5dSmarkus 	if (gssapi_client.mech && gssapi_client.mech->userok)
365fd10e266Sdjm 		if ((*gssapi_client.mech->userok)(&gssapi_client, user))
366fd10e266Sdjm 			return 1;
367fd10e266Sdjm 		else {
368fd10e266Sdjm 			/* Destroy delegated credentials if userok fails */
369fd10e266Sdjm 			gss_release_buffer(&lmin, &gssapi_client.displayname);
370fd10e266Sdjm 			gss_release_buffer(&lmin, &gssapi_client.exportedname);
371fd10e266Sdjm 			gss_release_cred(&lmin, &gssapi_client.creds);
372c671dcf1Sdjm 			explicit_bzero(&gssapi_client,
373c671dcf1Sdjm 			    sizeof(ssh_gssapi_client));
374fd10e266Sdjm 			return 0;
375fd10e266Sdjm 		}
376c9017d5dSmarkus 	else
377c9017d5dSmarkus 		debug("ssh_gssapi_userok: Unknown GSSAPI mechanism");
378c9017d5dSmarkus 	return (0);
379c9017d5dSmarkus }
380c9017d5dSmarkus 
38176e7022eSstevesk /* Privileged */
3821615790eSmarkus OM_uint32
ssh_gssapi_checkmic(Gssctxt * ctx,gss_buffer_t gssbuf,gss_buffer_t gssmic)3831615790eSmarkus ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
3841615790eSmarkus {
3851615790eSmarkus 	ctx->major = gss_verify_mic(&ctx->minor, ctx->context,
3861615790eSmarkus 	    gssbuf, gssmic, NULL);
3871615790eSmarkus 
3881615790eSmarkus 	return (ctx->major);
3891615790eSmarkus }
3901615790eSmarkus 
3910fafb8f1Sdjm /* Privileged */
ssh_gssapi_displayname(void)3920fafb8f1Sdjm const char *ssh_gssapi_displayname(void)
3930fafb8f1Sdjm {
3940fafb8f1Sdjm 	if (gssapi_client.displayname.length == 0 ||
3950fafb8f1Sdjm 	    gssapi_client.displayname.value == NULL)
3960fafb8f1Sdjm 		return NULL;
3970fafb8f1Sdjm 	return (char *)gssapi_client.displayname.value;
3980fafb8f1Sdjm }
3990fafb8f1Sdjm 
400c9017d5dSmarkus #endif
401