comparison cli-tcpfwd.c @ 1069:2fa71c3b2827 pam

merge pam branch up to date
author Matt Johnston <matt@ucc.asn.au>
date Mon, 16 Mar 2015 21:34:05 +0800
parents 0da8ba489c23
children c45d65392c1a
comparison
equal deleted inserted replaced
1068:9a6395ddb1b6 1069:2fa71c3b2827
28 #include "tcpfwd.h" 28 #include "tcpfwd.h"
29 #include "channel.h" 29 #include "channel.h"
30 #include "runopts.h" 30 #include "runopts.h"
31 #include "session.h" 31 #include "session.h"
32 #include "ssh.h" 32 #include "ssh.h"
33 #include "netio.h"
33 34
34 #ifdef ENABLE_CLI_REMOTETCPFWD 35 #ifdef ENABLE_CLI_REMOTETCPFWD
35 static int newtcpforwarded(struct Channel * channel); 36 static int newtcpforwarded(struct Channel * channel);
36 37
37 const struct ChanType cli_chan_tcpremote = { 38 const struct ChanType cli_chan_tcpremote = {
213 char *origaddr = NULL; 214 char *origaddr = NULL;
214 unsigned int origport; 215 unsigned int origport;
215 m_list_elem * iter = NULL; 216 m_list_elem * iter = NULL;
216 struct TCPFwdEntry *fwd; 217 struct TCPFwdEntry *fwd;
217 char portstring[NI_MAXSERV]; 218 char portstring[NI_MAXSERV];
218 int sock;
219 int err = SSH_OPEN_ADMINISTRATIVELY_PROHIBITED; 219 int err = SSH_OPEN_ADMINISTRATIVELY_PROHIBITED;
220 220
221 origaddr = buf_getstring(ses.payload, NULL); 221 origaddr = buf_getstring(ses.payload, NULL);
222 origport = buf_getint(ses.payload); 222 origport = buf_getint(ses.payload);
223 223
252 origaddr, origport); 252 origaddr, origport);
253 goto out; 253 goto out;
254 } 254 }
255 255
256 snprintf(portstring, sizeof(portstring), "%d", fwd->connectport); 256 snprintf(portstring, sizeof(portstring), "%d", fwd->connectport);
257 sock = connect_remote(fwd->connectaddr, portstring, 1, NULL); 257 channel->conn_pending = connect_remote(fwd->connectaddr, portstring, channel_connect_done, channel);
258 if (sock < 0) {
259 TRACE(("leave newtcpdirect: sock failed"))
260 err = SSH_OPEN_CONNECT_FAILED;
261 goto out;
262 }
263
264 ses.maxfd = MAX(ses.maxfd, sock);
265
266 /* We don't set readfd, that will get set after the connection's
267 * progress succeeds */
268 channel->writefd = sock;
269 channel->initconn = 1;
270 258
271 channel->prio = DROPBEAR_CHANNEL_PRIO_UNKNOWABLE; 259 channel->prio = DROPBEAR_CHANNEL_PRIO_UNKNOWABLE;
272 260
273 err = SSH_OPEN_IN_PROGRESS; 261 err = SSH_OPEN_IN_PROGRESS;
274 262