summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--channel.h8
-rw-r--r--common-channel.c9
-rw-r--r--listener.c6
-rw-r--r--listener.h2
-rw-r--r--options.h5
-rw-r--r--svr-agentfwd.c3
-rw-r--r--svr-packet.c2
-rw-r--r--svr-x11fwd.c11
-rw-r--r--x11fwd.h2
9 files changed, 27 insertions, 21 deletions
diff --git a/channel.h b/channel.h
index b77a660..e1bdae2 100644
--- a/channel.h
+++ b/channel.h
@@ -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_window_adjust();
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 --git a/common-channel.c b/common-channel.c
index 63ed275..3eea044 100644
--- a/common-channel.c
+++ b/common-channel.c
@@ -607,7 +607,7 @@ static void send_msg_channel_data(struct Channel *channel, int isextended,
/* 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 @@ static void send_msg_channel_open_confirmation(struct Channel* channel,
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 @@ void recv_msg_channel_open_confirmation() {
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 @@ static void closechanfd(struct Channel *channel, int fd, int how) {
}
}
-#endif /* USE_LISTENERS */
+#endif /* USING_LISTENERS */
diff --git a/listener.c b/listener.c
index df66629..7296a61 100644
--- a/listener.c
+++ b/listener.c
@@ -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 @@ void set_listener_fds(fd_set * readfds) {
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 @@ void handle_listeners(fd_set * readfds) {
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 @@ struct Listener* new_listener(int sock, int type, void* typedata,
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 --git a/listener.h b/listener.h
index ab77351..bda24ff 100644
--- a/listener.h
+++ b/listener.h
@@ -21,7 +21,7 @@ struct Listener {
};
-void listener_initialise();
+void listeners_initialise();
void handle_listeners(fd_set * readfds);
void set_listener_fds(fd_set * readfds);
diff --git a/options.h b/options.h
index 703fec0..c6b552a 100644
--- a/options.h
+++ b/options.h
@@ -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 --git a/svr-agentfwd.c b/svr-agentfwd.c
index 4c49e45..fd068fe 100644
--- a/svr-agentfwd.c
+++ b/svr-agentfwd.c
@@ -103,10 +103,11 @@ static void agentaccept(struct Listener * listener) {
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 --git a/svr-packet.c b/svr-packet.c
index ac09822..064f465 100644
--- a/svr-packet.c
+++ b/svr-packet.c
@@ -178,7 +178,7 @@ static void svr_process_postauth_packet(unsigned int type) {
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 --git a/svr-x11fwd.c b/svr-x11fwd.c
index 12a8f21..aa0ba2d 100644
--- a/svr-x11fwd.c
+++ b/svr-x11fwd.c
@@ -106,6 +106,7 @@ static void x11accept(struct Listener* listener) {
struct sockaddr_in addr;
int len;
int ret;
+ struct ChanSess * chansess = (struct ChanSess *)(listener->typedata);
len = sizeof(addr);
@@ -115,8 +116,8 @@ static void x11accept(struct Listener* listener) {
}
/* 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 x11setauth(struct ChanSess *chansess) {
}
}
-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 --git a/x11fwd.h b/x11fwd.h
index 13cd11f..5855a68 100644
--- a/x11fwd.h
+++ b/x11fwd.h
@@ -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_ */