changeset 13:db2c8e6fb284

Fixed stupid agentfwd error (using the listening FD, not the accepted on. gah)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 03 Jun 2004 18:08:34 +0000
parents 7a37cff27258
children 5ae28f6101c1 d7cc5b484a2e
files channel.h common-channel.c listener.c listener.h options.h svr-agentfwd.c svr-packet.c svr-x11fwd.c x11fwd.h
diffstat 9 files changed, 27 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- 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();
--- 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 */
--- 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;
--- 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);
 
--- 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)
--- 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);
 	}
 
--- 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;
--- 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;
 }
 
--- 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_ */