summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--chansession.h5
-rw-r--r--common-channel.c9
-rw-r--r--common-session.c2
-rw-r--r--debug.h2
-rw-r--r--session.h2
-rw-r--r--svr-chansession.c8
-rw-r--r--svr-session.c7
7 files changed, 23 insertions, 12 deletions
diff --git a/chansession.h b/chansession.h
index 1e4ba9a..85dc9c1 100644
--- a/chansession.h
+++ b/chansession.h
@@ -68,16 +68,15 @@ struct ChildPid {
};
-void newchansess(struct Channel * channel);
void chansessionrequest(struct Channel * channel);
-void closechansess(struct Channel * channel);
-void svr_chansessinitialise();
void send_msg_chansess_exitstatus(struct Channel * channel,
struct ChanSess * chansess);
void send_msg_chansess_exitsignal(struct Channel * channel,
struct ChanSess * chansess);
void addnewvar(const char* param, const char* var);
+void svr_chansessinitialise();
+extern const struct ChanType svrchansess;
struct SigMap {
int signal;
diff --git a/common-channel.c b/common-channel.c
index 8b5423a..135e098 100644
--- a/common-channel.c
+++ b/common-channel.c
@@ -61,7 +61,7 @@ static void closechanfd(struct Channel *channel, int fd, int how);
#define FD_CLOSED (-1)
/* Initialise all the channels */
-void chaninitialise(struct ChanType *chantypes[]) {
+void chaninitialise(const struct ChanType *chantypes[]) {
/* may as well create space for a single channel */
ses.channels = (struct Channel**)m_malloc(sizeof(struct Channel*));
@@ -737,7 +737,7 @@ void recv_msg_channel_open() {
unsigned int typelen;
unsigned int remotechan, transwindow, transmaxpacket;
struct Channel *channel;
- struct ChanType *chantype;
+ const struct ChanType *chantype;
unsigned int errtype = SSH_OPEN_UNKNOWN_CHANNEL_TYPE;
int ret;
@@ -775,14 +775,16 @@ void recv_msg_channel_open() {
channel = newchannel(remotechan, chantype, transwindow, transmaxpacket);
if (channel == NULL) {
+ TRACE(("newchannel returned NULL"));
goto failure;
}
if (channel->type->inithandler) {
ret = channel->type->inithandler(channel);
- if (ret >= 0) {
+ if (ret > 0) {
errtype = ret;
deletechannel(channel);
+ TRACE(("inithandler returned failure %d", ret));
goto failure;
}
}
@@ -810,6 +812,7 @@ void recv_msg_channel_open() {
goto cleanup;
failure:
+ TRACE(("recv_msg_channel_open failure"));
send_msg_channel_open_failure(remotechan, errtype, "", "");
cleanup:
diff --git a/common-session.c b/common-session.c
index 5e87c9a..fce301a 100644
--- a/common-session.c
+++ b/common-session.c
@@ -106,6 +106,8 @@ void common_session_init(int sock, runopts *opts) {
ses.dh_K = NULL;
ses.remoteident = NULL;
+ ses.chantypes = NULL;
+
TRACE(("leave session_init"));
}
diff --git a/debug.h b/debug.h
index 2b4a3dc..75f9503 100644
--- a/debug.h
+++ b/debug.h
@@ -34,7 +34,7 @@
/* #define DEBUG_VALGRIND */
/* Define this to print trace statements - very verbose */
-/* #define DEBUG_TRACE */
+#define DEBUG_TRACE
/* All functions writing to the cleartext payload buffer call
* CHECKCLEARTOWRITE() before writing. This is only really useful if you're
diff --git a/session.h b/session.h
index 51e3ae4..e372232 100644
--- a/session.h
+++ b/session.h
@@ -134,7 +134,7 @@ struct sshsession {
/* Channel related */
struct Channel ** channels; /* these pointers may be null */
unsigned int chansize; /* the number of Channel*s allocated for channels */
- struct ChanType **chantypes; /* The valid channel types */
+ const struct ChanType **chantypes; /* The valid channel types */
/* TCP forwarding - where manage listeners */
diff --git a/svr-chansession.c b/svr-chansession.c
index dce0827..2705069 100644
--- a/svr-chansession.c
+++ b/svr-chansession.c
@@ -50,7 +50,7 @@ static void execchild(struct ChanSess *chansess);
static void addchildpid(struct ChanSess *chansess, pid_t pid);
static void sesssigchild_handler(int val);
static void closechansess(struct Channel *channel);
-static void newchansess(struct Channel *channel);
+static int newchansess(struct Channel *channel);
static void chansessionrequest(struct Channel *channel);
static void send_exitsignalstatus(struct Channel *channel);
@@ -205,7 +205,7 @@ static void send_msg_chansess_exitsignal(struct Channel * channel,
}
/* set up a session channel */
-static void newchansess(struct Channel *channel) {
+static int newchansess(struct Channel *channel) {
struct ChanSess *chansess;
@@ -241,6 +241,8 @@ static void newchansess(struct Channel *channel) {
chansess->agentdir = NULL;
#endif
+ return 0;
+
}
/* clean a session channel */
@@ -310,8 +312,6 @@ static void chansessionrequest(struct Channel *channel) {
TRACE(("enter chansessionrequest"));
- assert(channel->type == CHANNEL_ID_SESSION);
-
type = buf_getstring(ses.payload, &typelen);
wantreply = buf_getbyte(ses.payload);
diff --git a/svr-session.c b/svr-session.c
index 1aade1f..c6f05cc 100644
--- a/svr-session.c
+++ b/svr-session.c
@@ -40,6 +40,12 @@ static void svr_remoteclosed();
struct serversession svr_ses;
+const struct ChanType *chantypes[] = {
+ &svrchansess,
+ NULL /* Null termination is mandatory. */
+};
+
+
void svr_session(int sock, runopts *opts, int childpipe,
struct sockaddr* remoteaddr) {
@@ -56,6 +62,7 @@ void svr_session(int sock, runopts *opts, int childpipe,
/* Initialise server specific parts of the session */
svr_ses.childpipe = childpipe;
authinitialise();
+ chaninitialise(chantypes);
svr_chansessinitialise();
if (gettimeofday(&timeout, 0) < 0) {