Skip to content

Commit 2ae666a

Browse files
mfriedldjmdjm
authored andcommitted
upstream commit
protocol handlers all get struct ssh passed; ok djm@ Upstream-ID: 0ca9ea2a5d01a6d2ded94c5024456a930c5bfb5d
1 parent 94583be commit 2ae666a

18 files changed

+127
-156
lines changed

auth2-chall.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: auth2-chall.c,v 1.46 2017/05/30 14:18:15 markus Exp $ */
1+
/* $OpenBSD: auth2-chall.c,v 1.47 2017/05/30 14:23:52 markus Exp $ */
22
/*
33
* Copyright (c) 2001 Markus Friedl. All rights reserved.
44
* Copyright (c) 2001 Per Allansson. All rights reserved.
@@ -49,7 +49,7 @@ extern ServerOptions options;
4949

5050
static int auth2_challenge_start(Authctxt *);
5151
static int send_userauth_info_request(Authctxt *);
52-
static int input_userauth_info_response(int, u_int32_t, void *);
52+
static int input_userauth_info_response(int, u_int32_t, struct ssh *);
5353

5454
#ifdef BSD_AUTH
5555
extern KbdintDevice bsdauth_device;
@@ -285,9 +285,8 @@ send_userauth_info_request(Authctxt *authctxt)
285285
}
286286

287287
static int
288-
input_userauth_info_response(int type, u_int32_t seq, void *ctxt)
288+
input_userauth_info_response(int type, u_int32_t seq, struct ssh *ssh)
289289
{
290-
struct ssh *ssh = ctxt;
291290
Authctxt *authctxt = ssh->authctxt;
292291
KbdintAuthctxt *kbdintctxt;
293292
int authenticated = 0, res;

auth2-gss.c

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: auth2-gss.c,v 1.23 2017/05/30 14:18:15 markus Exp $ */
1+
/* $OpenBSD: auth2-gss.c,v 1.24 2017/05/30 14:23:52 markus Exp $ */
22

33
/*
44
* Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
@@ -48,10 +48,10 @@
4848

4949
extern ServerOptions options;
5050

51-
static int input_gssapi_token(int type, u_int32_t plen, void *ctxt);
52-
static int input_gssapi_mic(int type, u_int32_t plen, void *ctxt);
53-
static int input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt);
54-
static int input_gssapi_errtok(int, u_int32_t, void *);
51+
static int input_gssapi_token(int type, u_int32_t plen, struct ssh *ssh);
52+
static int input_gssapi_mic(int type, u_int32_t plen, struct ssh *ssh);
53+
static int input_gssapi_exchange_complete(int type, u_int32_t plen, struct ssh *ssh);
54+
static int input_gssapi_errtok(int, u_int32_t, struct ssh *);
5555

5656
/*
5757
* We only support those mechanisms that we know about (ie ones that we know
@@ -127,9 +127,8 @@ userauth_gssapi(Authctxt *authctxt)
127127
}
128128

129129
static int
130-
input_gssapi_token(int type, u_int32_t plen, void *ctxt)
130+
input_gssapi_token(int type, u_int32_t plen, struct ssh *ssh)
131131
{
132-
struct ssh *ssh = ctxt;
133132
Authctxt *authctxt = ssh->authctxt;
134133
Gssctxt *gssctxt;
135134
gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
@@ -183,9 +182,8 @@ input_gssapi_token(int type, u_int32_t plen, void *ctxt)
183182
}
184183

185184
static int
186-
input_gssapi_errtok(int type, u_int32_t plen, void *ctxt)
185+
input_gssapi_errtok(int type, u_int32_t plen, struct ssh *ssh)
187186
{
188-
struct ssh *ssh = ctxt;
189187
Authctxt *authctxt = ssh->authctxt;
190188
Gssctxt *gssctxt;
191189
gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
@@ -225,9 +223,8 @@ input_gssapi_errtok(int type, u_int32_t plen, void *ctxt)
225223
*/
226224

227225
static int
228-
input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt)
226+
input_gssapi_exchange_complete(int type, u_int32_t plen, struct ssh *ssh)
229227
{
230-
struct ssh *ssh = ctxt;
231228
Authctxt *authctxt = ssh->authctxt;
232229
int authenticated;
233230

@@ -253,9 +250,8 @@ input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt)
253250
}
254251

