diff svr-chansession.c @ 378:a124aff0cbf1

merge of '182c2d8dbd5321ef4d1df8758936f4dc7127015f' and '31dcd7a22983ef19d6c63248e415e71d292dd0ec'
author Matt Johnston <matt@ucc.asn.au>
date Wed, 06 Dec 2006 13:11:41 +0000
parents fbcc3b5b34f3 01e4180895ba
children 59c7938af2bd
line wrap: on
line diff
--- a/svr-chansession.c	Wed Dec 06 13:09:32 2006 +0000
+++ b/svr-chansession.c	Wed Dec 06 13:11:41 2006 +0000
@@ -67,8 +67,7 @@
 extern char** environ;
 
 static int sesscheckclose(struct Channel *channel) {
-	struct ChanSess *chansess = (struct ChanSess*)channel->typedata;
-	return chansess->exit.exitpid >= 0;
+	return channel->writefd == -1;
 }
 
 /* Handler for childs exiting, store the state for return to the client */
@@ -89,6 +88,8 @@
 
 	TRACE(("enter sigchld handler"))
 	while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
+
+		exit = NULL;
 		/* find the corresponding chansess */
 		for (i = 0; i < svr_ses.childpidsize; i++) {
 			if (svr_ses.childpids[i].pid == pid) {
@@ -119,7 +120,6 @@
 			/* we use this to determine how pid exited */
 			exit->exitsignal = -1;
 		}
-		exit = NULL;
 	}
 
 	
@@ -410,7 +410,7 @@
 	
 	pty_change_window_size(chansess->master, termr, termc, termw, termh);
 
-	return DROPBEAR_FAILURE;
+	return DROPBEAR_SUCCESS;
 }
 
 static void get_termmodes(struct ChanSess *chansess) {
@@ -588,6 +588,16 @@
 		}
 	}
 
+#ifdef LOG_COMMANDS
+	if (chansess->cmd) {
+		dropbear_log(LOG_INFO, "user %s executing '%s'", 
+						ses.authstate.printableuser, chansess->cmd);
+	} else {
+		dropbear_log(LOG_INFO, "user %s executing login shell", 
+						ses.authstate.printableuser);
+	}
+#endif
+
 	if (chansess->term == NULL) {
 		/* no pty */
 		ret = noptycommand(channel, chansess);