comparison svr-x11fwd.c @ 62:20563735e8b5

just checkpointing
author Matt Johnston <matt@ucc.asn.au>
date Tue, 10 Aug 2004 17:09:52 +0000
parents db2c8e6fb284
children b0316ce64e4b
comparison
equal deleted inserted replaced
61:3a4f0ef1e8c3 62:20563735e8b5
35 #include "buffer.h" 35 #include "buffer.h"
36 36
37 #define X11BASEPORT 6000 37 #define X11BASEPORT 6000
38 #define X11BINDBASE 6010 38 #define X11BINDBASE 6010
39 39
40 static void x11accept(struct Listener* listener); 40 static void x11accept(struct Listener* listener, int sock);
41 static int bindport(int fd); 41 static int bindport(int fd);
42 static int send_msg_channel_open_x11(int fd, struct sockaddr_in* addr); 42 static int send_msg_channel_open_x11(int fd, struct sockaddr_in* addr);
43 43
44 /* called as a request for a session channel, sets up listening X11 */ 44 /* called as a request for a session channel, sets up listening X11 */
45 /* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ 45 /* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
80 } 80 }
81 81
82 /* listener code will handle the socket now. 82 /* listener code will handle the socket now.
83 * No cleanup handler needed, since listener_remove only happens 83 * No cleanup handler needed, since listener_remove only happens
84 * from our cleanup anyway */ 84 * from our cleanup anyway */
85 chansess->x11listener = new_listener( fd, 0, chansess, x11accept, NULL); 85 chansess->x11listener = new_listener( &fd, 1, 0, chansess, x11accept, NULL);
86 if (chansess->x11listener == NULL) { 86 if (chansess->x11listener == NULL) {
87 goto fail; 87 goto fail;
88 } 88 }
89 89
90 return DROPBEAR_SUCCESS; 90 return DROPBEAR_SUCCESS;
98 return DROPBEAR_FAILURE; 98 return DROPBEAR_FAILURE;
99 } 99 }
100 100
101 /* accepts a new X11 socket */ 101 /* accepts a new X11 socket */
102 /* returns DROPBEAR_FAILURE or DROPBEAR_SUCCESS */ 102 /* returns DROPBEAR_FAILURE or DROPBEAR_SUCCESS */
103 static void x11accept(struct Listener* listener) { 103 static void x11accept(struct Listener* listener, int sock) {
104 104
105 int fd; 105 int fd;
106 struct sockaddr_in addr; 106 struct sockaddr_in addr;
107 int len; 107 int len;
108 int ret; 108 int ret;
109 struct ChanSess * chansess = (struct ChanSess *)(listener->typedata); 109 struct ChanSess * chansess = (struct ChanSess *)(listener->typedata);
110 110
111 len = sizeof(addr); 111 len = sizeof(addr);
112 112
113 fd = accept(listener->sock, (struct sockaddr*)&addr, &len); 113 fd = accept(sock, (struct sockaddr*)&addr, &len);
114 if (fd < 0) { 114 if (fd < 0) {
115 return; 115 return;
116 } 116 }
117 117
118 /* if single-connection we close it up */ 118 /* if single-connection we close it up */