Sorted out the first channel init issues.

--HG--
extra : convert_revision : 67676f36b78efac878c11943d78a5de827498d05
This commit is contained in:
Matt Johnston 2004-06-01 10:48:46 +00:00
parent 40cb39d00c
commit 6152263045
7 changed files with 23 additions and 12 deletions

View File

@ -68,16 +68,15 @@ struct ChildPid {
}; };
void newchansess(struct Channel * channel);
void chansessionrequest(struct Channel * channel); void chansessionrequest(struct Channel * channel);
void closechansess(struct Channel * channel);
void svr_chansessinitialise();
void send_msg_chansess_exitstatus(struct Channel * channel, void send_msg_chansess_exitstatus(struct Channel * channel,
struct ChanSess * chansess); struct ChanSess * chansess);
void send_msg_chansess_exitsignal(struct Channel * channel, void send_msg_chansess_exitsignal(struct Channel * channel,
struct ChanSess * chansess); struct ChanSess * chansess);
void addnewvar(const char* param, const char* var); void addnewvar(const char* param, const char* var);
void svr_chansessinitialise();
extern const struct ChanType svrchansess;
struct SigMap { struct SigMap {
int signal; int signal;

View File

@ -61,7 +61,7 @@ static void closechanfd(struct Channel *channel, int fd, int how);
#define FD_CLOSED (-1) #define FD_CLOSED (-1)
/* Initialise all the channels */ /* Initialise all the channels */
void chaninitialise(struct ChanType *chantypes[]) { void chaninitialise(const struct ChanType *chantypes[]) {
/* may as well create space for a single channel */ /* may as well create space for a single channel */
ses.channels = (struct Channel**)m_malloc(sizeof(struct Channel*)); ses.channels = (struct Channel**)m_malloc(sizeof(struct Channel*));
@ -737,7 +737,7 @@ void recv_msg_channel_open() {
unsigned int typelen; unsigned int typelen;
unsigned int remotechan, transwindow, transmaxpacket; unsigned int remotechan, transwindow, transmaxpacket;
struct Channel *channel; struct Channel *channel;
struct ChanType *chantype; const struct ChanType *chantype;
unsigned int errtype = SSH_OPEN_UNKNOWN_CHANNEL_TYPE; unsigned int errtype = SSH_OPEN_UNKNOWN_CHANNEL_TYPE;
int ret; int ret;
@ -775,14 +775,16 @@ void recv_msg_channel_open() {
channel = newchannel(remotechan, chantype, transwindow, transmaxpacket); channel = newchannel(remotechan, chantype, transwindow, transmaxpacket);
if (channel == NULL) { if (channel == NULL) {
TRACE(("newchannel returned NULL"));
goto failure; goto failure;
} }
if (channel->type->inithandler) { if (channel->type->inithandler) {
ret = channel->type->inithandler(channel); ret = channel->type->inithandler(channel);
if (ret >= 0) { if (ret > 0) {
errtype = ret; errtype = ret;
deletechannel(channel); deletechannel(channel);
TRACE(("inithandler returned failure %d", ret));
goto failure; goto failure;
} }
} }
@ -810,6 +812,7 @@ void recv_msg_channel_open() {
goto cleanup; goto cleanup;
failure: failure:
TRACE(("recv_msg_channel_open failure"));
send_msg_channel_open_failure(remotechan, errtype, "", ""); send_msg_channel_open_failure(remotechan, errtype, "", "");
cleanup: cleanup:

View File

@ -106,6 +106,8 @@ void common_session_init(int sock, runopts *opts) {
ses.dh_K = NULL; ses.dh_K = NULL;
ses.remoteident = NULL; ses.remoteident = NULL;
ses.chantypes = NULL;
TRACE(("leave session_init")); TRACE(("leave session_init"));
} }

View File

@ -34,7 +34,7 @@
/* #define DEBUG_VALGRIND */ /* #define DEBUG_VALGRIND */
/* Define this to print trace statements - very verbose */ /* Define this to print trace statements - very verbose */
/* #define DEBUG_TRACE */ #define DEBUG_TRACE
/* All functions writing to the cleartext payload buffer call /* All functions writing to the cleartext payload buffer call
* CHECKCLEARTOWRITE() before writing. This is only really useful if you're * CHECKCLEARTOWRITE() before writing. This is only really useful if you're

View File

@ -134,7 +134,7 @@ struct sshsession {
/* Channel related */ /* Channel related */
struct Channel ** channels; /* these pointers may be null */ struct Channel ** channels; /* these pointers may be null */
unsigned int chansize; /* the number of Channel*s allocated for channels */ 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 */ /* TCP forwarding - where manage listeners */

View File

@ -50,7 +50,7 @@ static void execchild(struct ChanSess *chansess);
static void addchildpid(struct ChanSess *chansess, pid_t pid); static void addchildpid(struct ChanSess *chansess, pid_t pid);
static void sesssigchild_handler(int val); static void sesssigchild_handler(int val);
static void closechansess(struct Channel *channel); 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 chansessionrequest(struct Channel *channel);
static void send_exitsignalstatus(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 */ /* set up a session channel */
static void newchansess(struct Channel *channel) { static int newchansess(struct Channel *channel) {
struct ChanSess *chansess; struct ChanSess *chansess;
@ -241,6 +241,8 @@ static void newchansess(struct Channel *channel) {
chansess->agentdir = NULL; chansess->agentdir = NULL;
#endif #endif
return 0;
} }
/* clean a session channel */ /* clean a session channel */
@ -310,8 +312,6 @@ static void chansessionrequest(struct Channel *channel) {
TRACE(("enter chansessionrequest")); TRACE(("enter chansessionrequest"));
assert(channel->type == CHANNEL_ID_SESSION);
type = buf_getstring(ses.payload, &typelen); type = buf_getstring(ses.payload, &typelen);
wantreply = buf_getbyte(ses.payload); wantreply = buf_getbyte(ses.payload);

View File

@ -40,6 +40,12 @@ static void svr_remoteclosed();
struct serversession svr_ses; struct serversession svr_ses;
const struct ChanType *chantypes[] = {
&svrchansess,
NULL /* Null termination is mandatory. */
};
void svr_session(int sock, runopts *opts, int childpipe, void svr_session(int sock, runopts *opts, int childpipe,
struct sockaddr* remoteaddr) { struct sockaddr* remoteaddr) {
@ -56,6 +62,7 @@ void svr_session(int sock, runopts *opts, int childpipe,
/* Initialise server specific parts of the session */ /* Initialise server specific parts of the session */
svr_ses.childpipe = childpipe; svr_ses.childpipe = childpipe;
authinitialise(); authinitialise();
chaninitialise(chantypes);
svr_chansessinitialise(); svr_chansessinitialise();
if (gettimeofday(&timeout, 0) < 0) { if (gettimeofday(&timeout, 0) < 0) {