comparison 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
comparison
equal deleted inserted replaced
377:1bfa65fed772 378:a124aff0cbf1
65 65
66 /* required to clear environment */ 66 /* required to clear environment */
67 extern char** environ; 67 extern char** environ;
68 68
69 static int sesscheckclose(struct Channel *channel) { 69 static int sesscheckclose(struct Channel *channel) {
70 struct ChanSess *chansess = (struct ChanSess*)channel->typedata; 70 return channel->writefd == -1;
71 return chansess->exit.exitpid >= 0;
72 } 71 }
73 72
74 /* Handler for childs exiting, store the state for return to the client */ 73 /* Handler for childs exiting, store the state for return to the client */
75 74
76 /* There's a particular race we have to watch out for: if the forked child 75 /* There's a particular race we have to watch out for: if the forked child
87 struct sigaction sa_chld; 86 struct sigaction sa_chld;
88 struct exitinfo *exit = NULL; 87 struct exitinfo *exit = NULL;
89 88
90 TRACE(("enter sigchld handler")) 89 TRACE(("enter sigchld handler"))
91 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { 90 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
91
92 exit = NULL;
92 /* find the corresponding chansess */ 93 /* find the corresponding chansess */
93 for (i = 0; i < svr_ses.childpidsize; i++) { 94 for (i = 0; i < svr_ses.childpidsize; i++) {
94 if (svr_ses.childpids[i].pid == pid) { 95 if (svr_ses.childpids[i].pid == pid) {
95 96
96 exit = &svr_ses.childpids[i].chansess->exit; 97 exit = &svr_ses.childpids[i].chansess->exit;
117 #endif 118 #endif
118 } else { 119 } else {
119 /* we use this to determine how pid exited */ 120 /* we use this to determine how pid exited */
120 exit->exitsignal = -1; 121 exit->exitsignal = -1;
121 } 122 }
122 exit = NULL;
123 } 123 }
124 124
125 125
126 sa_chld.sa_handler = sesssigchild_handler; 126 sa_chld.sa_handler = sesssigchild_handler;
127 sa_chld.sa_flags = SA_NOCLDSTOP; 127 sa_chld.sa_flags = SA_NOCLDSTOP;
408 termw = buf_getint(ses.payload); 408 termw = buf_getint(ses.payload);
409 termh = buf_getint(ses.payload); 409 termh = buf_getint(ses.payload);
410 410
411 pty_change_window_size(chansess->master, termr, termc, termw, termh); 411 pty_change_window_size(chansess->master, termr, termc, termw, termh);
412 412
413 return DROPBEAR_FAILURE; 413 return DROPBEAR_SUCCESS;
414 } 414 }
415 415
416 static void get_termmodes(struct ChanSess *chansess) { 416 static void get_termmodes(struct ChanSess *chansess) {
417 417
418 struct termios termio; 418 struct termios termio;
585 m_free(chansess->cmd); 585 m_free(chansess->cmd);
586 return DROPBEAR_FAILURE; 586 return DROPBEAR_FAILURE;
587 } 587 }
588 } 588 }
589 } 589 }
590
591 #ifdef LOG_COMMANDS
592 if (chansess->cmd) {
593 dropbear_log(LOG_INFO, "user %s executing '%s'",
594 ses.authstate.printableuser, chansess->cmd);
595 } else {
596 dropbear_log(LOG_INFO, "user %s executing login shell",
597 ses.authstate.printableuser);
598 }
599 #endif
590 600
591 if (chansess->term == NULL) { 601 if (chansess->term == NULL) {
592 /* no pty */ 602 /* no pty */
593 ret = noptycommand(channel, chansess); 603 ret = noptycommand(channel, chansess);
594 } else { 604 } else {