summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auth.h10
-rw-r--r--auth2-chall.c31
-rw-r--r--auth2-gss.c43
-rw-r--r--auth2-hostbased.c6
-rw-r--r--auth2-kbdint.c6
-rw-r--r--auth2-none.c5
-rw-r--r--auth2-passwd.c5
-rw-r--r--auth2-pubkey.c6
-rw-r--r--auth2.c26
9 files changed, 70 insertions, 68 deletions
diff --git a/auth.h b/auth.h
index db80fd0c7..677935463 100644
--- a/auth.h
+++ b/auth.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth.h,v 1.90 2017/05/30 08:52:19 markus Exp $ */ 1/* $OpenBSD: auth.h,v 1.91 2017/05/30 14:29:59 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -91,7 +91,7 @@ struct Authctxt {
91 91
92struct Authmethod { 92struct Authmethod {
93 char *name; 93 char *name;
94 int (*userauth)(Authctxt *authctxt); 94 int (*userauth)(struct ssh *);
95 int *enabled; 95 int *enabled;
96}; 96};
97 97
@@ -155,7 +155,7 @@ void auth_info(Authctxt *authctxt, const char *, ...)
155 __attribute__((__nonnull__ (2))); 155 __attribute__((__nonnull__ (2)));
156void auth_log(Authctxt *, int, int, const char *, const char *); 156void auth_log(Authctxt *, int, int, const char *, const char *);
157void auth_maxtries_exceeded(Authctxt *) __attribute__((noreturn)); 157void auth_maxtries_exceeded(Authctxt *) __attribute__((noreturn));
158void userauth_finish(Authctxt *, int, const char *, const char *); 158void userauth_finish(struct ssh *, int, const char *, const char *);
159int auth_root_allowed(const char *); 159int auth_root_allowed(const char *);
160 160
161void userauth_send_banner(const char *); 161void userauth_send_banner(const char *);
@@ -168,8 +168,8 @@ int auth2_method_allowed(Authctxt *, const char *, const char *);
168 168
169void privsep_challenge_enable(void); 169void privsep_challenge_enable(void);
170 170
171int auth2_challenge(Authctxt *, char *); 171int auth2_challenge(struct ssh *, char *);
172void auth2_challenge_stop(Authctxt *); 172void auth2_challenge_stop(struct ssh *);
173int bsdauth_query(void *, char **, char **, u_int *, char ***, u_int **); 173int bsdauth_query(void *, char **, char **, u_int *, char ***, u_int **);
174int bsdauth_respond(void *, u_int, char **); 174int bsdauth_respond(void *, u_int, char **);
175int skey_query(void *, char **, char **, u_int *, char ***, u_int **); 175int skey_query(void *, char **, char **, u_int *, char ***, u_int **);
diff --git a/auth2-chall.c b/auth2-chall.c
index 954eb4e18..11c8d31b3 100644
--- a/auth2-chall.c
+++ b/auth2-chall.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-chall.c,v 1.47 2017/05/30 14:23:52 markus Exp $ */ 1/* $OpenBSD: auth2-chall.c,v 1.48 2017/05/30 14:29:59 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.
@@ -47,7 +47,7 @@
47/* import */ 47/* import */
48extern ServerOptions options; 48extern ServerOptions options;
49 49
50static int auth2_challenge_start(Authctxt *); 50static int auth2_challenge_start(struct ssh *);
51static int send_userauth_info_request(Authctxt *); 51static int send_userauth_info_request(Authctxt *);
52static int input_userauth_info_response(int, u_int32_t, struct ssh *); 52static int input_userauth_info_response(int, u_int32_t, struct ssh *);
53 53
@@ -195,8 +195,9 @@ kbdint_next_device(Authctxt *authctxt, KbdintAuthctxt *kbdintctxt)
195 * wait for the response. 195 * wait for the response.
196 */ 196 */
197int 197int
198auth2_challenge(Authctxt *authctxt, char *devs) 198auth2_challenge(struct ssh *ssh, char *devs)
199{ 199{
200 Authctxt *authctxt = ssh->authctxt;
200 debug("auth2_challenge: user=%s devs=%s", 201 debug("auth2_challenge: user=%s devs=%s",
201 authctxt->user ? authctxt->user : "<nouser>", 202 authctxt->user ? authctxt->user : "<nouser>",
202 devs ? devs : "<no devs>"); 203 devs ? devs : "<no devs>");
@@ -205,15 +206,16 @@ auth2_challenge(Authctxt *authctxt, char *devs)
205 return 0; 206 return 0;
206 if (authctxt->kbdintctxt == NULL) 207 if (authctxt->kbdintctxt == NULL)
207 authctxt->kbdintctxt = kbdint_alloc(devs); 208 authctxt->kbdintctxt = kbdint_alloc(devs);
208 return auth2_challenge_start(authctxt); 209 return auth2_challenge_start(ssh);
209} 210}
210 211
211/* unregister kbd-int callbacks and context */ 212/* unregister kbd-int callbacks and context */
212void 213void
213auth2_challenge_stop(Authctxt *authctxt) 214auth2_challenge_stop(struct ssh *ssh)
214{ 215{
216 Authctxt *authctxt = ssh->authctxt;
215 /* unregister callback */ 217 /* unregister callback */
216 dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL); 218 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL);
217 if (authctxt->kbdintctxt != NULL) { 219 if (authctxt->kbdintctxt != NULL) {
218 kbdint_free(authctxt->kbdintctxt); 220 kbdint_free(authctxt->kbdintctxt);
219 authctxt->kbdintctxt = NULL; 221 authctxt->kbdintctxt = NULL;
@@ -222,29 +224,30 @@ auth2_challenge_stop(Authctxt *authctxt)
222 224
223/* side effect: sets authctxt->postponed if a reply was sent*/ 225/* side effect: sets authctxt->postponed if a reply was sent*/
224static int 226static int
225auth2_challenge_start(Authctxt *authctxt) 227auth2_challenge_start(struct ssh *ssh)
226{ 228{
229 Authctxt *authctxt = ssh->authctxt;
227 KbdintAuthctxt *kbdintctxt = authctxt->kbdintctxt; 230 KbdintAuthctxt *kbdintctxt = authctxt->kbdintctxt;
228 231
229 debug2("auth2_challenge_start: devices %s", 232 debug2("auth2_challenge_start: devices %s",
230 kbdintctxt->devices ? kbdintctxt->devices : "<empty>"); 233 kbdintctxt->devices ? kbdintctxt->devices : "<empty>");
231 234
232 if (kbdint_next_device(authctxt, kbdintctxt) == 0) { 235 if (kbdint_next_device(authctxt, kbdintctxt) == 0) {
233 auth2_challenge_stop(authctxt); 236 auth2_challenge_stop(ssh);
234 return 0; 237 return 0;
235 } 238 }
236 debug("auth2_challenge_start: trying authentication method '%s'", 239 debug("auth2_challenge_start: trying authentication method '%s'",
237 kbdintctxt->device->name); 240 kbdintctxt->device->name);
238 241
239 if ((kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == NULL) { 242 if ((kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == NULL) {
240 auth2_challenge_stop(authctxt); 243 auth2_challenge_stop(ssh);
241 return 0; 244 return 0;
242 } 245 }
243 if (send_userauth_info_request(authctxt) == 0) { 246 if (send_userauth_info_request(authctxt) == 0) {
244 auth2_challenge_stop(authctxt); 247 auth2_challenge_stop(ssh);
245 return 0; 248 return 0;
246 } 249 }
247 dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, 250 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_INFO_RESPONSE,
248 &input_userauth_info_response); 251 &input_userauth_info_response);
249 252
250 authctxt->postponed = 1; 253 authctxt->postponed = 1;
@@ -340,14 +343,14 @@ input_userauth_info_response(int type, u_int32_t seq, struct ssh *ssh)
340 devicename = kbdintctxt->device->name; 343 devicename = kbdintctxt->device->name;
341 if (!authctxt->postponed) { 344 if (!authctxt->postponed) {
342 if (authenticated) { 345 if (authenticated) {
343 auth2_challenge_stop(authctxt); 346 auth2_challenge_stop(ssh);
344 } else { 347 } else {
345 /* start next device */ 348 /* start next device */
346 /* may set authctxt->postponed */ 349 /* may set authctxt->postponed */
347 auth2_challenge_start(authctxt); 350 auth2_challenge_start(ssh);
348 } 351 }
349 } 352 }
350 userauth_finish(authctxt, authenticated, "keyboard-interactive", 353 userauth_finish(ssh, authenticated, "keyboard-interactive",
351 devicename); 354 devicename);
352 return 0; 355 return 0;
353} 356}
diff --git a/auth2-gss.c b/auth2-gss.c
index a762747d6..680d5e712 100644
--- a/auth2-gss.c
+++ b/auth2-gss.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-gss.c,v 1.24 2017/05/30 14:23:52 markus Exp $ */ 1/* $OpenBSD: auth2-gss.c,v 1.25 2017/05/30 14:29:59 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. 4 * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
@@ -58,8 +58,9 @@ static int input_gssapi_errtok(int, u_int32_t, struct ssh *);
58 * how to check local user kuserok and the like) 58 * how to check local user kuserok and the like)
59 */ 59 */
60static int 60static int
61userauth_gssapi(Authctxt *authctxt) 61userauth_gssapi(struct ssh *ssh)
62{ 62{
63 Authctxt *authctxt = ssh->authctxt;
63 gss_OID_desc goid = {0, NULL}; 64 gss_OID_desc goid = {0, NULL};
64 Gssctxt *ctxt = NULL; 65 Gssctxt *ctxt = NULL;
65 int mechs; 66 int mechs;
@@ -119,8 +120,8 @@ userauth_gssapi(Authctxt *authctxt)
119 packet_send(); 120 packet_send();
120 free(doid); 121 free(doid);
121 122
122 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, &input_gssapi_token); 123 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_TOKEN, &input_gssapi_token);
123 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_ERRTOK, &input_gssapi_errtok); 124 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_ERRTOK, &input_gssapi_errtok);
124 authctxt->postponed = 1; 125 authctxt->postponed = 1;
125 126
126 return (0); 127 return (0);
@@ -157,8 +158,8 @@ input_gssapi_token(int type, u_int32_t plen, struct ssh *ssh)
157 packet_send(); 158 packet_send();
158 } 159 }
159 authctxt->postponed = 0; 160 authctxt->postponed = 0;
160 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL); 161 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);
161 userauth_finish(authctxt, 0, "gssapi-with-mic", NULL); 162 userauth_finish(ssh, 0, "gssapi-with-mic", NULL);
162 } else { 163 } else {
163 if (send_tok.length != 0) { 164 if (send_tok.length != 0) {
164 packet_start(SSH2_MSG_USERAUTH_GSSAPI_TOKEN); 165 packet_start(SSH2_MSG_USERAUTH_GSSAPI_TOKEN);
@@ -166,12 +167,12 @@ input_gssapi_token(int type, u_int32_t plen, struct ssh *ssh)
166 packet_send(); 167 packet_send();
167 } 168 }
168 if (maj_status == GSS_S_COMPLETE) { 169 if (maj_status == GSS_S_COMPLETE) {
169 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL); 170 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);
170 if (flags & GSS_C_INTEG_FLAG) 171 if (flags & GSS_C_INTEG_FLAG)
171 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_MIC, 172 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_MIC,
172 &input_gssapi_mic); 173 &input_gssapi_mic);
173 else 174 else
174 dispatch_set( 175 ssh_dispatch_set(ssh,
175 SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE, 176 SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE,
176 &input_gssapi_exchange_complete); 177 &input_gssapi_exchange_complete);
177 } 178 }
@@ -207,8 +208,8 @@ input_gssapi_errtok(int type, u_int32_t plen, struct ssh *ssh)
207 free(recv_tok.value); 208 free(recv_tok.value);
208 209
209 /* We can't return anything to the client, even if we wanted to */ 210 /* We can't return anything to the client, even if we wanted to */
210 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL); 211 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);
211 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_ERRTOK, NULL); 212 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_ERRTOK, NULL);
212 213
213 /* The client will have already moved on to the next auth */ 214 /* The client will have already moved on to the next auth */
214 215
@@ -241,11 +242,11 @@ input_gssapi_exchange_complete(int type, u_int32_t plen, struct ssh *ssh)
241 authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user)); 242 authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user));
242 243
243 authctxt->postponed = 0; 244 authctxt->postponed = 0;
244 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL); 245 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);
245 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_ERRTOK, NULL); 246 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_ERRTOK, NULL);
246 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_MIC, NULL); 247 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_MIC, NULL);
247 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE, NULL); 248 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE, NULL);
248 userauth_finish(authctxt, authenticated, "gssapi-with-mic", NULL); 249 userauth_finish(ssh, authenticated, "gssapi-with-mic", NULL);
249 return 0; 250 return 0;
250} 251}
251 252
@@ -282,11 +283,11 @@ input_gssapi_mic(int type, u_int32_t plen, struct ssh *ssh)
282 free(mic.value); 283 free(mic.value);
283 284
284 authctxt->postponed = 0; 285 authctxt->postponed = 0;
285 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL); 286 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);
286 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_ERRTOK, NULL); 287 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_ERRTOK, NULL);
287 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_MIC, NULL); 288 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_MIC, NULL);
288 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE, NULL); 289 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE, NULL);
289 userauth_finish(authctxt, authenticated, "gssapi-with-mic", NULL); 290 userauth_finish(ssh, authenticated, "gssapi-with-mic", NULL);
290 return 0; 291 return 0;
291} 292}
292 293
diff --git a/auth2-hostbased.c b/auth2-hostbased.c
index 728548396..63fe9ae65 100644
--- a/auth2-hostbased.c
+++ b/auth2-hostbased.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-hostbased.c,v 1.29 2017/05/30 14:25:42 markus Exp $ */ 1/* $OpenBSD: auth2-hostbased.c,v 1.30 2017/05/30 14:29:59 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -57,9 +57,9 @@ extern u_char *session_id2;
57extern u_int session_id2_len; 57extern u_int session_id2_len;
58 58
59static int 59static int
60userauth_hostbased(Authctxt *authctxt) 60userauth_hostbased(struct ssh *ssh)
61{ 61{
62 struct ssh *ssh = active_state; /* XXX */ 62 Authctxt *authctxt = ssh->authctxt;
63 struct sshbuf *b; 63 struct sshbuf *b;
64 struct sshkey *key = NULL; 64 struct sshkey *key = NULL;
65 char *pkalg, *cuser, *chost, *service; 65 char *pkalg, *cuser, *chost, *service;
diff --git a/auth2-kbdint.c b/auth2-kbdint.c
index bf75c6059..86aad8ddc 100644
--- a/auth2-kbdint.c
+++ b/auth2-kbdint.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-kbdint.c,v 1.7 2014/07/15 15:54:14 millert Exp $ */ 1/* $OpenBSD: auth2-kbdint.c,v 1.8 2017/05/30 14:29:59 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -43,7 +43,7 @@
43extern ServerOptions options; 43extern ServerOptions options;
44 44
45static int 45static int
46userauth_kbdint(Authctxt *authctxt) 46userauth_kbdint(struct ssh *ssh)
47{ 47{
48 int authenticated = 0; 48 int authenticated = 0;
49 char *lang, *devs; 49 char *lang, *devs;
@@ -55,7 +55,7 @@ userauth_kbdint(Authctxt *authctxt)
55 debug("keyboard-interactive devs %s", devs); 55 debug("keyboard-interactive devs %s", devs);
56 56
57 if (options.challenge_response_authentication) 57 if (options.challenge_response_authentication)
58 authenticated = auth2_challenge(authctxt, devs); 58 authenticated = auth2_challenge(ssh, devs);
59 59
60 free(devs); 60 free(devs);
61 free(lang); 61 free(lang);
diff --git a/auth2-none.c b/auth2-none.c
index da6e2dd12..35d25fa63 100644
--- a/auth2-none.c
+++ b/auth2-none.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-none.c,v 1.19 2017/05/30 14:27:22 markus Exp $ */ 1/* $OpenBSD: auth2-none.c,v 1.20 2017/05/30 14:29:59 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -60,9 +60,8 @@ extern ServerOptions options;
60static int none_enabled = 1; 60static int none_enabled = 1;
61 61
62static int 62static int
63userauth_none(Authctxt *authctxt) 63userauth_none(struct ssh *ssh)
64{ 64{
65 struct ssh *ssh = active_state; /* XXX */
66 int r; 65 int r;
67 66
68 none_enabled = 0; 67 none_enabled = 0;
diff --git a/auth2-passwd.c b/auth2-passwd.c
index d36b0cba3..5f7ba3244 100644
--- a/auth2-passwd.c
+++ b/auth2-passwd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-passwd.c,v 1.13 2017/05/30 14:26:49 markus Exp $ */ 1/* $OpenBSD: auth2-passwd.c,v 1.14 2017/05/30 14:29:59 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -48,9 +48,8 @@
48extern ServerOptions options; 48extern ServerOptions options;
49 49
50static int 50static int
51userauth_passwd(Authctxt *authctxt) 51userauth_passwd(struct ssh *ssh)
52{ 52{
53 struct ssh *ssh = active_state; /* XXX */
54 char *password; 53 char *password;
55 int authenticated = 0, r; 54 int authenticated = 0, r;
56 u_char change; 55 u_char change;
diff --git a/auth2-pubkey.c b/auth2-pubkey.c
index a4a091113..7a6280f8d 100644
--- a/auth2-pubkey.c
+++ b/auth2-pubkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-pubkey.c,v 1.64 2017/05/30 14:10:53 markus Exp $ */ 1/* $OpenBSD: auth2-pubkey.c,v 1.65 2017/05/30 14:29:59 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -75,9 +75,9 @@ extern u_char *session_id2;
75extern u_int session_id2_len; 75extern u_int session_id2_len;
76 76
77static int 77static int
78userauth_pubkey(Authctxt *authctxt) 78userauth_pubkey(struct ssh *ssh)
79{ 79{
80 struct ssh *ssh = active_state; /* XXX */ 80 Authctxt *authctxt = ssh->authctxt;
81 struct sshbuf *b; 81 struct sshbuf *b;
82 struct sshkey *key = NULL; 82 struct sshkey *key = NULL;
83 char *pkalg, *userstyle = NULL, *fp = NULL; 83 char *pkalg, *userstyle = NULL, *fp = NULL;
diff --git a/auth2.c b/auth2.c
index cfbf9d250..08ea2a802 100644
--- a/auth2.c
+++ b/auth2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2.c,v 1.139 2017/05/30 14:23:52 markus Exp $ */ 1/* $OpenBSD: auth2.c,v 1.140 2017/05/30 14:29:59 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -170,9 +170,9 @@ do_authentication2(Authctxt *authctxt)
170{ 170{
171 struct ssh *ssh = active_state; /* XXX */ 171 struct ssh *ssh = active_state; /* XXX */
172 ssh->authctxt = authctxt; /* XXX move to caller */ 172 ssh->authctxt = authctxt; /* XXX move to caller */
173 dispatch_init(&dispatch_protocol_error); 173 ssh_dispatch_init(ssh, &dispatch_protocol_error);
174 dispatch_set(SSH2_MSG_SERVICE_REQUEST, &input_service_request); 174 ssh_dispatch_set(ssh, SSH2_MSG_SERVICE_REQUEST, &input_service_request);
175 dispatch_run(DISPATCH_BLOCK, &authctxt->success, ssh); 175 ssh_dispatch_run(ssh, DISPATCH_BLOCK, &authctxt->success, ssh);
176 ssh->authctxt = NULL; 176 ssh->authctxt = NULL;
177} 177}
178 178
@@ -193,7 +193,7 @@ input_service_request(int type, u_int32_t seq, struct ssh *ssh)
193 if (!authctxt->success) { 193 if (!authctxt->success) {
194 acceptit = 1; 194 acceptit = 1;
195 /* now we can handle user-auth requests */ 195 /* now we can handle user-auth requests */
196 dispatch_set(SSH2_MSG_USERAUTH_REQUEST, &input_userauth_request); 196 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_REQUEST, &input_userauth_request);
197 } 197 }
198 } 198 }
199 /* XXX all other service requests are denied */ 199 /* XXX all other service requests are denied */
@@ -269,12 +269,12 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh)
269 authctxt->user, authctxt->service, user, service); 269 authctxt->user, authctxt->service, user, service);
270 } 270 }
271 /* reset state */ 271 /* reset state */
272 auth2_challenge_stop(authctxt); 272 auth2_challenge_stop(ssh);
273 273
274#ifdef GSSAPI 274#ifdef GSSAPI
275 /* XXX move to auth2_gssapi_stop() */ 275 /* XXX move to auth2_gssapi_stop() */
276 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL); 276 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_TOKEN, NULL);
277 dispatch_set(SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE, NULL); 277 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE, NULL);
278#endif 278#endif
279 279
280 authctxt->postponed = 0; 280 authctxt->postponed = 0;
@@ -284,9 +284,9 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh)
284 m = authmethod_lookup(authctxt, method); 284 m = authmethod_lookup(authctxt, method);
285 if (m != NULL && authctxt->failures < options.max_authtries) { 285 if (m != NULL && authctxt->failures < options.max_authtries) {
286 debug2("input_userauth_request: try method %s", method); 286 debug2("input_userauth_request: try method %s", method);
287 authenticated = m->userauth(authctxt); 287 authenticated = m->userauth(ssh);
288 } 288 }
289 userauth_finish(authctxt, authenticated, method, NULL); 289 userauth_finish(ssh, authenticated, method, NULL);
290 290
291 free(service); 291 free(service);
292 free(user); 292 free(user);
@@ -295,10 +295,10 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh)
295} 295}
296 296
297void 297void
298userauth_finish(Authctxt *authctxt, int authenticated, const char *method, 298userauth_finish(struct ssh *ssh, int authenticated, const char *method,
299 const char *submethod) 299 const char *submethod)
300{ 300{
301 struct ssh *ssh = active_state; /* XXX */ 301 Authctxt *authctxt = ssh->authctxt;
302 char *methods; 302 char *methods;
303 int partial = 0; 303 int partial = 0;
304 304
@@ -354,7 +354,7 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
354 354
355 if (authenticated == 1) { 355 if (authenticated == 1) {
356 /* turn off userauth */ 356 /* turn off userauth */
357 dispatch_set(SSH2_MSG_USERAUTH_REQUEST, &dispatch_protocol_ignore); 357 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_REQUEST, &dispatch_protocol_ignore);
358 packet_start(SSH2_MSG_USERAUTH_SUCCESS); 358 packet_start(SSH2_MSG_USERAUTH_SUCCESS);
359 packet_send(); 359 packet_send();
360 packet_write_wait(); 360 packet_write_wait();