mirror of
https://github.com/clearml/dropbear
synced 2025-04-10 15:35:41 +00:00
Fixed stupid agentfwd error (using the listening FD, not the accepted on. gah)
--HG-- extra : convert_revision : 27e793a6395dbf5f2c0aa130d37fad2e4ef67e01
This commit is contained in:
parent
9847cfe73d
commit
ae1b0b07cf
@ -50,12 +50,6 @@
|
|||||||
#define RECV_MAXPACKET 1400 /* tweak */
|
#define RECV_MAXPACKET 1400 /* tweak */
|
||||||
#define RECV_MINWINDOW 19000 /* when we get below this, we send a windowadjust */
|
#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 ChanType;
|
||||||
|
|
||||||
struct Channel {
|
struct Channel {
|
||||||
@ -113,7 +107,7 @@ void recv_msg_channel_window_adjust();
|
|||||||
void recv_msg_channel_close();
|
void recv_msg_channel_close();
|
||||||
void recv_msg_channel_eof();
|
void recv_msg_channel_eof();
|
||||||
|
|
||||||
#ifdef USE_LISTENERS
|
#ifdef USING_LISTENERS
|
||||||
int send_msg_channel_open_init(int fd, const struct ChanType *type);
|
int send_msg_channel_open_init(int fd, const struct ChanType *type);
|
||||||
void recv_msg_channel_open_confirmation();
|
void recv_msg_channel_open_confirmation();
|
||||||
void recv_msg_channel_open_failure();
|
void recv_msg_channel_open_failure();
|
||||||
|
@ -607,7 +607,7 @@ static void send_msg_channel_data(struct Channel *channel, int isextended,
|
|||||||
/* on error/eof, send eof */
|
/* on error/eof, send eof */
|
||||||
if (len == 0 || errno != EINTR) {
|
if (len == 0 || errno != EINTR) {
|
||||||
closeoutfd(channel, fd);
|
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);
|
buf_free(buf);
|
||||||
return;
|
return;
|
||||||
@ -889,7 +889,7 @@ static void send_msg_channel_open_confirmation(struct Channel* channel,
|
|||||||
TRACE(("leave send_msg_channel_open_confirmation"));
|
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
|
/* Create a new channel, and start the open request. This is intended
|
||||||
* for X11, agent, tcp forwarding, and should be filled with channel-specific
|
* for X11, agent, tcp forwarding, and should be filled with channel-specific
|
||||||
* options, with the calling function calling encrypt_packet() after
|
* options, with the calling function calling encrypt_packet() after
|
||||||
@ -947,6 +947,9 @@ void recv_msg_channel_open_confirmation() {
|
|||||||
channel->transwindow = buf_getint(ses.payload);
|
channel->transwindow = buf_getint(ses.payload);
|
||||||
channel->transmaxpacket = 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"));
|
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 */
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "dbutil.h"
|
#include "dbutil.h"
|
||||||
|
|
||||||
void listener_initialise() {
|
void listeners_initialise() {
|
||||||
|
|
||||||
/* just one slot to start with */
|
/* just one slot to start with */
|
||||||
ses.listeners = (struct Listener**)m_malloc(sizeof(struct Listener*));
|
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++) {
|
for (i = 0; i < ses.listensize; i++) {
|
||||||
listener = ses.listeners[i];
|
listener = ses.listeners[i];
|
||||||
if (listener != NULL) {
|
if (listener != NULL) {
|
||||||
|
TRACE(("set listener fd %d", listener->sock));
|
||||||
FD_SET(listener->sock, readfds);
|
FD_SET(listener->sock, readfds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,6 +37,7 @@ void handle_listeners(fd_set * readfds) {
|
|||||||
for (i = 0; i < ses.listensize; i++) {
|
for (i = 0; i < ses.listensize; i++) {
|
||||||
listener = ses.listeners[i];
|
listener = ses.listeners[i];
|
||||||
if (listener != NULL) {
|
if (listener != NULL) {
|
||||||
|
TRACE(("handle listener num %d fd %d", i, listener->sock));
|
||||||
if (FD_ISSET(listener->sock, readfds)) {
|
if (FD_ISSET(listener->sock, readfds)) {
|
||||||
listener->accepter(listener);
|
listener->accepter(listener);
|
||||||
}
|
}
|
||||||
@ -80,6 +82,8 @@ struct Listener* new_listener(int sock, int type, void* typedata,
|
|||||||
|
|
||||||
ses.maxfd = MAX(ses.maxfd, sock);
|
ses.maxfd = MAX(ses.maxfd, sock);
|
||||||
|
|
||||||
|
TRACE(("new listener num %d fd %d", i, sock));
|
||||||
|
|
||||||
newlisten = (struct Listener*)m_malloc(sizeof(struct Listener));
|
newlisten = (struct Listener*)m_malloc(sizeof(struct Listener));
|
||||||
newlisten->index = i;
|
newlisten->index = i;
|
||||||
newlisten->type = type;
|
newlisten->type = type;
|
||||||
|
@ -21,7 +21,7 @@ struct Listener {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void listener_initialise();
|
void listeners_initialise();
|
||||||
void handle_listeners(fd_set * readfds);
|
void handle_listeners(fd_set * readfds);
|
||||||
void set_listener_fds(fd_set * readfds);
|
void set_listener_fds(fd_set * readfds);
|
||||||
|
|
||||||
|
@ -303,6 +303,11 @@
|
|||||||
#define DISABLE_REMOTETCPFWD
|
#define DISABLE_REMOTETCPFWD
|
||||||
#endif
|
#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
|
/* We use dropbear_client and dropbear_server as shortcuts to avoid redundant
|
||||||
* code, if we're just compiling as client or server */
|
* code, if we're just compiling as client or server */
|
||||||
#if defined(DROPBEAR_SERVER) && defined(DROPBEAR_CLIENT)
|
#if defined(DROPBEAR_SERVER) && defined(DROPBEAR_CLIENT)
|
||||||
|
@ -103,10 +103,11 @@ static void agentaccept(struct Listener * listener) {
|
|||||||
|
|
||||||
fd = accept(listener->sock, NULL, NULL);
|
fd = accept(listener->sock, NULL, NULL);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
TRACE(("accept failed"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send_msg_channel_open_agent(listener->sock) != DROPBEAR_SUCCESS) {
|
if (send_msg_channel_open_agent(fd) != DROPBEAR_SUCCESS) {
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ static void svr_process_postauth_packet(unsigned int type) {
|
|||||||
recv_msg_channel_close();
|
recv_msg_channel_close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef USE_LISTENERS /* for x11, tcp fwd etc */
|
#ifdef USING_LISTENERS /* for x11, tcp fwd etc */
|
||||||
case SSH_MSG_CHANNEL_OPEN_CONFIRMATION:
|
case SSH_MSG_CHANNEL_OPEN_CONFIRMATION:
|
||||||
recv_msg_channel_open_confirmation();
|
recv_msg_channel_open_confirmation();
|
||||||
break;
|
break;
|
||||||
|
11
svr-x11fwd.c
11
svr-x11fwd.c
@ -106,6 +106,7 @@ static void x11accept(struct Listener* listener) {
|
|||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
int len;
|
int len;
|
||||||
int ret;
|
int ret;
|
||||||
|
struct ChanSess * chansess = (struct ChanSess *)(listener->typedata);
|
||||||
|
|
||||||
len = sizeof(addr);
|
len = sizeof(addr);
|
||||||
|
|
||||||
@ -115,8 +116,8 @@ static void x11accept(struct Listener* listener) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if single-connection we close it up */
|
/* if single-connection we close it up */
|
||||||
if (((struct ChanSess *)(listener->typedata))->x11singleconn) {
|
if (chansess->x11singleconn) {
|
||||||
x11cleanup(listener);
|
x11cleanup(chansess);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = send_msg_channel_open_x11(fd, &addr);
|
ret = send_msg_channel_open_x11(fd, &addr);
|
||||||
@ -166,13 +167,11 @@ void x11setauth(struct ChanSess *chansess) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void x11cleanup(struct Listener *listener) {
|
void x11cleanup(struct ChanSess *chansess) {
|
||||||
|
|
||||||
struct ChanSess *chansess = (struct ChanSess*)listener->typedata;
|
|
||||||
|
|
||||||
m_free(chansess->x11authprot);
|
m_free(chansess->x11authprot);
|
||||||
m_free(chansess->x11authcookie);
|
m_free(chansess->x11authcookie);
|
||||||
remove_listener(listener);
|
remove_listener(chansess->x11listener);
|
||||||
chansess->x11listener = NULL;
|
chansess->x11listener = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
x11fwd.h
2
x11fwd.h
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
int x11req(struct ChanSess * chansess);
|
int x11req(struct ChanSess * chansess);
|
||||||
void x11setauth(struct ChanSess *chansess);
|
void x11setauth(struct ChanSess *chansess);
|
||||||
void x11cleanup(struct Listener *listener);
|
void x11cleanup(struct ChanSess *chansess);
|
||||||
|
|
||||||
#endif /* DROPBEAR_X11FWD */
|
#endif /* DROPBEAR_X11FWD */
|
||||||
#endif /* _X11FWD_H_ */
|
#endif /* _X11FWD_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user