Mercurial > dropbear
changeset 6:ab00ef513e97
Sorted out the first channel init issues.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 01 Jun 2004 10:48:46 +0000 |
parents | bc6477a6c393 |
children | 425ed5c20157 |
files | chansession.h common-channel.c common-session.c debug.h session.h svr-chansession.c svr-session.c |
diffstat | 7 files changed, 23 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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:
--- 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")); }
--- 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
--- 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 */
--- 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);
--- 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) {