diff options
Diffstat (limited to 'auth.c')
-rw-r--r-- | auth.c | 39 |
1 files changed, 21 insertions, 18 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth.c,v 1.130 2018/06/06 18:23:32 djm Exp $ */ | 1 | /* $OpenBSD: auth.c,v 1.131 2018/07/09 21:35:50 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
4 | * | 4 | * |
@@ -55,10 +55,10 @@ | |||
55 | #include "match.h" | 55 | #include "match.h" |
56 | #include "groupaccess.h" | 56 | #include "groupaccess.h" |
57 | #include "log.h" | 57 | #include "log.h" |
58 | #include "buffer.h" | 58 | #include "sshbuf.h" |
59 | #include "misc.h" | 59 | #include "misc.h" |
60 | #include "servconf.h" | 60 | #include "servconf.h" |
61 | #include "key.h" | 61 | #include "sshkey.h" |
62 | #include "hostfile.h" | 62 | #include "hostfile.h" |
63 | #include "auth.h" | 63 | #include "auth.h" |
64 | #include "auth-options.h" | 64 | #include "auth-options.h" |
@@ -84,8 +84,7 @@ extern struct passwd *privsep_pw; | |||
84 | extern struct sshauthopt *auth_opts; | 84 | extern struct sshauthopt *auth_opts; |
85 | 85 | ||
86 | /* Debugging messages */ | 86 | /* Debugging messages */ |
87 | Buffer auth_debug; | 87 | static struct sshbuf *auth_debug; |
88 | int auth_debug_init; | ||
89 | 88 | ||
90 | /* | 89 | /* |
91 | * Check if the user is allowed to log in via ssh. If user is listed | 90 | * Check if the user is allowed to log in via ssh. If user is listed |
@@ -281,7 +280,7 @@ format_method_key(Authctxt *authctxt) | |||
281 | if (key == NULL) | 280 | if (key == NULL) |
282 | return NULL; | 281 | return NULL; |
283 | 282 | ||
284 | if (key_is_cert(key)) { | 283 | if (sshkey_is_cert(key)) { |
285 | fp = sshkey_fingerprint(key->cert->signature_key, | 284 | fp = sshkey_fingerprint(key->cert->signature_key, |
286 | options.fingerprint_hash, SSH_FP_DEFAULT); | 285 | options.fingerprint_hash, SSH_FP_DEFAULT); |
287 | xasprintf(&ret, "%s ID %s (serial %llu) CA %s %s%s%s", | 286 | xasprintf(&ret, "%s ID %s (serial %llu) CA %s %s%s%s", |
@@ -672,26 +671,32 @@ auth_debug_add(const char *fmt,...) | |||
672 | { | 671 | { |
673 | char buf[1024]; | 672 | char buf[1024]; |
674 | va_list args; | 673 | va_list args; |
674 | int r; | ||
675 | 675 | ||
676 | if (!auth_debug_init) | 676 | if (auth_debug == NULL) |
677 | return; | 677 | return; |
678 | 678 | ||
679 | va_start(args, fmt); | 679 | va_start(args, fmt); |
680 | vsnprintf(buf, sizeof(buf), fmt, args); | 680 | vsnprintf(buf, sizeof(buf), fmt, args); |
681 | va_end(args); | 681 | va_end(args); |
682 | buffer_put_cstring(&auth_debug, buf); | 682 | if ((r = sshbuf_put_cstring(auth_debug, buf)) != 0) |
683 | fatal("%s: sshbuf_put_cstring: %s", __func__, ssh_err(r)); | ||
683 | } | 684 | } |
684 | 685 | ||
685 | void | 686 | void |
686 | auth_debug_send(void) | 687 | auth_debug_send(void) |
687 | { | 688 | { |
689 | struct ssh *ssh = active_state; /* XXX */ | ||
688 | char *msg; | 690 | char *msg; |
691 | int r; | ||
689 | 692 | ||
690 | if (!auth_debug_init) | 693 | if (auth_debug == NULL) |
691 | return; | 694 | return; |
692 | while (buffer_len(&auth_debug)) { | 695 | while (sshbuf_len(auth_debug) != 0) { |
693 | msg = buffer_get_string(&auth_debug, NULL); | 696 | if ((r = sshbuf_get_cstring(auth_debug, &msg, NULL)) != 0) |
694 | packet_send_debug("%s", msg); | 697 | fatal("%s: sshbuf_get_cstring: %s", |
698 | __func__, ssh_err(r)); | ||
699 | ssh_packet_send_debug(ssh, "%s", msg); | ||
695 | free(msg); | 700 | free(msg); |
696 | } | 701 | } |
697 | } | 702 | } |
@@ -699,12 +704,10 @@ auth_debug_send(void) | |||
699 | void | 704 | void |
700 | auth_debug_reset(void) | 705 | auth_debug_reset(void) |
701 | { | 706 | { |
702 | if (auth_debug_init) | 707 | if (auth_debug != NULL) |
703 | buffer_clear(&auth_debug); | 708 | sshbuf_reset(auth_debug); |
704 | else { | 709 | else if ((auth_debug = sshbuf_new()) == NULL) |
705 | buffer_init(&auth_debug); | 710 | fatal("%s: sshbuf_new failed", __func__); |
706 | auth_debug_init = 1; | ||
707 | } | ||
708 | } | 711 | } |
709 | 712 | ||
710 | struct passwd * | 713 | struct passwd * |