diff options
Diffstat (limited to 'svr-chansession.c')
-rw-r--r-- | svr-chansession.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/svr-chansession.c b/svr-chansession.c index fed8240..99a67e9 100644 --- a/svr-chansession.c +++ b/svr-chansession.c @@ -59,7 +59,6 @@ static void send_msg_chansess_exitstatus(struct Channel * channel, struct ChanSess * chansess); static void send_msg_chansess_exitsignal(struct Channel * channel, struct ChanSess * chansess); -static int sesscheckclose(struct Channel *channel); static void get_termmodes(struct ChanSess *chansess); @@ -67,7 +66,8 @@ static void get_termmodes(struct ChanSess *chansess); extern char** environ; static int sesscheckclose(struct Channel *channel) { - return channel->writefd == -1; + struct ChanSess *chansess = (struct ChanSess*)channel->typedata; + return chansess->exit.exitpid != -1; } /* Handler for childs exiting, store the state for return to the client */ @@ -88,6 +88,8 @@ static void sesssigchild_handler(int UNUSED(dummy)) { 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) { @@ -99,7 +101,7 @@ static void sesssigchild_handler(int UNUSED(dummy)) { /* If the pid wasn't matched, then we might have hit the race mentioned * above. So we just store the info for the parent to deal with */ - if (i == svr_ses.childpidsize) { + if (!exit) { exit = &svr_ses.lastexit; } @@ -118,7 +120,6 @@ static void sesssigchild_handler(int UNUSED(dummy)) { /* we use this to determine how pid exited */ exit->exitsignal = -1; } - exit = NULL; } @@ -587,6 +588,16 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess, } } +#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); |