=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/telnet/commands.c,v retrieving revision 1.2 retrieving revision 1.3 diff -c -r1.2 -r1.3 *** src/usr.bin/telnet/commands.c 1996/01/05 16:41:21 1.2 --- src/usr.bin/telnet/commands.c 1996/03/27 19:32:58 1.3 *************** *** 1,3 **** --- 1,6 ---- + /* $OpenBSD: commands.c,v 1.3 1996/03/27 19:32:58 niklas Exp $ */ + /* $NetBSD: commands.c,v 1.13 1996/02/28 21:03:53 thorpej Exp $ */ + /* * Copyright (c) 1988, 1990, 1993 * The Regents of the University of California. All rights reserved. *************** *** 32,39 **** */ #ifndef lint ! /* from: static char sccsid[] = "@(#)commands.c 8.1 (Berkeley) 6/6/93"; */ ! static char *rcsid = "$Id: commands.c,v 1.2 1996/01/05 16:41:21 deraadt Exp $"; #endif /* not lint */ #if defined(unix) --- 35,46 ---- */ #ifndef lint ! #if 0 ! static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; ! static char rcsid[] = "$NetBSD: commands.c,v 1.13 1996/02/28 21:03:53 thorpej Exp $"; ! #else ! static char rcsid[] = "$OpenBSD: commands.c,v 1.3 1996/03/27 19:32:58 niklas Exp $"; ! #endif #endif /* not lint */ #if defined(unix) *************** *** 59,64 **** --- 66,73 ---- #include #include + #include + #define P __P #include "general.h" *************** *** 77,85 **** #include ! #ifndef MAXHOSTNAMELEN ! #define MAXHOSTNAMELEN 64 ! #endif MAXHOSTNAMELEN #if defined(IPPROTO_IP) && defined(IP_TOS) int tos = -1; --- 86,94 ---- #include ! #ifndef MAXHOSTNAMELEN ! #define MAXHOSTNAMELEN 64 ! #endif MAXHOSTNAMELEN #if defined(IPPROTO_IP) && defined(IP_TOS) int tos = -1; *************** *** 235,241 **** * the "send" command. * */ ! struct sendlist { char *name; /* How user refers to it (case independent) */ char *help; /* Help information (0 ==> no help) */ --- 244,250 ---- * the "send" command. * */ ! struct sendlist { char *name; /* How user refers to it (case independent) */ char *help; /* Help information (0 ==> no help) */ *************** *** 413,419 **** extern char *telopts[]; register int val = 0; ! if (isprefix(name, "help") || isprefix(name, "?")) { register int col, len; printf("Usage: send %s \n", cmd); --- 422,428 ---- extern char *telopts[]; register int val = 0; ! if (isprefix(name, "?")) { register int col, len; printf("Usage: send %s \n", cmd); *************** *** 1333,1339 **** (void) kill(0, SIGTSTP); /* * If we didn't get the window size before the SUSPEND, but we ! * can get them now (???), then send the NAWS to make sure that * we are set up for the right window size. */ if (TerminalWindowSize(&newrows, &newcols) && connected && --- 1342,1348 ---- (void) kill(0, SIGTSTP); /* * If we didn't get the window size before the SUSPEND, but we ! * can get them now (?), then send the NAWS to make sure that * we are set up for the right window size. */ if (TerminalWindowSize(&newrows, &newcols) && connected && *************** *** 1373,1384 **** * Fire up the shell in the child. */ register char *shellp, *shellname; ! extern char *rindex(); shellp = getenv("SHELL"); if (shellp == NULL) shellp = "/bin/sh"; ! if ((shellname = rindex(shellp, '/')) == 0) shellname = shellp; else shellname++; --- 1382,1393 ---- * Fire up the shell in the child. */ register char *shellp, *shellname; ! extern char *strrchr(); shellp = getenv("SHELL"); if (shellp == NULL) shellp = "/bin/sh"; ! if ((shellname = strrchr(shellp, '/')) == 0) shellname = shellp; else shellname++; *************** *** 1514,1527 **** } c = getslc(argv[1]); if (c == 0) { ! fprintf(stderr, "'%s': unknown argument ('slc ?' for help).\n", argv[1]); ! return 0; } if (Ambiguous(c)) { ! fprintf(stderr, "'%s': ambiguous argument ('slc ?' for help).\n", argv[1]); ! return 0; } (*c->handler)(c->arg); slcstate(); --- 1523,1536 ---- } c = getslc(argv[1]); if (c == 0) { ! fprintf(stderr, "'%s': unknown argument ('slc ?' for help).\n", argv[1]); ! return 0; } if (Ambiguous(c)) { ! fprintf(stderr, "'%s': ambiguous argument ('slc ?' for help).\n", argv[1]); ! return 0; } (*c->handler)(c->arg); slcstate(); *************** *** 1610,1623 **** } c = getenvcmd(argv[1]); if (c == 0) { ! fprintf(stderr, "'%s': unknown argument ('environ ?' for help).\n", argv[1]); ! return 0; } if (Ambiguous(c)) { ! fprintf(stderr, "'%s': ambiguous argument ('environ ?' for help).\n", argv[1]); ! return 0; } if (c->narg + 2 != argc) { fprintf(stderr, --- 1619,1632 ---- } c = getenvcmd(argv[1]); if (c == 0) { ! fprintf(stderr, "'%s': unknown argument ('environ ?' for help).\n", argv[1]); ! return 0; } if (Ambiguous(c)) { ! fprintf(stderr, "'%s': ambiguous argument ('environ ?' for help).\n", argv[1]); ! return 0; } if (c->narg + 2 != argc) { fprintf(stderr, *************** *** 1660,1669 **** extern char **environ; register char **epp, *cp; register struct env_lst *ep; ! extern char *index(); for (epp = environ; *epp; epp++) { ! if (cp = index(*epp, '=')) { *cp = '\0'; ep = env_define((unsigned char *)*epp, (unsigned char *)cp+1); --- 1669,1678 ---- extern char **environ; register char **epp, *cp; register struct env_lst *ep; ! extern char *strchr(); for (epp = environ; *epp; epp++) { ! if (cp = strchr(*epp, '=')) { *cp = '\0'; ep = env_define((unsigned char *)*epp, (unsigned char *)cp+1); *************** *** 1678,1686 **** */ if ((ep = env_find("DISPLAY")) && ((*ep->value == ':') ! || (strncmp((char *)ep->value, "unix:", 5) == 0))) { char hbuf[256+1]; ! char *cp2 = index((char *)ep->value, ':'); gethostname(hbuf, 256); hbuf[256] = '\0'; --- 1687,1695 ---- */ if ((ep = env_find("DISPLAY")) && ((*ep->value == ':') ! || (strncmp((char *)ep->value, "unix:", 5) == 0))) { char hbuf[256+1]; ! char *cp2 = strchr((char *)ep->value, ':'); gethostname(hbuf, 256); hbuf[256] = '\0'; *************** *** 1772,1778 **** { register struct env_lst *ep; ! if (my_state_is_wont(TELOPT_NEW_ENVIRON) #ifdef OLD_ENVIRON && my_state_is_wont(TELOPT_OLD_ENVIRON) #endif --- 1781,1787 ---- { register struct env_lst *ep; ! if (my_state_is_wont(TELOPT_NEW_ENVIRON) #ifdef OLD_ENVIRON && my_state_is_wont(TELOPT_OLD_ENVIRON) #endif *************** *** 1885,1892 **** }; extern int ! auth_enable P((int)), ! auth_disable P((int)), auth_status P((void)); static int auth_help P((void)); --- 1894,1901 ---- }; extern int ! auth_enable P((char *)), ! auth_disable P((char *)), auth_status P((void)); static int auth_help P((void)); *************** *** 1925,1941 **** { struct authlist *c; c = (struct authlist *) genget(argv[1], (char **) AuthList, sizeof(struct authlist)); if (c == 0) { ! fprintf(stderr, "'%s': unknown argument ('auth ?' for help).\n", argv[1]); ! return 0; } if (Ambiguous(c)) { ! fprintf(stderr, "'%s': ambiguous argument ('auth ?' for help).\n", argv[1]); ! return 0; } if (c->narg + 2 != argc) { fprintf(stderr, --- 1934,1956 ---- { struct authlist *c; + if (argc < 2) { + fprintf(stderr, + "Need an argument to 'auth' command. 'auth ?' for help.\n"); + return 0; + } + c = (struct authlist *) genget(argv[1], (char **) AuthList, sizeof(struct authlist)); if (c == 0) { ! fprintf(stderr, "'%s': unknown argument ('auth ?' for help).\n", argv[1]); ! return 0; } if (Ambiguous(c)) { ! fprintf(stderr, "'%s': ambiguous argument ('auth ?' for help).\n", argv[1]); ! return 0; } if (c->narg + 2 != argc) { fprintf(stderr, *************** *** 2081,2087 **** char *cmd, *hostp = 0, *portp = 0, *user = 0; /* clear the socket address prior to use */ ! bzero((char *)&sin, sizeof(sin)); if (connected) { printf("?Already connected to %s\n", hostname); --- 2096,2102 ---- char *cmd, *hostp = 0, *portp = 0, *user = 0; /* clear the socket address prior to use */ ! memset((char *)&sin, 0, sizeof(sin)); if (connected) { printf("?Already connected to %s\n", hostname); *************** *** 2099,2105 **** cmd = *argv; --argc; ++argv; while (argc) { ! if (isprefix(*argv, "?")) goto usage; if (strcmp(*argv, "-l") == 0) { --argc; ++argv; --- 2114,2120 ---- cmd = *argv; --argc; ++argv; while (argc) { ! if (strcmp(*argv, "help") == 0 || isprefix(*argv, "?")) goto usage; if (strcmp(*argv, "-l") == 0) { --argc; ++argv; *************** *** 2164,2180 **** if (host) { sin.sin_family = host->h_addrtype; #if defined(h_addr) /* In 4.3, this is a #define */ ! memcpy((caddr_t)&sin.sin_addr, host->h_addr_list[0], host->h_length); #else /* defined(h_addr) */ ! memcpy((caddr_t)&sin.sin_addr, host->h_addr, host->h_length); #endif /* defined(h_addr) */ strncpy(_hostname, host->h_name, sizeof(_hostname)); _hostname[sizeof(_hostname)-1] = '\0'; hostname = _hostname; } else { herror(hostp); ! setuid(getuid()); return 0; } } --- 2179,2195 ---- if (host) { sin.sin_family = host->h_addrtype; #if defined(h_addr) /* In 4.3, this is a #define */ ! memmove((caddr_t)&sin.sin_addr, host->h_addr_list[0], host->h_length); #else /* defined(h_addr) */ ! memmove((caddr_t)&sin.sin_addr, host->h_addr, host->h_length); #endif /* defined(h_addr) */ strncpy(_hostname, host->h_name, sizeof(_hostname)); _hostname[sizeof(_hostname)-1] = '\0'; hostname = _hostname; } else { herror(hostp); ! setuid(getuid()); return 0; } } *************** *** 2194,2200 **** sin.sin_port = sp->s_port; else { printf("%s: bad port number\n", portp); ! setuid(getuid()); return 0; } } else { --- 2209,2215 ---- sin.sin_port = sp->s_port; else { printf("%s: bad port number\n", portp); ! setuid(getuid()); return 0; } } else { *************** *** 2208,2214 **** sp = getservbyname("telnet", "tcp"); if (sp == 0) { fprintf(stderr, "telnet: tcp/telnet: unknown service\n"); ! setuid(getuid()); return 0; } sin.sin_port = sp->s_port; --- 2223,2229 ---- sp = getservbyname("telnet", "tcp"); if (sp == 0) { fprintf(stderr, "telnet: tcp/telnet: unknown service\n"); ! setuid(getuid()); return 0; } sin.sin_port = sp->s_port; *************** *** 2235,2241 **** tos = tp->t_tos; # endif if (tos < 0) ! tos = IPTOS_LOWDELAY; if (tos && (setsockopt(net, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0) --- 2250,2256 ---- tos = tp->t_tos; # endif if (tos < 0) ! tos = IPTOS_LOWDELAY; /* Low Delay bit */ if (tos && (setsockopt(net, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0) *************** *** 2258,2264 **** errno = oerrno; perror((char *)0); host->h_addr_list++; ! memcpy((caddr_t)&sin.sin_addr, host->h_addr_list[0], host->h_length); (void) NetClose(net); continue; --- 2273,2279 ---- errno = oerrno; perror((char *)0); host->h_addr_list++; ! memmove((caddr_t)&sin.sin_addr, host->h_addr_list[0], host->h_length); (void) NetClose(net); continue; *************** *** 2436,2442 **** goto getline; *cp = '\0'; if (rlogin == _POSIX_VDISABLE) ! printf("%s\n", line); } else { getline: if (rlogin != _POSIX_VDISABLE) --- 2451,2457 ---- goto getline; *cp = '\0'; if (rlogin == _POSIX_VDISABLE) ! printf("%s\n", line); } else { getline: if (rlogin != _POSIX_VDISABLE) *************** *** 2639,2648 **** * *cpp: If *cpp was equal to NULL, it will be filled * in with a pointer to our static area that has * the option filled in. This will be 32bit aligned. ! * * *lenp: This will be filled in with how long the option * pointed to by *cpp is. ! * */ unsigned long sourceroute(arg, cpp, lenp) --- 2654,2663 ---- * *cpp: If *cpp was equal to NULL, it will be filled * in with a pointer to our static area that has * the option filled in. This will be 32bit aligned. ! * * *lenp: This will be filled in with how long the option * pointed to by *cpp is. ! * */ unsigned long sourceroute(arg, cpp, lenp) *************** *** 2736,2751 **** sin_addr.s_addr = tmp; } else if (host = gethostbyname(cp)) { #if defined(h_addr) ! memcpy((caddr_t)&sin_addr, host->h_addr_list[0], host->h_length); #else ! memcpy((caddr_t)&sin_addr, host->h_addr, host->h_length); #endif } else { *cpp = cp; return(0); } ! memcpy(lsrp, (char *)&sin_addr, 4); lsrp += 4; if (cp2) cp = cp2; --- 2751,2766 ---- sin_addr.s_addr = tmp; } else if (host = gethostbyname(cp)) { #if defined(h_addr) ! memmove((caddr_t)&sin_addr, host->h_addr_list[0], host->h_length); #else ! memmove((caddr_t)&sin_addr, host->h_addr, host->h_length); #endif } else { *cpp = cp; return(0); } ! memmove(lsrp, (char *)&sin_addr, 4); lsrp += 4; if (cp2) cp = cp2;