Fixed stupid agentfwd error (using the listening FD, not the accepted on. gah)

--HG--
extra : convert_revision : 27e793a6395dbf5f2c0aa130d37fad2e4ef67e01
This commit is contained in:
Matt Johnston 2004-06-03 18:08:34 +00:00
parent 9847cfe73d
commit ae1b0b07cf
9 changed files with 27 additions and 21 deletions

View File

@ -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();

View File

@ -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 */

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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_ */