summaryrefslogtreecommitdiff
path: root/sshconnect2.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2015-01-19 20:07:45 +0000
committerDamien Miller <djm@mindrot.org>2015-01-20 09:14:16 +1100
commit3fdc88a0def4f86aa88a5846ac079dc964c0546a (patch)
treed26470c8ffb49bb4417af2b729d933d6ce3f75f8 /sshconnect2.c
parent091c302829210c41e7f57c3f094c7b9c054306f0 (diff)
upstream commit
move dispatch to struct ssh; ok djm@
Diffstat (limited to 'sshconnect2.c')
-rw-r--r--sshconnect2.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/sshconnect2.c b/sshconnect2.c
index ba34762ea..e0d129996 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect2.c,v 1.217 2015/01/19 19:52:16 markus Exp $ */ 1/* $OpenBSD: sshconnect2.c,v 1.218 2015/01/19 20:07:45 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Damien Miller. All rights reserved. 4 * Copyright (c) 2008 Damien Miller. All rights reserved.
@@ -285,14 +285,14 @@ struct cauthmethod {
285 int *batch_flag; /* flag in option struct that disables method */ 285 int *batch_flag; /* flag in option struct that disables method */
286}; 286};
287 287
288void input_userauth_success(int, u_int32_t, void *); 288int input_userauth_success(int, u_int32_t, void *);
289void input_userauth_success_unexpected(int, u_int32_t, void *); 289int input_userauth_success_unexpected(int, u_int32_t, void *);
290void input_userauth_failure(int, u_int32_t, void *); 290int input_userauth_failure(int, u_int32_t, void *);
291void input_userauth_banner(int, u_int32_t, void *); 291int input_userauth_banner(int, u_int32_t, void *);
292void input_userauth_error(int, u_int32_t, void *); 292int input_userauth_error(int, u_int32_t, void *);
293void input_userauth_info_req(int, u_int32_t, void *); 293int input_userauth_info_req(int, u_int32_t, void *);
294void input_userauth_pk_ok(int, u_int32_t, void *); 294int input_userauth_pk_ok(int, u_int32_t, void *);
295void input_userauth_passwd_changereq(int, u_int32_t, void *); 295int input_userauth_passwd_changereq(int, u_int32_t, void *);
296 296
297int userauth_none(Authctxt *); 297int userauth_none(Authctxt *);
298int userauth_pubkey(Authctxt *); 298int userauth_pubkey(Authctxt *);
@@ -302,11 +302,11 @@ int userauth_hostbased(Authctxt *);
302 302
303#ifdef GSSAPI 303#ifdef GSSAPI
304int userauth_gssapi(Authctxt *authctxt); 304int userauth_gssapi(Authctxt *authctxt);
305void input_gssapi_response(int type, u_int32_t, void *); 305int input_gssapi_response(int type, u_int32_t, void *);
306void input_gssapi_token(int type, u_int32_t, void *); 306int input_gssapi_token(int type, u_int32_t, void *);
307void input_gssapi_hash(int type, u_int32_t, void *); 307int input_gssapi_hash(int type, u_int32_t, void *);
308void input_gssapi_error(int, u_int32_t, void *); 308int input_gssapi_error(int, u_int32_t, void *);
309void input_gssapi_errtok(int, u_int32_t, void *); 309int input_gssapi_errtok(int, u_int32_t, void *);
310#endif 310#endif
311 311
312void userauth(Authctxt *, char *); 312void userauth(Authctxt *, char *);
@@ -455,15 +455,16 @@ userauth(Authctxt *authctxt, char *authlist)
455} 455}
456 456
457/* ARGSUSED */ 457/* ARGSUSED */
458void 458int
459input_userauth_error(int type, u_int32_t seq, void *ctxt) 459input_userauth_error(int type, u_int32_t seq, void *ctxt)
460{ 460{
461 fatal("input_userauth_error: bad message during authentication: " 461 fatal("input_userauth_error: bad message during authentication: "
462 "type %d", type); 462 "type %d", type);
463 return 0;
463} 464}
464 465
465/* ARGSUSED */ 466/* ARGSUSED */
466void 467int
467input_userauth_banner(int type, u_int32_t seq, void *ctxt) 468input_userauth_banner(int type, u_int32_t seq, void *ctxt)
468{ 469{
469 char *msg, *raw, *lang; 470 char *msg, *raw, *lang;
@@ -482,10 +483,11 @@ input_userauth_banner(int type, u_int32_t seq, void *ctxt)
482 } 483 }
483 free(raw); 484 free(raw);
484 free(lang); 485 free(lang);
486 return 0;
485} 487}
486 488
487/* ARGSUSED */ 489/* ARGSUSED */
488void 490int
489input_userauth_success(int type, u_int32_t seq, void *ctxt) 491input_userauth_success(int type, u_int32_t seq, void *ctxt)
490{ 492{
491 Authctxt *authctxt = ctxt; 493 Authctxt *authctxt = ctxt;
@@ -499,9 +501,10 @@ input_userauth_success(int type, u_int32_t seq, void *ctxt)
499 free(authctxt->methoddata); 501 free(authctxt->methoddata);
500 authctxt->methoddata = NULL; 502 authctxt->methoddata = NULL;
501 authctxt->success = 1; /* break out */ 503 authctxt->success = 1; /* break out */
504 return 0;
502} 505}
503 506
504void 507int
505input_userauth_success_unexpected(int type, u_int32_t seq, void *ctxt) 508input_userauth_success_unexpected(int type, u_int32_t seq, void *ctxt)
506{ 509{
507 Authctxt *authctxt = ctxt; 510 Authctxt *authctxt = ctxt;
@@ -511,10 +514,11 @@ input_userauth_success_unexpected(int type, u_int32_t seq, void *ctxt)
511 514
512 fatal("Unexpected authentication success during %s.", 515 fatal("Unexpected authentication success during %s.",
513 authctxt->method->name); 516 authctxt->method->name);
517 return 0;
514} 518}
515 519
516/* ARGSUSED */ 520/* ARGSUSED */
517void 521int
518input_userauth_failure(int type, u_int32_t seq, void *ctxt) 522input_userauth_failure(int type, u_int32_t seq, void *ctxt)
519{ 523{
520 Authctxt *authctxt = ctxt; 524 Authctxt *authctxt = ctxt;
@@ -537,10 +541,11 @@ input_userauth_failure(int type, u_int32_t seq, void *ctxt)
537 debug("Authentications that can continue: %s", authlist); 541 debug("Authentications that can continue: %s", authlist);
538 542
539 userauth(authctxt, authlist); 543 userauth(authctxt, authlist);
544 return 0;
540} 545}
541 546
542/* ARGSUSED */ 547/* ARGSUSED */
543void 548int
544input_userauth_pk_ok(int type, u_int32_t seq, void *ctxt) 549input_userauth_pk_ok(int type, u_int32_t seq, void *ctxt)
545{ 550{
546 Authctxt *authctxt = ctxt; 551 Authctxt *authctxt = ctxt;
@@ -608,6 +613,7 @@ done:
608 /* try another method if we did not send a packet */ 613 /* try another method if we did not send a packet */
609 if (sent == 0) 614 if (sent == 0)
610 userauth(authctxt, NULL); 615 userauth(authctxt, NULL);
616 return 0;
611} 617}
612 618
613#ifdef GSSAPI 619#ifdef GSSAPI
@@ -891,7 +897,7 @@ userauth_passwd(Authctxt *authctxt)
891 * parse PASSWD_CHANGEREQ, prompt user and send SSH2_MSG_USERAUTH_REQUEST 897 * parse PASSWD_CHANGEREQ, prompt user and send SSH2_MSG_USERAUTH_REQUEST
892 */ 898 */
893/* ARGSUSED */ 899/* ARGSUSED */
894void 900int
895input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt) 901input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
896{ 902{
897 Authctxt *authctxt = ctxt; 903 Authctxt *authctxt = ctxt;
@@ -932,7 +938,7 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
932 password = read_passphrase(prompt, RP_ALLOW_EOF); 938 password = read_passphrase(prompt, RP_ALLOW_EOF);
933 if (password == NULL) { 939 if (password == NULL) {
934 /* bail out */ 940 /* bail out */
935 return; 941 return 0;
936 } 942 }
937 snprintf(prompt, sizeof(prompt), 943 snprintf(prompt, sizeof(prompt),
938 "Retype %.30s@%.128s's new password: ", 944 "Retype %.30s@%.128s's new password: ",
@@ -955,6 +961,7 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
955 961
956 dispatch_set(SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ, 962 dispatch_set(SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ,
957 &input_userauth_passwd_changereq); 963 &input_userauth_passwd_changereq);
964 return 0;
958} 965}
959 966
960static int 967static int
@@ -1379,7 +1386,7 @@ userauth_kbdint(Authctxt *authctxt)
1379/* 1386/*
1380 * parse INFO_REQUEST, prompt user and send INFO_RESPONSE 1387 * parse INFO_REQUEST, prompt user and send INFO_RESPONSE
1381 */ 1388 */
1382void 1389int
1383input_userauth_info_req(int type, u_int32_t seq, void *ctxt) 1390input_userauth_info_req(int type, u_int32_t seq, void *ctxt)
1384{ 1391{
1385 Authctxt *authctxt = ctxt; 1392 Authctxt *authctxt = ctxt;
@@ -1431,6 +1438,7 @@ input_userauth_info_req(int type, u_int32_t seq, void *ctxt)
1431 1438
1432 packet_add_padding(64); 1439 packet_add_padding(64);
1433 packet_send(); 1440 packet_send();
1441 return 0;
1434} 1442}
1435 1443
1436static int 1444static int