comparison svr-chansession.c @ 308:6e5f8ce73bf2 ucc-axis-hack

add break handler
author matt-ucc@ucc.asn.au
date Sat, 25 Mar 2006 18:35:35 +0000
parents 24b19535264b
children 24056a5eb75b
comparison
equal deleted inserted replaced
307:24b19535264b 308:6e5f8ce73bf2
61 struct ChanSess * chansess); 61 struct ChanSess * chansess);
62 static int sesscheckclose(struct Channel *channel); 62 static int sesscheckclose(struct Channel *channel);
63 static void get_termmodes(struct ChanSess *chansess); 63 static void get_termmodes(struct ChanSess *chansess);
64 64
65 static void serial_connect(struct Channel *channel); 65 static void serial_connect(struct Channel *channel);
66 static int sessionbreak(struct ChanSess *chansess);
66 67
67 /* required to clear environment */ 68 /* required to clear environment */
68 extern char** environ; 69 extern char** environ;
69 70
70 static int sesscheckclose(struct Channel *channel) { 71 static int sesscheckclose(struct Channel *channel) {
315 316
316 chansess = (struct ChanSess*)channel->typedata; 317 chansess = (struct ChanSess*)channel->typedata;
317 dropbear_assert(chansess != NULL); 318 dropbear_assert(chansess != NULL);
318 TRACE(("type is %s", type)) 319 TRACE(("type is %s", type))
319 320
321 #if 0
322 hack
320 if (strcmp(type, "window-change") == 0) { 323 if (strcmp(type, "window-change") == 0) {
321 ret = sessionwinchange(chansess); 324 ret = sessionwinchange(chansess);
322 } else if (strcmp(type, "shell") == 0) { 325 } else
326 #endif
327 if (strcmp(type, "shell") == 0) {
323 ret = sessioncommand(channel, chansess, 0, 0); 328 ret = sessioncommand(channel, chansess, 0, 0);
324 } else if (strcmp(type, "pty-req") == 0) { 329 } else if (strcmp(type, "pty-req") == 0) {
325 ret = sessionpty(chansess); 330 ret = sessionpty(chansess);
326 } else if (strcmp(type, "exec") == 0) { 331 } else if (strcmp(type, "exec") == 0) {
327 ret = sessioncommand(channel, chansess, 1, 0); 332 ret = sessioncommand(channel, chansess, 1, 0);
335 } else if (strcmp(type, "[email protected]") == 0) { 340 } else if (strcmp(type, "[email protected]") == 0) {
336 ret = agentreq(chansess); 341 ret = agentreq(chansess);
337 #endif 342 #endif
338 } else if (strcmp(type, "signal") == 0) { 343 } else if (strcmp(type, "signal") == 0) {
339 ret = sessionsignal(chansess); 344 ret = sessionsignal(chansess);
345 } else if (strcmp(type, "break") == 0) {
346 ret = sessionbreak(chansess);
340 } else { 347 } else {
341 /* etc, todo "env", "subsystem" */ 348 /* etc, todo "env", "subsystem" */
342 } 349 }
343 350
344 out: 351 out:
353 360
354 m_free(type); 361 m_free(type);
355 TRACE(("leave chansessionrequest")) 362 TRACE(("leave chansessionrequest"))
356 } 363 }
357 364
365 static int sessionbreak(struct ChanSess *chansess) {
366
367 int v;
368 char* argv[3];
369 TRACE(("break!!!!"))
370
371 v = fork();
372 if (v < 0) {
373 dropbear_exit("failed for for break");
374 } else if (v == 0) {
375 /* child */
376 argv[0] = "mfctl";
377 argv[1] = "b";
378 argv[2] = NULL;
379
380 execv("/etc/mfctl", argv);
381 dropbear_log(LOG_INFO, "break failed, eh?");
382
383 } else {
384 /* parent - do nothing */
385 }
386
387 return DROPBEAR_SUCCESS;
388 }
358 389
359 /* Send a signal to a session's process as requested by the client*/ 390 /* Send a signal to a session's process as requested by the client*/
360 static int sessionsignal(struct ChanSess *chansess) { 391 static int sessionsignal(struct ChanSess *chansess) {
361 392
362 int sig = 0; 393 int sig = 0;
512 543
513 unsigned int termlen; 544 unsigned int termlen;
514 unsigned char namebuf[65]; 545 unsigned char namebuf[65];
515 546
516 TRACE(("enter sessionpty")) 547 TRACE(("enter sessionpty"))
548 /* Axis hack */
549 TRACE(("this does nothing"))
550 #if 0
517 chansess->term = buf_getstring(ses.payload, &termlen); 551 chansess->term = buf_getstring(ses.payload, &termlen);
518 if (termlen > MAX_TERM_LEN) { 552 if (termlen > MAX_TERM_LEN) {
519 /* TODO send disconnect ? */ 553 /* TODO send disconnect ? */
520 TRACE(("leave sessionpty: term len too long")) 554 TRACE(("leave sessionpty: term len too long"))
521 return DROPBEAR_FAILURE; 555 return DROPBEAR_FAILURE;
542 576
543 /* Read the terminal modes */ 577 /* Read the terminal modes */
544 get_termmodes(chansess); 578 get_termmodes(chansess);
545 579
546 TRACE(("leave sessionpty")) 580 TRACE(("leave sessionpty"))
581 #endif
547 return DROPBEAR_SUCCESS; 582 return DROPBEAR_SUCCESS;
548 } 583 }
549 584
550 /* Handle a command request from the client. This is used for both shell 585 /* Handle a command request from the client. This is used for both shell
551 * and command-execution requests, and passes the command to 586 * and command-execution requests, and passes the command to
762 /* child */ 797 /* child */
763 798
764 /* redirect stdin/stdout/stderr */ 799 /* redirect stdin/stdout/stderr */
765 close(chansess->master); 800 close(chansess->master);
766 801
802 /* hack
767 pty_make_controlling_tty(&chansess->slave, chansess->tty); 803 pty_make_controlling_tty(&chansess->slave, chansess->tty);
804 */
768 805
769 if ((dup2(chansess->slave, STDIN_FILENO) < 0) || 806 if ((dup2(chansess->slave, STDIN_FILENO) < 0) ||
770 (dup2(chansess->slave, STDERR_FILENO) < 0) || 807 (dup2(chansess->slave, STDERR_FILENO) < 0) ||
771 (dup2(chansess->slave, STDOUT_FILENO) < 0)) { 808 (dup2(chansess->slave, STDOUT_FILENO) < 0)) {
772 TRACE(("leave ptycommand: error redirecting filedesc")) 809 TRACE(("leave ptycommand: error redirecting filedesc"))