upstream commit

sshd: pass struct ssh to auth functions; ok djm@

Upstream-ID: b00a80c3460884ebcdd14ef550154c761aebe488
This commit is contained in:
markus@openbsd.org 2017-05-30 14:18:15 +00:00 committed by Damien Miller
parent 7da5df11ac
commit 5f4082d886
4 changed files with 25 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: auth2-chall.c,v 1.45 2017/05/30 08:49:58 markus Exp $ */ /* $OpenBSD: auth2-chall.c,v 1.46 2017/05/30 14:18:15 markus Exp $ */
/* /*
* Copyright (c) 2001 Markus Friedl. All rights reserved. * Copyright (c) 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2001 Per Allansson. All rights reserved. * Copyright (c) 2001 Per Allansson. All rights reserved.
@ -287,7 +287,8 @@ send_userauth_info_request(Authctxt *authctxt)
static int static int
input_userauth_info_response(int type, u_int32_t seq, void *ctxt) input_userauth_info_response(int type, u_int32_t seq, void *ctxt)
{ {
Authctxt *authctxt = ctxt; struct ssh *ssh = ctxt;
Authctxt *authctxt = ssh->authctxt;
KbdintAuthctxt *kbdintctxt; KbdintAuthctxt *kbdintctxt;
int authenticated = 0, res; int authenticated = 0, res;
u_int i, nresp; u_int i, nresp;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: auth2-gss.c,v 1.22 2015/01/19 20:07:45 markus Exp $ */ /* $OpenBSD: auth2-gss.c,v 1.23 2017/05/30 14:18:15 markus Exp $ */
/* /*
* Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
@ -129,7 +129,8 @@ userauth_gssapi(Authctxt *authctxt)
static int static int
input_gssapi_token(int type, u_int32_t plen, void *ctxt) input_gssapi_token(int type, u_int32_t plen, void *ctxt)
{ {
Authctxt *authctxt = ctxt; struct ssh *ssh = ctxt;
Authctxt *authctxt = ssh->authctxt;
Gssctxt *gssctxt; Gssctxt *gssctxt;
gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER; gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
gss_buffer_desc recv_tok; gss_buffer_desc recv_tok;
@ -184,7 +185,8 @@ input_gssapi_token(int type, u_int32_t plen, void *ctxt)
static int static int
input_gssapi_errtok(int type, u_int32_t plen, void *ctxt) input_gssapi_errtok(int type, u_int32_t plen, void *ctxt)
{ {
Authctxt *authctxt = ctxt; struct ssh *ssh = ctxt;
Authctxt *authctxt = ssh->authctxt;
Gssctxt *gssctxt; Gssctxt *gssctxt;
gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER; gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
gss_buffer_desc recv_tok; gss_buffer_desc recv_tok;
@ -225,7 +227,8 @@ input_gssapi_errtok(int type, u_int32_t plen, void *ctxt)
static int static int
input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt) input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt)
{ {
Authctxt *authctxt = ctxt; struct ssh *ssh = ctxt;
Authctxt *authctxt = ssh->authctxt;
int authenticated; int authenticated;
if (authctxt == NULL || (authctxt->methoddata == NULL && !use_privsep)) if (authctxt == NULL || (authctxt->methoddata == NULL && !use_privsep))
@ -252,7 +255,8 @@ input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt)
static int static int
input_gssapi_mic(int type, u_int32_t plen, void *ctxt) input_gssapi_mic(int type, u_int32_t plen, void *ctxt)
{ {
Authctxt *authctxt = ctxt; struct ssh *ssh = ctxt;
Authctxt *authctxt = ssh->authctxt;
Gssctxt *gssctxt; Gssctxt *gssctxt;
int authenticated = 0; int authenticated = 0;
Buffer b; Buffer b;

14
auth2.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: auth2.c,v 1.137 2017/02/03 23:05:57 djm Exp $ */ /* $OpenBSD: auth2.c,v 1.138 2017/05/30 14:18:15 markus Exp $ */
/* /*
* Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2000 Markus Friedl. All rights reserved.
* *
@ -168,16 +168,20 @@ done:
void void
do_authentication2(Authctxt *authctxt) do_authentication2(Authctxt *authctxt)
{ {
struct ssh *ssh = active_state; /* XXX */
ssh->authctxt = authctxt; /* XXX move to caller */
dispatch_init(&dispatch_protocol_error); dispatch_init(&dispatch_protocol_error);
dispatch_set(SSH2_MSG_SERVICE_REQUEST, &input_service_request); dispatch_set(SSH2_MSG_SERVICE_REQUEST, &input_service_request);
dispatch_run(DISPATCH_BLOCK, &authctxt->success, authctxt); dispatch_run(DISPATCH_BLOCK, &authctxt->success, ssh);
ssh->authctxt = NULL;
} }
/*ARGSUSED*/ /*ARGSUSED*/
static int static int
input_service_request(int type, u_int32_t seq, void *ctxt) input_service_request(int type, u_int32_t seq, void *ctxt)
{ {
Authctxt *authctxt = ctxt; struct ssh *ssh = ctxt;
Authctxt *authctxt = ssh->authctxt;
u_int len; u_int len;
int acceptit = 0; int acceptit = 0;
char *service = packet_get_cstring(&len); char *service = packet_get_cstring(&len);
@ -212,8 +216,8 @@ input_service_request(int type, u_int32_t seq, void *ctxt)
static int static int
input_userauth_request(int type, u_int32_t seq, void *ctxt) input_userauth_request(int type, u_int32_t seq, void *ctxt)
{ {
struct ssh *ssh = active_state; /* XXX */ struct ssh *ssh = ctxt;
Authctxt *authctxt = ctxt; Authctxt *authctxt = ssh->authctxt;
Authmethod *m = NULL; Authmethod *m = NULL;
char *user, *service, *method, *style = NULL; char *user, *service, *method, *style = NULL;
int authenticated = 0; int authenticated = 0;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: packet.h,v 1.79 2017/05/03 21:08:09 naddy Exp $ */ /* $OpenBSD: packet.h,v 1.80 2017/05/30 14:18:15 markus Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
@ -77,6 +77,9 @@ struct ssh {
TAILQ_HEAD(, key_entry) private_keys; TAILQ_HEAD(, key_entry) private_keys;
TAILQ_HEAD(, key_entry) public_keys; TAILQ_HEAD(, key_entry) public_keys;
/* Client/Server authentication context */
void *authctxt;
/* APP data */ /* APP data */
void *app_data; void *app_data;
}; };