# HG changeset patch # User matt-ucc@ucc.asn.au # Date 1143311735 0 # Node ID 6e5f8ce73bf2efe3f0226858f5222e816b8e676b # Parent 24b19535264b535621ed321ad818f017b44148f1 add break handler diff -r 24b19535264b -r 6e5f8ce73bf2 svr-chansession.c --- a/svr-chansession.c Sat Mar 25 17:31:52 2006 +0000 +++ b/svr-chansession.c Sat Mar 25 18:35:35 2006 +0000 @@ -63,6 +63,7 @@ static void get_termmodes(struct ChanSess *chansess); static void serial_connect(struct Channel *channel); +static int sessionbreak(struct ChanSess *chansess); /* required to clear environment */ extern char** environ; @@ -317,9 +318,13 @@ dropbear_assert(chansess != NULL); TRACE(("type is %s", type)) +#if 0 + hack if (strcmp(type, "window-change") == 0) { ret = sessionwinchange(chansess); - } else if (strcmp(type, "shell") == 0) { + } else +#endif + if (strcmp(type, "shell") == 0) { ret = sessioncommand(channel, chansess, 0, 0); } else if (strcmp(type, "pty-req") == 0) { ret = sessionpty(chansess); @@ -337,6 +342,8 @@ #endif } else if (strcmp(type, "signal") == 0) { ret = sessionsignal(chansess); + } else if (strcmp(type, "break") == 0) { + ret = sessionbreak(chansess); } else { /* etc, todo "env", "subsystem" */ } @@ -355,6 +362,30 @@ TRACE(("leave chansessionrequest")) } +static int sessionbreak(struct ChanSess *chansess) { + + int v; + char* argv[3]; + TRACE(("break!!!!")) + + v = fork(); + if (v < 0) { + dropbear_exit("failed for for break"); + } else if (v == 0) { + /* child */ + argv[0] = "mfctl"; + argv[1] = "b"; + argv[2] = NULL; + + execv("/etc/mfctl", argv); + dropbear_log(LOG_INFO, "break failed, eh?"); + + } else { + /* parent - do nothing */ + } + + return DROPBEAR_SUCCESS; +} /* Send a signal to a session's process as requested by the client*/ static int sessionsignal(struct ChanSess *chansess) { @@ -514,6 +545,9 @@ unsigned char namebuf[65]; TRACE(("enter sessionpty")) + /* Axis hack */ + TRACE(("this does nothing")) +#if 0 chansess->term = buf_getstring(ses.payload, &termlen); if (termlen > MAX_TERM_LEN) { /* TODO send disconnect ? */ @@ -544,6 +578,7 @@ get_termmodes(chansess); TRACE(("leave sessionpty")) +#endif return DROPBEAR_SUCCESS; } @@ -764,7 +799,9 @@ /* redirect stdin/stdout/stderr */ close(chansess->master); + /* hack pty_make_controlling_tty(&chansess->slave, chansess->tty); + */ if ((dup2(chansess->slave, STDIN_FILENO) < 0) || (dup2(chansess->slave, STDERR_FILENO) < 0) ||