diff options
-rw-r--r-- | auth-bsdauth.c | 6 | ||||
-rw-r--r-- | auth-krb5.c | 6 | ||||
-rw-r--r-- | auth-rhosts.c | 6 | ||||
-rw-r--r-- | auth.c | 39 | ||||
-rw-r--r-- | auth2-chall.c | 69 | ||||
-rw-r--r-- | auth2-hostbased.c | 4 | ||||
-rw-r--r-- | auth2-kbdint.c | 14 | ||||
-rw-r--r-- | auth2-none.c | 3 | ||||
-rw-r--r-- | auth2-passwd.c | 3 | ||||
-rw-r--r-- | auth2-pubkey.c | 4 | ||||
-rw-r--r-- | auth2.c | 22 | ||||
-rw-r--r-- | monitor.c | 4 |
12 files changed, 95 insertions, 85 deletions
diff --git a/auth-bsdauth.c b/auth-bsdauth.c index e00718f2e..4dc5045c2 100644 --- a/auth-bsdauth.c +++ b/auth-bsdauth.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth-bsdauth.c,v 1.14 2015/10/20 23:24:25 mmcc Exp $ */ | 1 | /* $OpenBSD: auth-bsdauth.c,v 1.15 2018/07/09 21:35:50 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. |
4 | * | 4 | * |
@@ -33,11 +33,11 @@ | |||
33 | 33 | ||
34 | #ifdef BSD_AUTH | 34 | #ifdef BSD_AUTH |
35 | #include "xmalloc.h" | 35 | #include "xmalloc.h" |
36 | #include "key.h" | 36 | #include "sshkey.h" |
37 | #include "sshbuf.h" | ||
37 | #include "hostfile.h" | 38 | #include "hostfile.h" |
38 | #include "auth.h" | 39 | #include "auth.h" |
39 | #include "log.h" | 40 | #include "log.h" |
40 | #include "buffer.h" | ||
41 | #ifdef GSSAPI | 41 | #ifdef GSSAPI |
42 | #include "ssh-gss.h" | 42 | #include "ssh-gss.h" |
43 | #endif | 43 | #endif |
diff --git a/auth-krb5.c b/auth-krb5.c index a5a81ed2e..3096f1c8e 100644 --- a/auth-krb5.c +++ b/auth-krb5.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth-krb5.c,v 1.22 2016/05/04 14:22:33 markus Exp $ */ | 1 | /* $OpenBSD: auth-krb5.c,v 1.23 2018/07/09 21:35:50 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Kerberos v5 authentication and ticket-passing routines. | 3 | * Kerberos v5 authentication and ticket-passing routines. |
4 | * | 4 | * |
@@ -38,11 +38,11 @@ | |||
38 | #include "ssh.h" | 38 | #include "ssh.h" |
39 | #include "packet.h" | 39 | #include "packet.h" |
40 | #include "log.h" | 40 | #include "log.h" |
41 | #include "buffer.h" | 41 | #include "sshbuf.h" |
42 | #include "sshkey.h" | ||
42 | #include "misc.h" | 43 | #include "misc.h" |
43 | #include "servconf.h" | 44 | #include "servconf.h" |
44 | #include "uidswap.h" | 45 | #include "uidswap.h" |
45 | #include "key.h" | ||
46 | #include "hostfile.h" | 46 | #include "hostfile.h" |
47 | #include "auth.h" | 47 | #include "auth.h" |
48 | 48 | ||
diff --git a/auth-rhosts.c b/auth-rhosts.c index ecf956f06..57296e1f6 100644 --- a/auth-rhosts.c +++ b/auth-rhosts.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth-rhosts.c,v 1.48 2016/08/13 17:47:41 markus Exp $ */ | 1 | /* $OpenBSD: auth-rhosts.c,v 1.49 2018/07/09 21:35:50 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -34,8 +34,8 @@ | |||
34 | #include "pathnames.h" | 34 | #include "pathnames.h" |
35 | #include "log.h" | 35 | #include "log.h" |
36 | #include "misc.h" | 36 | #include "misc.h" |
37 | #include "buffer.h" /* XXX */ | 37 | #include "sshbuf.h" |
38 | #include "key.h" /* XXX */ | 38 | #include "sshkey.h" |
39 | #include "servconf.h" | 39 | #include "servconf.h" |
40 | #include "canohost.h" | 40 | #include "canohost.h" |
41 | #include "sshkey.h" | 41 | #include "sshkey.h" |
@@ -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 * |
diff --git a/auth2-chall.c b/auth2-chall.c index 11c8d31b3..5edd0e653 100644 --- a/auth2-chall.c +++ b/auth2-chall.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth2-chall.c,v 1.48 2017/05/30 14:29:59 markus Exp $ */ | 1 | /* $OpenBSD: auth2-chall.c,v 1.49 2018/07/09 21:35:50 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2001 Per Allansson. All rights reserved. | 4 | * Copyright (c) 2001 Per Allansson. All rights reserved. |
@@ -34,12 +34,13 @@ | |||
34 | 34 | ||
35 | #include "xmalloc.h" | 35 | #include "xmalloc.h" |
36 | #include "ssh2.h" | 36 | #include "ssh2.h" |
37 | #include "key.h" | 37 | #include "sshkey.h" |
38 | #include "hostfile.h" | 38 | #include "hostfile.h" |
39 | #include "auth.h" | 39 | #include "auth.h" |
40 | #include "buffer.h" | 40 | #include "sshbuf.h" |
41 | #include "packet.h" | 41 | #include "packet.h" |
42 | #include "dispatch.h" | 42 | #include "dispatch.h" |
43 | #include "ssherr.h" | ||
43 | #include "log.h" | 44 | #include "log.h" |
44 | #include "misc.h" | 45 | #include "misc.h" |
45 | #include "servconf.h" | 46 | #include "servconf.h" |
@@ -48,7 +49,7 @@ | |||
48 | extern ServerOptions options; | 49 | extern ServerOptions options; |
49 | 50 | ||
50 | static int auth2_challenge_start(struct ssh *); | 51 | static int auth2_challenge_start(struct ssh *); |
51 | static int send_userauth_info_request(Authctxt *); | 52 | static int send_userauth_info_request(struct ssh *); |
52 | static int input_userauth_info_response(int, u_int32_t, struct ssh *); | 53 | static int input_userauth_info_response(int, u_int32_t, struct ssh *); |
53 | 54 | ||
54 | #ifdef BSD_AUTH | 55 | #ifdef BSD_AUTH |
@@ -105,8 +106,8 @@ static KbdintAuthctxt * | |||
105 | kbdint_alloc(const char *devs) | 106 | kbdint_alloc(const char *devs) |
106 | { | 107 | { |
107 | KbdintAuthctxt *kbdintctxt; | 108 | KbdintAuthctxt *kbdintctxt; |
108 | Buffer b; | 109 | struct sshbuf *b; |
109 | int i; | 110 | int i, r; |
110 | 111 | ||
111 | #ifdef USE_PAM | 112 | #ifdef USE_PAM |
112 | if (!options.use_pam) | 113 | if (!options.use_pam) |
@@ -115,16 +116,17 @@ kbdint_alloc(const char *devs) | |||
115 | 116 | ||
116 | kbdintctxt = xcalloc(1, sizeof(KbdintAuthctxt)); | 117 | kbdintctxt = xcalloc(1, sizeof(KbdintAuthctxt)); |
117 | if (strcmp(devs, "") == 0) { | 118 | if (strcmp(devs, "") == 0) { |
118 | buffer_init(&b); | 119 | if ((b = sshbuf_new()) == NULL) |
120 | fatal("%s: sshbuf_new failed", __func__); | ||
119 | for (i = 0; devices[i]; i++) { | 121 | for (i = 0; devices[i]; i++) { |
120 | if (buffer_len(&b) > 0) | 122 | if ((r = sshbuf_putf(b, "%s%s", |
121 | buffer_append(&b, ",", 1); | 123 | sshbuf_len(b) ? "," : "", devices[i]->name)) != 0) |
122 | buffer_append(&b, devices[i]->name, | 124 | fatal("%s: buffer error: %s", |
123 | strlen(devices[i]->name)); | 125 | __func__, ssh_err(r)); |
124 | } | 126 | } |
125 | if ((kbdintctxt->devices = sshbuf_dup_string(&b)) == NULL) | 127 | if ((kbdintctxt->devices = sshbuf_dup_string(b)) == NULL) |
126 | fatal("%s: sshbuf_dup_string failed", __func__); | 128 | fatal("%s: sshbuf_dup_string failed", __func__); |
127 | buffer_free(&b); | 129 | sshbuf_free(b); |
128 | } else { | 130 | } else { |
129 | kbdintctxt->devices = xstrdup(devs); | 131 | kbdintctxt->devices = xstrdup(devs); |
130 | } | 132 | } |
@@ -243,7 +245,7 @@ auth2_challenge_start(struct ssh *ssh) | |||
243 | auth2_challenge_stop(ssh); | 245 | auth2_challenge_stop(ssh); |
244 | return 0; | 246 | return 0; |
245 | } | 247 | } |
246 | if (send_userauth_info_request(authctxt) == 0) { | 248 | if (send_userauth_info_request(ssh) == 0) { |
247 | auth2_challenge_stop(ssh); | 249 | auth2_challenge_stop(ssh); |
248 | return 0; | 250 | return 0; |
249 | } | 251 | } |
@@ -255,28 +257,32 @@ auth2_challenge_start(struct ssh *ssh) | |||
255 | } | 257 | } |
256 | 258 | ||
257 | static int | 259 | static int |
258 | send_userauth_info_request(Authctxt *authctxt) | 260 | send_userauth_info_request(struct ssh *ssh) |
259 | { | 261 | { |
262 | Authctxt *authctxt = ssh->authctxt; | ||
260 | KbdintAuthctxt *kbdintctxt; | 263 | KbdintAuthctxt *kbdintctxt; |
261 | char *name, *instr, **prompts; | 264 | char *name, *instr, **prompts; |
262 | u_int i, *echo_on; | 265 | u_int r, i, *echo_on; |
263 | 266 | ||
264 | kbdintctxt = authctxt->kbdintctxt; | 267 | kbdintctxt = authctxt->kbdintctxt; |
265 | if (kbdintctxt->device->query(kbdintctxt->ctxt, | 268 | if (kbdintctxt->device->query(kbdintctxt->ctxt, |
266 | &name, &instr, &kbdintctxt->nreq, &prompts, &echo_on)) | 269 | &name, &instr, &kbdintctxt->nreq, &prompts, &echo_on)) |
267 | return 0; | 270 | return 0; |
268 | 271 | ||
269 | packet_start(SSH2_MSG_USERAUTH_INFO_REQUEST); | 272 | if ((r = sshpkt_start(ssh, SSH2_MSG_USERAUTH_INFO_REQUEST)) != 0 || |
270 | packet_put_cstring(name); | 273 | (r = sshpkt_put_cstring(ssh, name)) != 0 || |
271 | packet_put_cstring(instr); | 274 | (r = sshpkt_put_cstring(ssh, instr)) != 0 || |
272 | packet_put_cstring(""); /* language not used */ | 275 | (r = sshpkt_put_cstring(ssh, "")) != 0 || /* language not used */ |
273 | packet_put_int(kbdintctxt->nreq); | 276 | (r = sshpkt_put_u32(ssh, kbdintctxt->nreq)) != 0) |
277 | fatal("%s: %s", __func__, ssh_err(r)); | ||
274 | for (i = 0; i < kbdintctxt->nreq; i++) { | 278 | for (i = 0; i < kbdintctxt->nreq; i++) { |
275 | packet_put_cstring(prompts[i]); | 279 | if ((r = sshpkt_put_cstring(ssh, prompts[i])) != 0 || |
276 | packet_put_char(echo_on[i]); | 280 | (r = sshpkt_put_u8(ssh, echo_on[i])) != 0) |
281 | fatal("%s: %s", __func__, ssh_err(r)); | ||
277 | } | 282 | } |
278 | packet_send(); | 283 | if ((r = sshpkt_send(ssh)) != 0) |
279 | packet_write_wait(); | 284 | fatal("%s: %s", __func__, ssh_err(r)); |
285 | ssh_packet_write_wait(ssh); | ||
280 | 286 | ||
281 | for (i = 0; i < kbdintctxt->nreq; i++) | 287 | for (i = 0; i < kbdintctxt->nreq; i++) |
282 | free(prompts[i]); | 288 | free(prompts[i]); |
@@ -293,6 +299,7 @@ input_userauth_info_response(int type, u_int32_t seq, struct ssh *ssh) | |||
293 | Authctxt *authctxt = ssh->authctxt; | 299 | Authctxt *authctxt = ssh->authctxt; |
294 | KbdintAuthctxt *kbdintctxt; | 300 | KbdintAuthctxt *kbdintctxt; |
295 | int authenticated = 0, res; | 301 | int authenticated = 0, res; |
302 | int r; | ||
296 | u_int i, nresp; | 303 | u_int i, nresp; |
297 | const char *devicename = NULL; | 304 | const char *devicename = NULL; |
298 | char **response = NULL; | 305 | char **response = NULL; |
@@ -306,7 +313,8 @@ input_userauth_info_response(int type, u_int32_t seq, struct ssh *ssh) | |||
306 | fatal("input_userauth_info_response: no device"); | 313 | fatal("input_userauth_info_response: no device"); |
307 | 314 | ||
308 | authctxt->postponed = 0; /* reset */ | 315 | authctxt->postponed = 0; /* reset */ |
309 | nresp = packet_get_int(); | 316 | if ((r = sshpkt_get_u32(ssh, &nresp)) != 0) |
317 | fatal("%s: %s", __func__, ssh_err(r)); | ||
310 | if (nresp != kbdintctxt->nreq) | 318 | if (nresp != kbdintctxt->nreq) |
311 | fatal("input_userauth_info_response: wrong number of replies"); | 319 | fatal("input_userauth_info_response: wrong number of replies"); |
312 | if (nresp > 100) | 320 | if (nresp > 100) |
@@ -314,9 +322,12 @@ input_userauth_info_response(int type, u_int32_t seq, struct ssh *ssh) | |||
314 | if (nresp > 0) { | 322 | if (nresp > 0) { |
315 | response = xcalloc(nresp, sizeof(char *)); | 323 | response = xcalloc(nresp, sizeof(char *)); |
316 | for (i = 0; i < nresp; i++) | 324 | for (i = 0; i < nresp; i++) |
317 | response[i] = packet_get_string(NULL); | 325 | if ((r = sshpkt_get_cstring(ssh, &response[i], |
326 | NULL)) != 0) | ||
327 | fatal("%s: %s", __func__, ssh_err(r)); | ||
318 | } | 328 | } |
319 | packet_check_eom(); | 329 | if ((r = sshpkt_get_end(ssh)) != 0) |
330 | fatal("%s: %s", __func__, ssh_err(r)); | ||
320 | 331 | ||
321 | res = kbdintctxt->device->respond(kbdintctxt->ctxt, nresp, response); | 332 | res = kbdintctxt->device->respond(kbdintctxt->ctxt, nresp, response); |
322 | 333 | ||
@@ -333,7 +344,7 @@ input_userauth_info_response(int type, u_int32_t seq, struct ssh *ssh) | |||
333 | break; | 344 | break; |
334 | case 1: | 345 | case 1: |
335 | /* Authentication needs further interaction */ | 346 | /* Authentication needs further interaction */ |
336 | if (send_userauth_info_request(authctxt) == 1) | 347 | if (send_userauth_info_request(ssh) == 1) |
337 | authctxt->postponed = 1; | 348 | authctxt->postponed = 1; |
338 | break; | 349 | break; |
339 | default: | 350 | default: |
diff --git a/auth2-hostbased.c b/auth2-hostbased.c index f70609cb0..60159a56c 100644 --- a/auth2-hostbased.c +++ b/auth2-hostbased.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth2-hostbased.c,v 1.34 2018/07/03 11:39:54 djm Exp $ */ | 1 | /* $OpenBSD: auth2-hostbased.c,v 1.35 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 | * |
@@ -34,7 +34,7 @@ | |||
34 | #include "xmalloc.h" | 34 | #include "xmalloc.h" |
35 | #include "ssh2.h" | 35 | #include "ssh2.h" |
36 | #include "packet.h" | 36 | #include "packet.h" |
37 | #include "buffer.h" | 37 | #include "sshbuf.h" |
38 | #include "log.h" | 38 | #include "log.h" |
39 | #include "misc.h" | 39 | #include "misc.h" |
40 | #include "servconf.h" | 40 | #include "servconf.h" |
diff --git a/auth2-kbdint.c b/auth2-kbdint.c index 86aad8ddc..a813b8f56 100644 --- a/auth2-kbdint.c +++ b/auth2-kbdint.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth2-kbdint.c,v 1.8 2017/05/30 14:29:59 markus Exp $ */ | 1 | /* $OpenBSD: auth2-kbdint.c,v 1.9 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 | * |
@@ -31,13 +31,12 @@ | |||
31 | 31 | ||
32 | #include "xmalloc.h" | 32 | #include "xmalloc.h" |
33 | #include "packet.h" | 33 | #include "packet.h" |
34 | #include "key.h" | ||
35 | #include "hostfile.h" | 34 | #include "hostfile.h" |
36 | #include "auth.h" | 35 | #include "auth.h" |
37 | #include "log.h" | 36 | #include "log.h" |
38 | #include "buffer.h" | ||
39 | #include "misc.h" | 37 | #include "misc.h" |
40 | #include "servconf.h" | 38 | #include "servconf.h" |
39 | #include "ssherr.h" | ||
41 | 40 | ||
42 | /* import */ | 41 | /* import */ |
43 | extern ServerOptions options; | 42 | extern ServerOptions options; |
@@ -45,12 +44,13 @@ extern ServerOptions options; | |||
45 | static int | 44 | static int |
46 | userauth_kbdint(struct ssh *ssh) | 45 | userauth_kbdint(struct ssh *ssh) |
47 | { | 46 | { |
48 | int authenticated = 0; | 47 | int r, authenticated = 0; |
49 | char *lang, *devs; | 48 | char *lang, *devs; |
50 | 49 | ||
51 | lang = packet_get_string(NULL); | 50 | if ((r = sshpkt_get_cstring(ssh, &lang, NULL)) != 0 || |
52 | devs = packet_get_string(NULL); | 51 | (r = sshpkt_get_cstring(ssh, &devs, NULL)) != 0 || |
53 | packet_check_eom(); | 52 | (r = sshpkt_get_end(ssh)) != 0) |
53 | fatal("%s: %s", __func__, ssh_err(r)); | ||
54 | 54 | ||
55 | debug("keyboard-interactive devs %s", devs); | 55 | debug("keyboard-interactive devs %s", devs); |
56 | 56 | ||
diff --git a/auth2-none.c b/auth2-none.c index 8d4e9bb8c..dacb5fb83 100644 --- a/auth2-none.c +++ b/auth2-none.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth2-none.c,v 1.21 2018/03/03 03:15:51 djm Exp $ */ | 1 | /* $OpenBSD: auth2-none.c,v 1.22 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 | * |
@@ -42,7 +42,6 @@ | |||
42 | #include "auth.h" | 42 | #include "auth.h" |
43 | #include "packet.h" | 43 | #include "packet.h" |
44 | #include "log.h" | 44 | #include "log.h" |
45 | #include "buffer.h" | ||
46 | #include "misc.h" | 45 | #include "misc.h" |
47 | #include "servconf.h" | 46 | #include "servconf.h" |
48 | #include "compat.h" | 47 | #include "compat.h" |
diff --git a/auth2-passwd.c b/auth2-passwd.c index 445016aec..0395a69f4 100644 --- a/auth2-passwd.c +++ b/auth2-passwd.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth2-passwd.c,v 1.15 2018/03/03 03:15:51 djm Exp $ */ | 1 | /* $OpenBSD: auth2-passwd.c,v 1.16 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 | * |
@@ -36,7 +36,6 @@ | |||
36 | #include "sshkey.h" | 36 | #include "sshkey.h" |
37 | #include "hostfile.h" | 37 | #include "hostfile.h" |
38 | #include "auth.h" | 38 | #include "auth.h" |
39 | #include "buffer.h" | ||
40 | #ifdef GSSAPI | 39 | #ifdef GSSAPI |
41 | #include "ssh-gss.h" | 40 | #include "ssh-gss.h" |
42 | #endif | 41 | #endif |
diff --git a/auth2-pubkey.c b/auth2-pubkey.c index 4feeae3e2..e649a6253 100644 --- a/auth2-pubkey.c +++ b/auth2-pubkey.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth2-pubkey.c,v 1.80 2018/07/03 11:39:54 djm Exp $ */ | 1 | /* $OpenBSD: auth2-pubkey.c,v 1.81 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 | * |
@@ -46,7 +46,7 @@ | |||
46 | #include "ssh.h" | 46 | #include "ssh.h" |
47 | #include "ssh2.h" | 47 | #include "ssh2.h" |
48 | #include "packet.h" | 48 | #include "packet.h" |
49 | #include "buffer.h" | 49 | #include "sshbuf.h" |
50 | #include "log.h" | 50 | #include "log.h" |
51 | #include "misc.h" | 51 | #include "misc.h" |
52 | #include "servconf.h" | 52 | #include "servconf.h" |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth2.c,v 1.147 2018/05/11 03:22:55 dtucker Exp $ */ | 1 | /* $OpenBSD: auth2.c,v 1.148 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 | * |
@@ -41,7 +41,7 @@ | |||
41 | #include "ssh2.h" | 41 | #include "ssh2.h" |
42 | #include "packet.h" | 42 | #include "packet.h" |
43 | #include "log.h" | 43 | #include "log.h" |
44 | #include "buffer.h" | 44 | #include "sshbuf.h" |
45 | #include "misc.h" | 45 | #include "misc.h" |
46 | #include "servconf.h" | 46 | #include "servconf.h" |
47 | #include "compat.h" | 47 | #include "compat.h" |
@@ -451,11 +451,12 @@ auth2_method_allowed(Authctxt *authctxt, const char *method, | |||
451 | static char * | 451 | static char * |
452 | authmethods_get(Authctxt *authctxt) | 452 | authmethods_get(Authctxt *authctxt) |
453 | { | 453 | { |
454 | Buffer b; | 454 | struct sshbuf *b; |
455 | char *list; | 455 | char *list; |
456 | u_int i; | 456 | int i, r; |
457 | 457 | ||
458 | buffer_init(&b); | 458 | if ((b = sshbuf_new()) == NULL) |
459 | fatal("%s: sshbuf_new failed", __func__); | ||
459 | for (i = 0; authmethods[i] != NULL; i++) { | 460 | for (i = 0; authmethods[i] != NULL; i++) { |
460 | if (strcmp(authmethods[i]->name, "none") == 0) | 461 | if (strcmp(authmethods[i]->name, "none") == 0) |
461 | continue; | 462 | continue; |
@@ -465,14 +466,13 @@ authmethods_get(Authctxt *authctxt) | |||
465 | if (!auth2_method_allowed(authctxt, authmethods[i]->name, | 466 | if (!auth2_method_allowed(authctxt, authmethods[i]->name, |
466 | NULL)) | 467 | NULL)) |
467 | continue; | 468 | continue; |
468 | if (buffer_len(&b) > 0) | 469 | if ((r = sshbuf_putf(b, "%s%s", sshbuf_len(b) ? "," : "", |
469 | buffer_append(&b, ",", 1); | 470 | authmethods[i]->name)) != 0) |
470 | buffer_append(&b, authmethods[i]->name, | 471 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
471 | strlen(authmethods[i]->name)); | ||
472 | } | 472 | } |
473 | if ((list = sshbuf_dup_string(&b)) == NULL) | 473 | if ((list = sshbuf_dup_string(b)) == NULL) |
474 | fatal("%s: sshbuf_dup_string failed", __func__); | 474 | fatal("%s: sshbuf_dup_string failed", __func__); |
475 | buffer_free(&b); | 475 | sshbuf_free(b); |
476 | return list; | 476 | return list; |
477 | } | 477 | } |
478 | 478 | ||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: monitor.c,v 1.181 2018/07/09 21:26:02 markus Exp $ */ | 1 | /* $OpenBSD: monitor.c,v 1.182 2018/07/09 21:35:50 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright 2002 Niels Provos <provos@citi.umich.edu> | 3 | * Copyright 2002 Niels Provos <provos@citi.umich.edu> |
4 | * Copyright 2002 Markus Friedl <markus@openbsd.org> | 4 | * Copyright 2002 Markus Friedl <markus@openbsd.org> |
@@ -113,8 +113,6 @@ static Gssctxt *gsscontext = NULL; | |||
113 | extern ServerOptions options; | 113 | extern ServerOptions options; |
114 | extern u_int utmp_len; | 114 | extern u_int utmp_len; |
115 | extern u_char session_id[]; | 115 | extern u_char session_id[]; |
116 | extern Buffer auth_debug; | ||
117 | extern int auth_debug_init; | ||
118 | extern struct sshbuf *loginmsg; | 116 | extern struct sshbuf *loginmsg; |
119 | extern struct sshauthopt *auth_opts; /* XXX move to permanent ssh->authctxt? */ | 117 | extern struct sshauthopt *auth_opts; /* XXX move to permanent ssh->authctxt? */ |
120 | 118 | ||