diff options
Diffstat (limited to 'auth2-gss.c')
-rw-r--r-- | auth2-gss.c | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/auth2-gss.c b/auth2-gss.c index 93d576bfb..17d4a3a84 100644 --- a/auth2-gss.c +++ b/auth2-gss.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* $OpenBSD: auth2-gss.c,v 1.18 2012/12/02 20:34:09 djm Exp $ */ | 1 | /* $OpenBSD: auth2-gss.c,v 1.18 2012/12/02 20:34:09 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | 4 | * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions |
@@ -52,6 +52,40 @@ static void input_gssapi_mic(int type, u_int32_t plen, void *ctxt); | |||
52 | static void input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt); | 52 | static void input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt); |
53 | static void input_gssapi_errtok(int, u_int32_t, void *); | 53 | static void input_gssapi_errtok(int, u_int32_t, void *); |
54 | 54 | ||
55 | /* | ||
56 | * The 'gssapi_keyex' userauth mechanism. | ||
57 | */ | ||
58 | static int | ||
59 | userauth_gsskeyex(Authctxt *authctxt) | ||
60 | { | ||
61 | int authenticated = 0; | ||
62 | Buffer b; | ||
63 | gss_buffer_desc mic, gssbuf; | ||
64 | u_int len; | ||
65 | |||
66 | mic.value = packet_get_string(&len); | ||
67 | mic.length = len; | ||
68 | |||
69 | packet_check_eom(); | ||
70 | |||
71 | ssh_gssapi_buildmic(&b, authctxt->user, authctxt->service, | ||
72 | "gssapi-keyex"); | ||
73 | |||
74 | gssbuf.value = buffer_ptr(&b); | ||
75 | gssbuf.length = buffer_len(&b); | ||
76 | |||
77 | /* gss_kex_context is NULL with privsep, so we can't check it here */ | ||
78 | if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gss_kex_context, | ||
79 | &gssbuf, &mic)))) | ||
80 | authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user, | ||
81 | authctxt->pw)); | ||
82 | |||
83 | buffer_free(&b); | ||
84 | xfree(mic.value); | ||
85 | |||
86 | return (authenticated); | ||
87 | } | ||
88 | |||
55 | /* | 89 | /* |
56 | * We only support those mechanisms that we know about (ie ones that we know | 90 | * We only support those mechanisms that we know about (ie ones that we know |
57 | * how to check local user kuserok and the like) | 91 | * how to check local user kuserok and the like) |
@@ -244,7 +278,8 @@ input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt) | |||
244 | 278 | ||
245 | packet_check_eom(); | 279 | packet_check_eom(); |
246 | 280 | ||
247 | authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user)); | 281 | authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user, |
282 | authctxt->pw)); | ||
248 | 283 | ||
249 | authctxt->postponed = 0; | 284 | authctxt->postponed = 0; |
250 | dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL); | 285 | dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL); |
@@ -279,7 +314,8 @@ input_gssapi_mic(int type, u_int32_t plen, void *ctxt) | |||
279 | gssbuf.length = buffer_len(&b); | 314 | gssbuf.length = buffer_len(&b); |
280 | 315 | ||
281 | if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gssctxt, &gssbuf, &mic)))) | 316 | if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gssctxt, &gssbuf, &mic)))) |
282 | authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user)); | 317 | authenticated = |
318 | PRIVSEP(ssh_gssapi_userok(authctxt->user, authctxt->pw)); | ||
283 | else | 319 | else |
284 | logit("GSSAPI MIC check failed"); | 320 | logit("GSSAPI MIC check failed"); |
285 | 321 | ||
@@ -294,6 +330,12 @@ input_gssapi_mic(int type, u_int32_t plen, void *ctxt) | |||
294 | userauth_finish(authctxt, authenticated, "gssapi-with-mic", NULL); | 330 | userauth_finish(authctxt, authenticated, "gssapi-with-mic", NULL); |
295 | } | 331 | } |
296 | 332 | ||
333 | Authmethod method_gsskeyex = { | ||
334 | "gssapi-keyex", | ||
335 | userauth_gsskeyex, | ||
336 | &options.gss_authentication | ||
337 | }; | ||
338 | |||
297 | Authmethod method_gssapi = { | 339 | Authmethod method_gssapi = { |
298 | "gssapi-with-mic", | 340 | "gssapi-with-mic", |
299 | userauth_gssapi, | 341 | userauth_gssapi, |