# HG changeset patch # User Matt Johnston # Date 1086286114 0 # Node ID db2c8e6fb28460f8604e3cf327cf4e0168e5d4fa # Parent 7a37cff272584a1368a18487c1711b865412a8e7 Fixed stupid agentfwd error (using the listening FD, not the accepted on. gah) diff -r 7a37cff27258 -r db2c8e6fb284 channel.h --- a/channel.h Thu Jun 03 17:29:17 2004 +0000 +++ b/channel.h Thu Jun 03 18:08:34 2004 +0000 @@ -50,12 +50,6 @@ #define RECV_MAXPACKET 1400 /* tweak */ #define RECV_MINWINDOW 19000 /* when we get below this, we send a windowadjust */ -/* a simpler way to define that we need code for listeners */ -#if !defined(DISABLE_X11FWD) || !defined(DISABLE_AUTHFWD) || \ - !defined(DISABLE_REMOTETCPFWD) -#define USE_LISTENERS -#endif - struct ChanType; struct Channel { @@ -113,7 +107,7 @@ void recv_msg_channel_close(); void recv_msg_channel_eof(); -#ifdef USE_LISTENERS +#ifdef USING_LISTENERS int send_msg_channel_open_init(int fd, const struct ChanType *type); void recv_msg_channel_open_confirmation(); void recv_msg_channel_open_failure(); diff -r 7a37cff27258 -r db2c8e6fb284 common-channel.c --- a/common-channel.c Thu Jun 03 17:29:17 2004 +0000 +++ b/common-channel.c Thu Jun 03 18:08:34 2004 +0000 @@ -607,7 +607,7 @@ /* on error/eof, send eof */ if (len == 0 || errno != EINTR) { closeoutfd(channel, fd); - TRACE(("leave send_msg_channel_data: read err")); + TRACE(("leave send_msg_channel_data: read err %d", channel->index)); } buf_free(buf); return; @@ -889,7 +889,7 @@ TRACE(("leave send_msg_channel_open_confirmation")); } -#ifdef USE_LISTENERS +#ifdef USING_LISTENERS /* Create a new channel, and start the open request. This is intended * for X11, agent, tcp forwarding, and should be filled with channel-specific * options, with the calling function calling encrypt_packet() after @@ -946,7 +946,10 @@ channel->remotechan = buf_getint(ses.payload); channel->transwindow = buf_getint(ses.payload); channel->transmaxpacket = buf_getint(ses.payload); + + TRACE(("new chan remote %d localho %d", channel->remotechan, chan)); + TRACE(("leave recv_msg_channel_open_confirmation")); } @@ -1012,4 +1015,4 @@ } } -#endif /* USE_LISTENERS */ +#endif /* USING_LISTENERS */ diff -r 7a37cff27258 -r db2c8e6fb284 listener.c --- a/listener.c Thu Jun 03 17:29:17 2004 +0000 +++ b/listener.c Thu Jun 03 18:08:34 2004 +0000 @@ -3,7 +3,7 @@ #include "session.h" #include "dbutil.h" -void listener_initialise() { +void listeners_initialise() { /* just one slot to start with */ ses.listeners = (struct Listener**)m_malloc(sizeof(struct Listener*)); @@ -21,6 +21,7 @@ for (i = 0; i < ses.listensize; i++) { listener = ses.listeners[i]; if (listener != NULL) { + TRACE(("set listener fd %d", listener->sock)); FD_SET(listener->sock, readfds); } } @@ -36,6 +37,7 @@ for (i = 0; i < ses.listensize; i++) { listener = ses.listeners[i]; if (listener != NULL) { + TRACE(("handle listener num %d fd %d", i, listener->sock)); if (FD_ISSET(listener->sock, readfds)) { listener->accepter(listener); } @@ -80,6 +82,8 @@ ses.maxfd = MAX(ses.maxfd, sock); + TRACE(("new listener num %d fd %d", i, sock)); + newlisten = (struct Listener*)m_malloc(sizeof(struct Listener)); newlisten->index = i; newlisten->type = type; diff -r 7a37cff27258 -r db2c8e6fb284 listener.h --- a/listener.h Thu Jun 03 17:29:17 2004 +0000 +++ b/listener.h Thu Jun 03 18:08:34 2004 +0000 @@ -21,7 +21,7 @@ }; -void listener_initialise(); +void listeners_initialise(); void handle_listeners(fd_set * readfds); void set_listener_fds(fd_set * readfds); diff -r 7a37cff27258 -r db2c8e6fb284 options.h --- a/options.h Thu Jun 03 17:29:17 2004 +0000 +++ b/options.h Thu Jun 03 18:08:34 2004 +0000 @@ -303,6 +303,11 @@ #define DISABLE_REMOTETCPFWD #endif +#if defined(ENABLE_REMOTETCPFWD) || defined(ENABLE_LOCALTCPFWD) || \ + defined(ENABLE_AGENTFWD) || defined(ENABLE_X11FWD) +#define USING_LISTENERS +#endif + /* We use dropbear_client and dropbear_server as shortcuts to avoid redundant * code, if we're just compiling as client or server */ #if defined(DROPBEAR_SERVER) && defined(DROPBEAR_CLIENT) diff -r 7a37cff27258 -r db2c8e6fb284 svr-agentfwd.c --- a/svr-agentfwd.c Thu Jun 03 17:29:17 2004 +0000 +++ b/svr-agentfwd.c Thu Jun 03 18:08:34 2004 +0000 @@ -103,10 +103,11 @@ fd = accept(listener->sock, NULL, NULL); if (fd < 0) { + TRACE(("accept failed")); return; } - if (send_msg_channel_open_agent(listener->sock) != DROPBEAR_SUCCESS) { + if (send_msg_channel_open_agent(fd) != DROPBEAR_SUCCESS) { close(fd); } diff -r 7a37cff27258 -r db2c8e6fb284 svr-packet.c --- a/svr-packet.c Thu Jun 03 17:29:17 2004 +0000 +++ b/svr-packet.c Thu Jun 03 18:08:34 2004 +0000 @@ -178,7 +178,7 @@ recv_msg_channel_close(); break; -#ifdef USE_LISTENERS /* for x11, tcp fwd etc */ +#ifdef USING_LISTENERS /* for x11, tcp fwd etc */ case SSH_MSG_CHANNEL_OPEN_CONFIRMATION: recv_msg_channel_open_confirmation(); break; diff -r 7a37cff27258 -r db2c8e6fb284 svr-x11fwd.c --- a/svr-x11fwd.c Thu Jun 03 17:29:17 2004 +0000 +++ b/svr-x11fwd.c Thu Jun 03 18:08:34 2004 +0000 @@ -106,6 +106,7 @@ struct sockaddr_in addr; int len; int ret; + struct ChanSess * chansess = (struct ChanSess *)(listener->typedata); len = sizeof(addr); @@ -115,8 +116,8 @@ } /* if single-connection we close it up */ - if (((struct ChanSess *)(listener->typedata))->x11singleconn) { - x11cleanup(listener); + if (chansess->x11singleconn) { + x11cleanup(chansess); } ret = send_msg_channel_open_x11(fd, &addr); @@ -166,13 +167,11 @@ } } -void x11cleanup(struct Listener *listener) { - - struct ChanSess *chansess = (struct ChanSess*)listener->typedata; +void x11cleanup(struct ChanSess *chansess) { m_free(chansess->x11authprot); m_free(chansess->x11authcookie); - remove_listener(listener); + remove_listener(chansess->x11listener); chansess->x11listener = NULL; } diff -r 7a37cff27258 -r db2c8e6fb284 x11fwd.h --- a/x11fwd.h Thu Jun 03 17:29:17 2004 +0000 +++ b/x11fwd.h Thu Jun 03 18:08:34 2004 +0000 @@ -31,7 +31,7 @@ int x11req(struct ChanSess * chansess); void x11setauth(struct ChanSess *chansess); -void x11cleanup(struct Listener *listener); +void x11cleanup(struct ChanSess *chansess); #endif /* DROPBEAR_X11FWD */ #endif /* _X11FWD_H_ */