=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/telnet/commands.c,v retrieving revision 1.75 retrieving revision 1.76 diff -c -r1.75 -r1.76 *** src/usr.bin/telnet/commands.c 2015/11/13 16:46:30 1.75 --- src/usr.bin/telnet/commands.c 2015/11/13 16:50:03 1.76 *************** *** 1,4 **** ! /* $OpenBSD: commands.c,v 1.75 2015/11/13 16:46:30 deraadt Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: commands.c,v 1.76 2015/11/13 16:50:03 deraadt Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* *************** *** 33,39 **** #include "telnet_locl.h" #include - #include #include #include #include --- 33,38 ---- *************** *** 60,66 **** } Command; static char line[256]; - static char saveline[256]; static int margc; static char *margv[20]; --- 59,64 ---- *************** *** 72,83 **** margc = 0; cp = line; - if (*cp == '!') { /* Special case shell escape */ - strlcpy(saveline, line, sizeof(saveline)); /* save for shell command */ - *argp++ = "!"; /* No room in string to get this */ - margc++; - cp++; - } while ((c = *cp)) { int inquote = 0; while (isspace((unsigned char)c)) --- 70,75 ---- *************** *** 1212,1263 **** return 1; } - int - shell(int argc, char *argv[]) - { - long oldrows, oldcols, newrows, newcols, err; - - setcommandmode(); - - err = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0; - switch(vfork()) { - case -1: - perror("Fork failed\r\n"); - break; - - case 0: - { - /* - * Fire up the shell in the child. - */ - char *shellp, *shellname; - - shellp = getenv("SHELL"); - if (shellp == NULL) - shellp = "/bin/sh"; - if ((shellname = strrchr(shellp, '/')) == 0) - shellname = shellp; - else - shellname++; - if (argc > 1) - execl(shellp, shellname, "-c", &saveline[1], (char *)NULL); - else - execl(shellp, shellname, (char *)NULL); - perror("Execl"); - _exit(1); - } - default: - (void)wait((int *)0); /* Wait for the shell to complete */ - - if (TerminalWindowSize(&newrows, &newcols) && connected && - (err || ((oldrows != newrows) || (oldcols != newcols)))) { - sendnaws(); - } - break; - } - return 1; - } - static void close_connection(void) { --- 1204,1209 ---- *************** *** 2025,2031 **** slchelp[] = "change state of special charaters ('slc ?' for more)", displayhelp[] = "display operating parameters", zhelp[] = "suspend telnet", - shellhelp[] = "invoke a subshell", envhelp[] = "change environment variables ('environ ?' for more)", modestring[] = "try to enter line or character mode ('mode ?' for more)"; --- 1971,1976 ---- *************** *** 2046,2052 **** { "slc", slchelp, slccmd, 0 }, { "z", zhelp, telnetsuspend, 0 }, - { "!", shellhelp, shell, 0 }, { "environ", envhelp, env_cmd, 0 }, { "?", helphelp, help, 0 }, { 0, 0, 0, 0 } --- 1991,1996 ----