changeset 37:0913e2ee3545

we're nearly there yet
author Matt Johnston <matt@ucc.asn.au>
date Fri, 30 Jul 2004 03:02:19 +0000
parents a600c015562d
children 5c6f9d27ea1c
files Makefile.in cli-auth.c cli-session.c common-channel.c runopts.h session.h
diffstat 6 files changed, 35 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Thu Jul 29 15:43:26 2004 +0000
+++ b/Makefile.in	Fri Jul 30 03:02:19 2004 +0000
@@ -27,7 +27,7 @@
 		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 \
--- a/cli-auth.c	Thu Jul 29 15:43:26 2004 +0000
+++ b/cli-auth.c	Fri Jul 30 03:02:19 2004 +0000
@@ -96,6 +96,7 @@
 void recv_msg_userauth_success() {
 	TRACE(("received msg_userauth_success"));
 	ses.authstate.authdone = 1;
+	cli_ses.state = USERAUTH_SUCCESS_RCVD;
 }
 
 void cli_auth_try() {
--- a/cli-session.c	Thu Jul 29 15:43:26 2004 +0000
+++ b/cli-session.c	Fri Jul 30 03:02:19 2004 +0000
@@ -37,7 +37,6 @@
 };
 
 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 @@
 			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 */
 
 
--- a/common-channel.c	Thu Jul 29 15:43:26 2004 +0000
+++ b/common-channel.c	Fri Jul 30 03:02:19 2004 +0000
@@ -67,6 +67,7 @@
 	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 @@
 	newchan->recvmaxpacket = RECV_MAXPACKET;
 
 	ses.channels[i] = newchan;
+	ses.chancount++;
 
 	TRACE(("leave newchannel"));
 
@@ -515,6 +517,7 @@
 
 	ses.channels[channel->index] = NULL;
 	m_free(channel);
+	ses.chancount--;
 	
 }
 
@@ -934,6 +937,7 @@
 
 	unsigned int chan;
 	struct Channel * channel;
+	int ret;
 
 	TRACE(("enter recv_msg_channel_open_confirmation"));
 	chan = buf_getint(ses.payload);
@@ -949,6 +953,15 @@
 	
 	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"));
 }
--- a/runopts.h	Thu Jul 29 15:43:26 2004 +0000
+++ b/runopts.h	Fri Jul 30 03:02:19 2004 +0000
@@ -83,6 +83,9 @@
 	char *remoteport;
 
 	char *username;
+
+	char *cmd;
+	int wantpty;
 	/* XXX TODO */
 
 } cli_runopts;
--- a/session.h	Thu Jul 29 15:43:26 2004 +0000
+++ b/session.h	Fri Jul 30 03:02:19 2004 +0000
@@ -152,6 +152,7 @@
 	/* 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 @@
 	USERAUTH_METHODS_SENT,
 	USERAUTH_REQ_SENT,
 	USERAUTH_FAIL_RCVD,
+	USERAUTH_SUCCESS_RCVD,
+	SESSION_RUNNING,
 
 } cli_state;