diff options
Diffstat (limited to 'eBones/usr.bin/telnet/commands.c')
-rw-r--r-- | eBones/usr.bin/telnet/commands.c | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/eBones/usr.bin/telnet/commands.c b/eBones/usr.bin/telnet/commands.c index 8e67187..c642877 100644 --- a/eBones/usr.bin/telnet/commands.c +++ b/eBones/usr.bin/telnet/commands.c @@ -120,6 +120,37 @@ static char saveline[256]; static int margc; static char *margv[20]; +#if defined(SKEY) +#include <sys/wait.h> +#define PATH_SKEY "/usr/bin/key" + int +skey_calc(argc, argv) + int argc; + char **argv; +{ + int status; + + if(argc != 3) { + printf("%s sequence challenge\n", argv[0]); + return; + } + + switch(fork()) { + case 0: + execv(PATH_SKEY, argv); + exit (1); + case -1: + perror("fork"); + break; + default: + (void) wait(&status); + if (WIFEXITED(status)) + return (WEXITSTATUS(status)); + return (0); + } +} +#endif + static void makeargv() { @@ -511,7 +542,7 @@ togdebug() } #else /* NOT43 */ if (debug) { - if (net > 0 && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 0, 0) < 0) + if (net > 0 && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 1) < 0) perror("setsockopt (SO_DEBUG)"); } else printf("Cannot turn off socket debugging\n"); @@ -2330,10 +2361,15 @@ tn(argc, argv) } else { #endif temp = inet_addr(hostp); - if (temp != (unsigned long) -1) { - sin.sin_addr.s_addr = temp; - sin.sin_family = AF_INET; - (void) strcpy(_hostname, hostp); + if (temp != INADDR_NONE) { + sin.sin_addr.s_addr = temp; + sin.sin_family = AF_INET; + host = gethostbyaddr((char *)&temp, sizeof(temp), AF_INET); + if (host) + (void) strncpy(_hostname, host->h_name, sizeof(_hostname)); + else + (void) strncpy(_hostname, hostp, sizeof(_hostname)); + _hostname[sizeof(_hostname)-1] = '\0'; hostname = _hostname; } else { host = gethostbyname(hostp); @@ -2500,6 +2536,9 @@ static char #if defined(unix) zhelp[] = "suspend telnet", #endif /* defined(unix) */ +#if defined(SKEY) + skeyhelp[] = "compute response to s/key challenge", +#endif shellhelp[] = "invoke a subshell", envhelp[] = "change environment variables ('environ ?' for more)", modestring[] = "try to enter line or character mode ('mode ?' for more)"; @@ -2536,6 +2575,9 @@ static Command cmdtab[] = { #endif { "environ", envhelp, env_cmd, 0 }, { "?", helphelp, help, 0 }, +#if defined(SKEY) + { "skey", skeyhelp, skey_calc, 0 }, +#endif { 0, 0, 0, 0 } }; @@ -2721,7 +2763,7 @@ cmdrc(m1, m2) if (rcname == 0) { rcname = getenv("HOME"); - if (rcname) + if (rcname && (strlen(rcname) + 10) < sizeof(rcbuf)) strcpy(rcbuf, rcname); else rcbuf[0] = '\0'; |