255252
static int
256-
input_gssapi_mic(int type, u_int32_t plen, void *ctxt)
253+
input_gssapi_mic(int type, u_int32_t plen, struct ssh *ssh)
257254
{
258-
struct ssh *ssh = ctxt;
259255
Authctxt *authctxt = ssh->authctxt;
260256
Gssctxt *gssctxt;
261257
int authenticated = 0;

auth2.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: auth2.c,v 1.138 2017/05/30 14:18:15 markus Exp $ */
1+
/* $OpenBSD: auth2.c,v 1.139 2017/05/30 14:23:52 markus Exp $ */
22
/*
33
* Copyright (c) 2000 Markus Friedl. All rights reserved.
44
*
@@ -87,8 +87,8 @@ Authmethod *authmethods[] = {
8787

8888
/* protocol */
8989

90-
static int input_service_request(int, u_int32_t, void *);
91-
static int input_userauth_request(int, u_int32_t, void *);
90+
static int input_service_request(int, u_int32_t, struct ssh *);
91+
static int input_userauth_request(int, u_int32_t, struct ssh *);
9292

9393
/* helper */
9494
static Authmethod *authmethod_lookup(Authctxt *, const char *);
@@ -178,9 +178,8 @@ do_authentication2(Authctxt *authctxt)
178178

179179
/*ARGSUSED*/
180180
static int
181-
input_service_request(int type, u_int32_t seq, void *ctxt)
181+
input_service_request(int type, u_int32_t seq, struct ssh *ssh)
182182
{
183-
struct ssh *ssh = ctxt;
184183
Authctxt *authctxt = ssh->authctxt;
185184
u_int len;
186185
int acceptit = 0;
@@ -214,9 +213,8 @@ input_service_request(int type, u_int32_t seq, void *ctxt)
214213

215214
/*ARGSUSED*/
216215
static int
217-
input_userauth_request(int type, u_int32_t seq, void *ctxt)
216+
input_userauth_request(int type, u_int32_t seq, struct ssh *ssh)
218217
{
219-
struct ssh *ssh = ctxt;
220218
Authctxt *authctxt = ssh->authctxt;
221219
Authmethod *m = NULL;
222220
char *user, *service, *method, *style = NULL;

channels.c

+18-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: channels.c,v 1.362 2017/05/30 08:49:58 markus Exp $ */
1+
/* $OpenBSD: channels.c,v 1.363 2017/05/30 14:23:52 markus Exp $ */
22
/*
33
* Author: Tatu Ylonen <[email protected]>
44
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
@@ -2394,9 +2394,8 @@ channel_proxy_downstream(Channel *downstream)
23942394
* replaces local (proxy) channel ID with downstream channel ID.
23952395
*/
23962396
int
2397-
channel_proxy_upstream(Channel *c, int type, u_int32_t seq, void *ctxt)
2397+
channel_proxy_upstream(Channel *c, int type, u_int32_t seq, struct ssh *ssh)
23982398
{
2399-
struct ssh *ssh = active_state;
24002399
struct sshbuf *b = NULL;
24012400
Channel *downstream;
24022401
const u_char *cp = NULL;
@@ -2476,7 +2475,7 @@ channel_proxy_upstream(Channel *c, int type, u_int32_t seq, void *ctxt)
24762475

24772476
/* ARGSUSED */
24782477
int
2479-
channel_input_data(int type, u_int32_t seq, void *ctxt)
2478+
channel_input_data(int type, u_int32_t seq, struct ssh *ssh)
24802479
{
24812480
int id;
24822481
const u_char *data;
@@ -2488,7 +2487,7 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
24882487
c = channel_lookup(id);
24892488
if (c == NULL)
24902489
packet_disconnect("Received data for nonexistent channel %d.", id);
2491-
if (channel_proxy_upstream(c, type, seq, ctxt))
2490+
if (channel_proxy_upstream(c, type, seq, ssh))
24922491
return 0;
24932492

24942493
/* Ignore any data for non-open channels (might happen on close) */
@@ -2536,7 +2535,7 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
25362535

25372536
/* ARGSUSED */
25382537
int
2539-
channel_input_extended_data(int type, u_int32_t seq, void *ctxt)
2538+
channel_input_extended_data(int type, u_int32_t seq, struct ssh *ssh)
25402539
{
25412540
int id;
25422541
char *data;
@@ -2549,7 +2548,7 @@ channel_input_extended_data(int type, u_int32_t seq, void *ctxt)
25492548

25502549
if (c == NULL)
25512550
packet_disconnect("Received extended_data for bad channel %d.", id);
2552-
if (channel_proxy_upstream(c, type, seq, ctxt))
2551+
if (channel_proxy_upstream(c, type, seq, ssh))
25532552
return 0;
25542553
if (c->type != SSH_CHANNEL_OPEN) {
25552554
logit("channel %d: ext data for non open", id);
@@ -2586,7 +2585,7 @@ channel_input_extended_data(int type, u_int32_t seq, void *ctxt)
25862585

25872586
/* ARGSUSED */
25882587
int
2589-
channel_input_ieof(int type, u_int32_t seq, void *ctxt)
2588+
channel_input_ieof(int type, u_int32_t seq, struct ssh *ssh)
25902589
{
25912590
int id;
25922591
Channel *c;
@@ -2596,7 +2595,7 @@ channel_input_ieof(int type, u_int32_t seq, void *ctxt)
25962595
c = channel_lookup(id);
25972596
if (c == NULL)
25982597
packet_disconnect("Received ieof for nonexistent channel %d.", id);
2599-
if (channel_proxy_upstream(c, type, seq, ctxt))
2598+
if (channel_proxy_upstream(c, type, seq, ssh))
26002599
return 0;
26012600
chan_rcvd_ieof(c);
26022601

@@ -2612,14 +2611,14 @@ channel_input_ieof(int type, u_int32_t seq, void *ctxt)
26122611

26132612
/* ARGSUSED */
26142613
int
2615-
channel_input_oclose(int type, u_int32_t seq, void *ctxt)
2614+
channel_input_oclose(int type, u_int32_t seq, struct ssh *ssh)
26162615
{
26172616
int id = packet_get_int();
26182617
Channel *c = channel_lookup(id);
26192618

26202619
if (c == NULL)
26212620
packet_disconnect("Received oclose for nonexistent channel %d.", id);
2622-
if (channel_proxy_upstream(c, type, seq, ctxt))
2621+
if (channel_proxy_upstream(c, type, seq, ssh))
26232622
return 0;
26242623
packet_check_eom();
26252624
chan_rcvd_oclose(c);
@@ -2628,7 +2627,7 @@ channel_input_oclose(int type, u_int32_t seq, void *ctxt)
26282627

26292628
/* ARGSUSED */
26302629
int
2631-
channel_input_open_confirmation(int type, u_int32_t seq, void *ctxt)
2630+
channel_input_open_confirmation(int type, u_int32_t seq, struct ssh *ssh)
26322631
{
26332632
int id, remote_id;
26342633
Channel *c;
@@ -2639,7 +2638,7 @@ channel_input_open_confirmation(int type, u_int32_t seq, void *ctxt)
26392638
if (c==NULL)
26402639
packet_disconnect("Received open confirmation for "
26412640
"unknown channel %d.", id);
2642-
if (channel_proxy_upstream(c, type, seq, ctxt))
2641+
if (channel_proxy_upstream(c, type, seq, ssh))
26432642
return 0;
26442643
if (c->type != SSH_CHANNEL_OPENING)
26452644
packet_disconnect("Received open confirmation for "
@@ -2680,7 +2679,7 @@ reason2txt(int reason)
26802679

26812680
/* ARGSUSED */
26822681
int
2683-
channel_input_open_failure(int type, u_int32_t seq, void *ctxt)
2682+
channel_input_open_failure(int type, u_int32_t seq, struct ssh *ssh)
26842683
{
26852684
int id, reason;
26862685
char *msg = NULL, *lang = NULL;
@@ -2692,7 +2691,7 @@ channel_input_open_failure(int type, u_int32_t seq, void *ctxt)
26922691
if (c==NULL)
26932692
packet_disconnect("Received open failure for "
26942693
"unknown channel %d.", id);
2695-
if (channel_proxy_upstream(c, type, seq, ctxt))
2694+
if (channel_proxy_upstream(c, type, seq, ssh))
26962695
return 0;
26972696
if (c->type != SSH_CHANNEL_OPENING)
26982697
packet_disconnect("Received open failure for "
@@ -2719,7 +2718,7 @@ channel_input_open_failure(int type, u_int32_t seq, void *ctxt)
27192718

27202719
/* ARGSUSED */
27212720
int
2722-
channel_input_window_adjust(int type, u_int32_t seq, void *ctxt)
2721+
channel_input_window_adjust(int type, u_int32_t seq, struct ssh *ssh)
27232722
{
27242723
Channel *c;
27252724
int id;
@@ -2733,7 +2732,7 @@ channel_input_window_adjust(int type, u_int32_t seq, void *ctxt)
27332732
logit("Received window adjust for non-open channel %d.", id);
27342733
return 0;
27352734
}
2736-
if (channel_proxy_upstream(c, type, seq, ctxt))
2735+
if (channel_proxy_upstream(c, type, seq, ssh))
27372736
return 0;
27382737
adjust = packet_get_int();
27392738
packet_check_eom();
@@ -2747,7 +2746,7 @@ channel_input_window_adjust(int type, u_int32_t seq, void *ctxt)
27472746

27482747
/* ARGSUSED */
27492748
int
2750-
channel_input_status_confirm(int type, u_int32_t seq, void *ctxt)
2749+
channel_input_status_confirm(int type, u_int32_t seq, struct ssh *ssh)
27512750
{
27522751
Channel *c;
27532752
struct channel_confirm *cc;
@@ -2763,7 +2762,7 @@ channel_input_status_confirm(int type, u_int32_t seq, void *ctxt)
27632762
logit("channel_input_status_confirm: %d: unknown", id);
27642763
return 0;
27652764
}
2766-
if (channel_proxy_upstream(c, type, seq, ctxt))
2765+
if (channel_proxy_upstream(c, type, seq, ssh))
27672766
return 0;
27682767
packet_check_eom();
27692768
if ((cc = TAILQ_FIRST(&c->status_confirms)) == NULL)

channels.h

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: channels.h,v 1.125 2017/05/26 19:35:50 markus Exp $ */
1+
/* $OpenBSD: channels.h,v 1.126 2017/05/30 14:23:52 markus Exp $ */
22

33
/*
44
* Author: Tatu Ylonen <[email protected]>
@@ -61,6 +61,7 @@
6161

6262
#define CHANNEL_CANCEL_PORT_STATIC -1
6363

64+
struct ssh;
6465
struct Channel;
6566
typedef struct Channel Channel;
6667

@@ -232,18 +233,19 @@ void channel_send_window_changes(void);
232233
/* mux proxy support */
233234

234235
int channel_proxy_downstream(Channel *mc);
235-
int channel_proxy_upstream(Channel *, int, u_int32_t, void *);
236+
int channel_proxy_upstream(Channel *, int, u_int32_t, struct ssh *);
236237

237238
/* protocol handler */
238239

239-
int channel_input_data(int, u_int32_t, void *);
240-
int channel_input_extended_data(int, u_int32_t, void *);
241-
int channel_input_ieof(int, u_int32_t, void *);
242-
int channel_input_oclose(int, u_int32_t, void *);
243-
int channel_input_open_confirmation(int, u_int32_t, void *);
244-
int channel_input_open_failure(int, u_int32_t, void *);
245-
int channel_input_window_adjust(int, u_int32_t, void *);
246-
int channel_input_status_confirm(int, u_int32_t, void *);
240+
int channel_input_data(int, u_int32_t, struct ssh *);
241+
int channel_input_extended_data(int, u_int32_t, struct ssh *);
242+
int channel_input_ieof(int, u_int32_t, struct ssh *);
243+
int channel_input_oclose(int, u_int32_t, struct ssh *);
244+
int channel_input_open_confirmation(int, u_int32_t, struct ssh *);
245+
int channel_input_open_failure(int, u_int32_t, struct ssh *);
246+
int channel_input_port_open(int, u_int32_t, struct ssh *);
247+
int channel_input_window_adjust(int, u_int32_t, struct ssh *);
248+
int channel_input_status_confirm(int, u_int32_t, struct ssh *);
247249

248250
/* file descriptor handling (read/write) */
249251

clientloop.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: clientloop.c,v 1.296 2017/05/03 21:08:09 naddy Exp $ */
1+
/* $OpenBSD: clientloop.c,v 1.297 2017/05/30 14:23:52 markus Exp $ */
22
/*
33
* Author: Tatu Ylonen <[email protected]>
44
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
@@ -459,7 +459,7 @@ client_check_window_change(void)
459459
}
460460

461461
static int
462-
client_global_request_reply(int type, u_int32_t seq, void *ctxt)
462+
client_global_request_reply(int type, u_int32_t seq, struct ssh *ssh)
463463
{
464464
struct global_confirm *gc;
465465

@@ -1642,7 +1642,7 @@ client_request_tun_fwd(int tun_mode, int local_tun, int remote_tun)
16421642

16431643
/* XXXX move to generic input handler */
16441644
static int
1645-
client_input_channel_open(int type, u_int32_t seq, void *ctxt)
1645+
client_input_channel_open(int type, u_int32_t seq, struct ssh *ssh)
16461646
{
16471647
Channel *c = NULL;
16481648
char *ctype;
@@ -1698,15 +1698,15 @@ client_input_channel_open(int type, u_int32_t seq, void *ctxt)
16981698
}
16991699

17001700
static int
1701-
client_input_channel_req(int type, u_int32_t seq, void *ctxt)
1701+
client_input_channel_req(int type, u_int32_t seq, struct ssh *ssh)
17021702
{
17031703
Channel *c = NULL;
17041704
int exitval, id, reply, success = 0;
17051705
char *rtype;
17061706

17071707
id = packet_get_int();
17081708
c = channel_lookup(id);
1709-
if (channel_proxy_upstream(c, type, seq, ctxt))
1709+
if (channel_proxy_upstream(c, type, seq, ssh))
17101710
return 0;
17111711
rtype = packet_get_string(NULL);
17121712
reply = packet_get_char();
@@ -2136,7 +2136,7 @@ client_input_hostkeys(void)
21362136
}
21372137

21382138
static int
2139-
client_input_global_request(int type, u_int32_t seq, void *ctxt)
2139+
client_input_global_request(int type, u_int32_t seq, struct ssh *ssh)
21402140
{
21412141
char *rtype;
21422142
int want_reply;

0 commit comments

Comments
 (0)