summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2003-11-17 21:20:18 +1100
committerDamien Miller <djm@mindrot.org>2003-11-17 21:20:18 +1100
commit91c6aa4468a1a8b8e76fbf1c64719055c6acdffa (patch)
tree9a23e23f73fbdd3677a38efb2f7273c349a27c2f
parentfe44847cb82d984618176722376f0a491f7b2b29 (diff)
- markus@cvs.openbsd.org 2003/11/14 13:19:09
[sshconnect2.c] cleanup and minor fixes for the client code; from Simon Wilkinson
-rw-r--r--ChangeLog5
-rw-r--r--sshconnect2.c80
2 files changed, 40 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index eb3c71b3f..8eba44a97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,6 +37,9 @@
37 - jmc@cvs.openbsd.org 2003/11/12 20:14:51 37 - jmc@cvs.openbsd.org 2003/11/12 20:14:51
38 [ssh_config.5] 38 [ssh_config.5]
39 make verb agree with subject, and kill some whitespace; 39 make verb agree with subject, and kill some whitespace;
40 - markus@cvs.openbsd.org 2003/11/14 13:19:09
41 [sshconnect2.c]
42 cleanup and minor fixes for the client code; from Simon Wilkinson
40 43
4120031115 4420031115
42 - (dtucker) [regress/agent-ptrace.sh] Test for GDB output from Solaris and 45 - (dtucker) [regress/agent-ptrace.sh] Test for GDB output from Solaris and
@@ -1457,4 +1460,4 @@
1457 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. 1460 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
1458 Report from murple@murple.net, diagnosis from dtucker@zip.com.au 1461 Report from murple@murple.net, diagnosis from dtucker@zip.com.au
1459 1462
1460$Id: ChangeLog,v 1.3107 2003/11/17 10:19:49 djm Exp $ 1463$Id: ChangeLog,v 1.3108 2003/11/17 10:20:18 djm Exp $
diff --git a/sshconnect2.c b/sshconnect2.c
index f991f81d8..045f3081f 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: sshconnect2.c,v 1.129 2003/11/02 11:01:03 markus Exp $"); 26RCSID("$OpenBSD: sshconnect2.c,v 1.130 2003/11/14 13:19:09 markus Exp $");
27 27
28#include "openbsd-compat/sys-queue.h" 28#include "openbsd-compat/sys-queue.h"
29 29
@@ -537,15 +537,44 @@ userauth_gssapi(Authctxt *authctxt)
537 return 1; 537 return 1;
538} 538}
539 539
540static OM_uint32
541process_gssapi_token(void *ctxt, gss_buffer_t recv_tok)
542{
543 Authctxt *authctxt = ctxt;
544 Gssctxt *gssctxt = authctxt->methoddata;
545 gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
546 OM_uint32 status, ms;
547
548 status = ssh_gssapi_init_ctx(gssctxt, options.gss_deleg_creds,
549 recv_tok, &send_tok, NULL);
550
551 if (send_tok.length > 0) {
552 if (GSS_ERROR(status))
553 packet_start(SSH2_MSG_USERAUTH_GSSAPI_ERRTOK);
554 else
555 packet_start(SSH2_MSG_USERAUTH_GSSAPI_TOKEN);
556
557 packet_put_string(send_tok.value, send_tok.length);
558 packet_send();
559 gss_release_buffer(&ms, &send_tok);
560 }
561
562 if (status == GSS_S_COMPLETE) {
563 /* If that succeeded, send a exchange complete message */
564 packet_start(SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE);
565 packet_send();
566 }
567
568 return status;
569}
570
540void 571void
541input_gssapi_response(int type, u_int32_t plen, void *ctxt) 572input_gssapi_response(int type, u_int32_t plen, void *ctxt)
542{ 573{
543 Authctxt *authctxt = ctxt; 574 Authctxt *authctxt = ctxt;
544 Gssctxt *gssctxt; 575 Gssctxt *gssctxt;
545 OM_uint32 status, ms;
546 int oidlen; 576 int oidlen;
547 char *oidv; 577 char *oidv;
548 gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
549 578
550 if (authctxt == NULL) 579 if (authctxt == NULL)
551 fatal("input_gssapi_response: no authentication context"); 580 fatal("input_gssapi_response: no authentication context");
@@ -557,9 +586,9 @@ input_gssapi_response(int type, u_int32_t plen, void *ctxt)
557 if (oidlen <= 2 || 586 if (oidlen <= 2 ||
558 oidv[0] != SSH_GSS_OIDTYPE || 587 oidv[0] != SSH_GSS_OIDTYPE ||
559 oidv[1] != oidlen - 2) { 588 oidv[1] != oidlen - 2) {
589 xfree(oidv);
560 debug("Badly encoded mechanism OID received"); 590 debug("Badly encoded mechanism OID received");
561 userauth(authctxt, NULL); 591 userauth(authctxt, NULL);
562 xfree(oidv);
563 return; 592 return;
564 } 593 }
565 594
@@ -570,76 +599,39 @@ input_gssapi_response(int type, u_int32_t plen, void *ctxt)
570 599
571 xfree(oidv); 600 xfree(oidv);
572 601
573 status = ssh_gssapi_init_ctx(gssctxt, options.gss_deleg_creds, 602 if (GSS_ERROR(process_gssapi_token(ctxt, GSS_C_NO_BUFFER))) {
574 GSS_C_NO_BUFFER, &send_tok, NULL);
575 if (GSS_ERROR(status)) {
576 if (send_tok.length > 0) {
577 packet_start(SSH2_MSG_USERAUTH_GSSAPI_ERRTOK);
578 packet_put_string(send_tok.value, send_tok.length);
579 packet_send();
580 gss_release_buffer(&ms, &send_tok);
581 }
582 /* Start again with next method on list */ 603 /* Start again with next method on list */
583 debug("Trying to start again"); 604 debug("Trying to start again");
584 userauth(authctxt, NULL); 605 userauth(authctxt, NULL);
585 return; 606 return;
586 } 607 }
587
588 /* We must have data to send */
589 packet_start(SSH2_MSG_USERAUTH_GSSAPI_TOKEN);
590 packet_put_string(send_tok.value, send_tok.length);
591 packet_send();
592 gss_release_buffer(&ms, &send_tok);
593} 608}
594 609
595void 610void
596input_gssapi_token(int type, u_int32_t plen, void *ctxt) 611input_gssapi_token(int type, u_int32_t plen, void *ctxt)
597{ 612{
598 Authctxt *authctxt = ctxt; 613 Authctxt *authctxt = ctxt;
599 Gssctxt *gssctxt;
600 gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
601 gss_buffer_desc recv_tok; 614 gss_buffer_desc recv_tok;
602 OM_uint32 status, ms; 615 OM_uint32 status;
603 u_int slen; 616 u_int slen;
604 617
605 if (authctxt == NULL) 618 if (authctxt == NULL)
606 fatal("input_gssapi_response: no authentication context"); 619 fatal("input_gssapi_response: no authentication context");
607 gssctxt = authctxt->methoddata;
608 620
609 recv_tok.value = packet_get_string(&slen); 621 recv_tok.value = packet_get_string(&slen);
610 recv_tok.length = slen; /* safe typecast */ 622 recv_tok.length = slen; /* safe typecast */
611 623
612 packet_check_eom(); 624 packet_check_eom();
613 625
614 status = ssh_gssapi_init_ctx(gssctxt, options.gss_deleg_creds, 626 status = process_gssapi_token(ctxt, &recv_tok);
615 &recv_tok, &send_tok, NULL);
616 627
617 xfree(recv_tok.value); 628 xfree(recv_tok.value);
618 629
619 if (GSS_ERROR(status)) { 630 if (GSS_ERROR(status)) {
620 if (send_tok.length > 0) {
621 packet_start(SSH2_MSG_USERAUTH_GSSAPI_ERRTOK);
622 packet_put_string(send_tok.value, send_tok.length);
623 packet_send();
624 gss_release_buffer(&ms, &send_tok);
625 }
626 /* Start again with the next method in the list */ 631 /* Start again with the next method in the list */
627 userauth(authctxt, NULL); 632 userauth(authctxt, NULL);
628 return; 633 return;
629 } 634 }
630
631 if (send_tok.length > 0) {
632 packet_start(SSH2_MSG_USERAUTH_GSSAPI_TOKEN);
633 packet_put_string(send_tok.value, send_tok.length);
634 packet_send();
635 gss_release_buffer(&ms, &send_tok);
636 }
637
638 if (status == GSS_S_COMPLETE) {
639 /* If that succeeded, send a exchange complete message */
640 packet_start(SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE);
641 packet_send();
642 }
643} 635}
644 636
645void 637void