# HG changeset patch # User Matt Johnston # Date 1086086926 0 # Node ID ab00ef513e975c6f4054ece7030f886593337d26 # Parent bc6477a6c393c243e31f261f32b426d00cc1d192 Sorted out the first channel init issues. diff -r bc6477a6c393 -r ab00ef513e97 chansession.h --- a/chansession.h Tue Jun 01 04:20:12 2004 +0000 +++ b/chansession.h Tue Jun 01 10:48:46 2004 +0000 @@ -68,16 +68,15 @@ }; -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 -r bc6477a6c393 -r ab00ef513e97 common-channel.c --- a/common-channel.c Tue Jun 01 04:20:12 2004 +0000 +++ b/common-channel.c Tue Jun 01 10:48:46 2004 +0000 @@ -61,7 +61,7 @@ #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 @@ 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 @@ 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 @@ goto cleanup; failure: + TRACE(("recv_msg_channel_open failure")); send_msg_channel_open_failure(remotechan, errtype, "", ""); cleanup: diff -r bc6477a6c393 -r ab00ef513e97 common-session.c --- a/common-session.c Tue Jun 01 04:20:12 2004 +0000 +++ b/common-session.c Tue Jun 01 10:48:46 2004 +0000 @@ -106,6 +106,8 @@ ses.dh_K = NULL; ses.remoteident = NULL; + ses.chantypes = NULL; + TRACE(("leave session_init")); } diff -r bc6477a6c393 -r ab00ef513e97 debug.h --- a/debug.h Tue Jun 01 04:20:12 2004 +0000 +++ b/debug.h Tue Jun 01 10:48:46 2004 +0000 @@ -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 -r bc6477a6c393 -r ab00ef513e97 session.h --- a/session.h Tue Jun 01 04:20:12 2004 +0000 +++ b/session.h Tue Jun 01 10:48:46 2004 +0000 @@ -134,7 +134,7 @@ /* 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 -r bc6477a6c393 -r ab00ef513e97 svr-chansession.c --- a/svr-chansession.c Tue Jun 01 04:20:12 2004 +0000 +++ b/svr-chansession.c Tue Jun 01 10:48:46 2004 +0000 @@ -50,7 +50,7 @@ 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 @@ } /* set up a session channel */ -static void newchansess(struct Channel *channel) { +static int newchansess(struct Channel *channel) { struct ChanSess *chansess; @@ -241,6 +241,8 @@ chansess->agentdir = NULL; #endif + return 0; + } /* clean a session channel */ @@ -310,8 +312,6 @@ TRACE(("enter chansessionrequest")); - assert(channel->type == CHANNEL_ID_SESSION); - type = buf_getstring(ses.payload, &typelen); wantreply = buf_getbyte(ses.payload); diff -r bc6477a6c393 -r ab00ef513e97 svr-session.c --- a/svr-session.c Tue Jun 01 04:20:12 2004 +0000 +++ b/svr-session.c Tue Jun 01 10:48:46 2004 +0000 @@ -40,6 +40,12 @@ 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 @@ /* Initialise server specific parts of the session */ svr_ses.childpipe = childpipe; authinitialise(); + chaninitialise(chantypes); svr_chansessinitialise(); if (gettimeofday(&timeout, 0) < 0) {