From b601f68cda9187ed77d21eb46126fc83ba0bd14b Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Fri, 30 Jul 2004 03:02:19 +0000 Subject: [PATCH] we're nearly there yet --HG-- extra : convert_revision : ab7e63234f2c134c2321406598ae67038e0ca576 --- Makefile.in | 2 +- cli-auth.c | 1 + cli-session.c | 15 ++++++++++++++- common-channel.c | 13 +++++++++++++ runopts.h | 3 +++ session.h | 3 +++ 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index b8de23e..efb64d6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -27,7 +27,7 @@ SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \ svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \ - cli-session.o cli-service.o cli-runopts.o + cli-session.o cli-service.o cli-runopts.o cli-chansession.o CLISVROBJS=common-session.o packet.o common-algo.o common-kex.o \ common-channel.o common-chansession.o termcodes.o loginrec.o \ diff --git a/cli-auth.c b/cli-auth.c index 3759ff5..37e7814 100644 --- a/cli-auth.c +++ b/cli-auth.c @@ -96,6 +96,7 @@ void recv_msg_userauth_failure() { void recv_msg_userauth_success() { TRACE(("received msg_userauth_success")); ses.authstate.authdone = 1; + cli_ses.state = USERAUTH_SUCCESS_RCVD; } void cli_auth_try() { diff --git a/cli-session.c b/cli-session.c index c999aed..b126b27 100644 --- a/cli-session.c +++ b/cli-session.c @@ -37,7 +37,6 @@ static const packettype cli_packettypes[] = { }; static const struct ChanType *cli_chantypes[] = { -// &clichansess, /* &chan_tcpdirect etc, though need to only allow if we've requested * that forwarding */ NULL /* Null termination */ @@ -148,6 +147,20 @@ static void cli_sessionloop() { TRACE(("leave cli_sessionloop: cli_auth_try")); return; + /* + case USERAUTH_SUCCESS_RCVD: + send_msg_service_request(SSH_SERVICE_CONNECTION); + cli_ses.state = SERVICE_CONN_REQ_SENT; + TRACE(("leave cli_sessionloop: sent ssh-connection service req")); + return; + */ + + case USERAUTH_SUCCESS_RCVD: + cli_send_chansess_request(); + TRACE(("leave cli_sessionloop: cli_send_chansess_request")); + cli_ses.state = SESSION_RUNNING; + return; + /* XXX more here needed */ diff --git a/common-channel.c b/common-channel.c index 3eea044..fbfb00b 100644 --- a/common-channel.c +++ b/common-channel.c @@ -67,6 +67,7 @@ void chaninitialise(const struct ChanType *chantypes[]) { ses.channels = (struct Channel**)m_malloc(sizeof(struct Channel*)); ses.chansize = 1; ses.channels[0] = NULL; + ses.chancount = 0; ses.chantypes = chantypes; @@ -153,6 +154,7 @@ struct Channel* newchannel(unsigned int remotechan, newchan->recvmaxpacket = RECV_MAXPACKET; ses.channels[i] = newchan; + ses.chancount++; TRACE(("leave newchannel")); @@ -515,6 +517,7 @@ static void deletechannel(struct Channel *channel) { ses.channels[channel->index] = NULL; m_free(channel); + ses.chancount--; } @@ -934,6 +937,7 @@ void recv_msg_channel_open_confirmation() { unsigned int chan; struct Channel * channel; + int ret; TRACE(("enter recv_msg_channel_open_confirmation")); chan = buf_getint(ses.payload); @@ -949,6 +953,15 @@ void recv_msg_channel_open_confirmation() { TRACE(("new chan remote %d localho %d", channel->remotechan, chan)); + /* Run the inithandler callback */ + if (channel->type->inithandler) { + ret = channel->type->inithandler(channel); + if (ret > 0) { + removechannel(channel); + TRACE(("inithandler returned failure %d", ret)); + } + } + TRACE(("leave recv_msg_channel_open_confirmation")); } diff --git a/runopts.h b/runopts.h index 125d737..b2fc149 100644 --- a/runopts.h +++ b/runopts.h @@ -83,6 +83,9 @@ typedef struct cli_runopts { char *remoteport; char *username; + + char *cmd; + int wantpty; /* XXX TODO */ } cli_runopts; diff --git a/session.h b/session.h index bf6adb3..349c00f 100644 --- a/session.h +++ b/session.h @@ -152,6 +152,7 @@ struct sshsession { /* Channel related */ struct Channel ** channels; /* these pointers may be null */ unsigned int chansize; /* the number of Channel*s allocated for channels */ + unsigned int chancount; /* the number of Channel*s in use */ const struct ChanType **chantypes; /* The valid channel types */ @@ -194,6 +195,8 @@ typedef enum { USERAUTH_METHODS_SENT, USERAUTH_REQ_SENT, USERAUTH_FAIL_RCVD, + USERAUTH_SUCCESS_RCVD, + SESSION_RUNNING, } cli_state;