diff options
author | Damien Miller <djm@mindrot.org> | 2001-12-21 14:58:35 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2001-12-21 14:58:35 +1100 |
commit | e737856350287104a12f5a97c81fad1f7bcd7096 (patch) | |
tree | 7d65ebfd3156be17043fa01341feba379f8d10d2 /channels.c | |
parent | 5a6b4fe22583394886092aad5787b5fa8355276e (diff) |
- markus@cvs.openbsd.org 2001/12/20 16:37:29
[channels.c channels.h session.c]
setup x11 listen socket for just one connect if the client requests so.
(v2 only, but the openssh client does not support this feature).
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/channels.c b/channels.c index 63eb5bcff..340b10646 100644 --- a/channels.c +++ b/channels.c | |||
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include "includes.h" | 41 | #include "includes.h" |
42 | RCSID("$OpenBSD: channels.c,v 1.148 2001/12/19 07:18:56 deraadt Exp $"); | 42 | RCSID("$OpenBSD: channels.c,v 1.149 2001/12/20 16:37:29 markus Exp $"); |
43 | 43 | ||
44 | #include "ssh.h" | 44 | #include "ssh.h" |
45 | #include "ssh1.h" | 45 | #include "ssh1.h" |
@@ -263,6 +263,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd, | |||
263 | c->cb_arg = NULL; | 263 | c->cb_arg = NULL; |
264 | c->cb_event = 0; | 264 | c->cb_event = 0; |
265 | c->force_drain = 0; | 265 | c->force_drain = 0; |
266 | c->single_connection = 0; | ||
266 | c->detach_user = NULL; | 267 | c->detach_user = NULL; |
267 | c->input_filter = NULL; | 268 | c->input_filter = NULL; |
268 | debug("channel %d: new [%s]", found, remote_name); | 269 | debug("channel %d: new [%s]", found, remote_name); |
@@ -1003,6 +1004,11 @@ channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) | |||
1003 | debug("X11 connection requested."); | 1004 | debug("X11 connection requested."); |
1004 | addrlen = sizeof(addr); | 1005 | addrlen = sizeof(addr); |
1005 | newsock = accept(c->sock, &addr, &addrlen); | 1006 | newsock = accept(c->sock, &addr, &addrlen); |
1007 | if (c->single_connection) { | ||
1008 | debug("single_connection: closing X11 listener."); | ||
1009 | channel_close_fd(&c->sock); | ||
1010 | chan_mark_dead(c); | ||
1011 | } | ||
1006 | if (newsock < 0) { | 1012 | if (newsock < 0) { |
1007 | error("accept: %.100s", strerror(errno)); | 1013 | error("accept: %.100s", strerror(errno)); |
1008 | return; | 1014 | return; |
@@ -1029,8 +1035,8 @@ channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) | |||
1029 | packet_start(SSH2_MSG_CHANNEL_OPEN); | 1035 | packet_start(SSH2_MSG_CHANNEL_OPEN); |
1030 | packet_put_cstring("x11"); | 1036 | packet_put_cstring("x11"); |
1031 | packet_put_int(nc->self); | 1037 | packet_put_int(nc->self); |
1032 | packet_put_int(c->local_window_max); | 1038 | packet_put_int(nc->local_window_max); |
1033 | packet_put_int(c->local_maxpacket); | 1039 | packet_put_int(nc->local_maxpacket); |
1034 | /* originator ipaddr and port */ | 1040 | /* originator ipaddr and port */ |
1035 | packet_put_cstring(remote_ipaddr); | 1041 | packet_put_cstring(remote_ipaddr); |
1036 | if (datafellows & SSH_BUG_X11FWD) { | 1042 | if (datafellows & SSH_BUG_X11FWD) { |
@@ -2405,8 +2411,10 @@ channel_connect_to(const char *host, u_short port) | |||
2405 | * an error occurs. | 2411 | * an error occurs. |
2406 | */ | 2412 | */ |
2407 | int | 2413 | int |
2408 | x11_create_display_inet(int x11_display_offset, int gateway_ports) | 2414 | x11_create_display_inet(int x11_display_offset, int gateway_ports, |
2415 | int single_connection) | ||
2409 | { | 2416 | { |
2417 | Channel *nc = NULL; | ||
2410 | int display_number, sock; | 2418 | int display_number, sock; |
2411 | u_short port; | 2419 | u_short port; |
2412 | struct addrinfo hints, *ai, *aitop; | 2420 | struct addrinfo hints, *ai, *aitop; |
@@ -2482,10 +2490,12 @@ x11_create_display_inet(int x11_display_offset, int gateway_ports) | |||
2482 | /* Allocate a channel for each socket. */ | 2490 | /* Allocate a channel for each socket. */ |
2483 | for (n = 0; n < num_socks; n++) { | 2491 | for (n = 0; n < num_socks; n++) { |
2484 | sock = socks[n]; | 2492 | sock = socks[n]; |
2485 | (void) channel_new("x11 listener", | 2493 | nc = channel_new("x11 listener", |
2486 | SSH_CHANNEL_X11_LISTENER, sock, sock, -1, | 2494 | SSH_CHANNEL_X11_LISTENER, sock, sock, -1, |
2487 | CHAN_X11_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, | 2495 | CHAN_X11_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, |
2488 | 0, xstrdup("X11 inet listener"), 1); | 2496 | 0, xstrdup("X11 inet listener"), 1); |
2497 | if (nc != NULL) | ||
2498 | nc->single_connection = single_connection; | ||
2489 | } | 2499 | } |
2490 | 2500 | ||
2491 | /* Return the display number for the DISPLAY environment variable. */ | 2501 | /* Return the display number for the DISPLAY environment variable. */ |