From a536c89388f2859b37cfbc81160d3e523c728857 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Thu, 7 Jun 2001 17:40:17 +0000 Subject: [PATCH] * authenc.c (telnet_gets): Cleanup assignment in conditional * commands.c: Include sys/wait.h, libtelent/auth.h, libtelnet/encrypt.h for prototypes. Explicity declare functions as returning int. Assignments in conditionals cleanup. * externs.h: Add numerous prototypes. * ring.c (ring_init): Explicitly declare as returning int. * ring.h: Add prototype for ring_at_mark(). * telnet.c: Include unistd.h, libtelnet/auth.h, libtelnet/encrypt.h for prototypes. Delcare is_unique() static. Fix up format string for sprintf() to expect longs. Assignments in conditionals cleaned up. * main.c, terminal.c: Include libtelnet/encrypt.h for prototype. * utilities.c: Include sys/socket.h, libtelent/auth.h, libtelnet/encrypt.h for prototypes. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13287 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/telnet/telnet/ChangeLog | 24 ++++++++++ src/appl/telnet/telnet/authenc.c | 2 +- src/appl/telnet/telnet/commands.c | 77 +++++++++++++++++++----------- src/appl/telnet/telnet/externs.h | 43 ++++++++++++++++- src/appl/telnet/telnet/main.c | 7 ++- src/appl/telnet/telnet/ring.c | 3 +- src/appl/telnet/telnet/ring.h | 3 ++ src/appl/telnet/telnet/telnet.c | 33 ++++++++++--- src/appl/telnet/telnet/terminal.c | 4 ++ src/appl/telnet/telnet/utilities.c | 9 ++++ 10 files changed, 164 insertions(+), 41 deletions(-) diff --git a/src/appl/telnet/telnet/ChangeLog b/src/appl/telnet/telnet/ChangeLog index 6cfdcaf39..78d48a9b3 100644 --- a/src/appl/telnet/telnet/ChangeLog +++ b/src/appl/telnet/telnet/ChangeLog @@ -1,3 +1,27 @@ +2001-06-07 Ezra Peisach + + * authenc.c (telnet_gets): Cleanup assignment in conditional. + + * commands.c: Include sys/wait.h, libtelent/auth.h, + libtelnet/encrypt.h for prototypes. Explicity declare functions as + returning int. Assignments in conditionals cleanup. + + * externs.h: Add numerous prototypes. + + * ring.c (ring_init): Explicitly declare as returning int. + + * ring.h: Add prototype for ring_at_mark(). + + * telnet.c: Include unistd.h, libtelnet/auth.h, + libtelnet/encrypt.h for prototypes. Delcare is_unique() + static. Fix up format string for sprintf() to expect + longs. Assignments in conditionals cleaned up. + + * main.c, terminal.c: Include libtelnet/encrypt.h for prototype. + + * utilities.c: Include sys/socket.h, libtelent/auth.h, + libtelnet/encrypt.h for prototypes. + 2001-05-01 Ken Raeburn * telnet.c (telnet): Fix grammar in some error messages. Based on diff --git a/src/appl/telnet/telnet/authenc.c b/src/appl/telnet/telnet/authenc.c index 3f7691125..99037bb69 100644 --- a/src/appl/telnet/telnet/authenc.c +++ b/src/appl/telnet/telnet/authenc.c @@ -105,7 +105,7 @@ telnet_gets(prompt, result, length, echo) if (echo) { printf("%s", prompt); res = fgets(result, length, stdin); - } else if (res = getpass(prompt)) { + } else if ((res = getpass(prompt))) { strncpy(result, res, length); res = result; } diff --git a/src/appl/telnet/telnet/commands.c b/src/appl/telnet/telnet/commands.c index 050248141..aa10ceacd 100644 --- a/src/appl/telnet/telnet/commands.c +++ b/src/appl/telnet/telnet/commands.c @@ -50,6 +50,7 @@ #ifdef CRAY #include #endif /* CRAY */ +#include #include #include @@ -80,6 +81,13 @@ #include #endif +#ifdef ENCRYPTION +#include +#endif + +#if defined(AUTHENTICATION) || defined(ENCRYPTION) +#include +#endif #if !defined(CRAY) && !defined(sysV88) #include @@ -115,7 +123,10 @@ extern int isprefix(); extern char **genget(); extern int Ambiguous(); -static call(); +static int call(); +void cmdrc P((char *, char *)); +static int +send_tncmd P((void (*func)(), char *, char *)); typedef struct { char *name; /* command name */ @@ -145,7 +156,7 @@ makeargv() margc++; cp++; } - while (c = *cp) { + while ((c = *cp)) { register int inquote = 0; while (isspace(c)) c = *++cp; @@ -188,7 +199,7 @@ makeargv() * Todo: 1. Could take random integers (12, 0x12, 012, 0b1). */ - static + static int special(s) register char *s; { @@ -426,7 +437,7 @@ send_wontcmd(name) return(send_tncmd(send_wont, "wont", name)); } - int +static int send_tncmd(func, cmd, name) void (*func)(); char *cmd, *name; @@ -1319,7 +1330,7 @@ display(argc, argv) } } } -/*@*/optionstatus(); + /*@*/optionstatus(); #ifdef ENCRYPTION EncryptStatus(); #endif /* ENCRYPTION */ @@ -1457,8 +1468,8 @@ shell(argc, argv) extern int shell(); #endif /* !defined(TN3270) */ - /*VARARGS*/ - static +/*VARARGS*/ +static int bye(argc, argv) int argc; /* Number of arguments */ char *argv[]; /* arguments */ @@ -1488,11 +1499,13 @@ bye(argc, argv) } /*VARARGS*/ +int quit() { (void) call(bye, "bye", "fromquit", 0); Exit(0); /*NOTREACHED*/ + return 0; } /*VARARGS*/ @@ -1545,7 +1558,7 @@ slc_help() } } - static struct slclist * +static struct slclist * getslc(name) char *name; { @@ -1553,7 +1566,7 @@ getslc(name) genget(name, (char **) SlcList, sizeof(struct slclist)); } - static +static int slccmd(argc, argv) int argc; char *argv[]; @@ -1650,6 +1663,7 @@ getenvcmd(name) genget(name, (char **) EnvList, sizeof(struct envlist)); } +int env_cmd(argc, argv) int argc; char *argv[]; @@ -1715,7 +1729,7 @@ env_init() register struct env_lst *ep; for (epp = environ; *epp; epp++) { - if (cp = strchr(*epp, '=')) { + if ((cp = strchr(*epp, '='))) { *cp = '\0'; ep = env_define((unsigned char *)*epp, (unsigned char *)cp+1); @@ -1760,7 +1774,7 @@ env_define(var, value) { register struct env_lst *ep; - if (ep = env_find(var)) { + if ((ep = env_find(var))) { if (ep->var) free(ep->var); if (ep->value) @@ -1786,7 +1800,7 @@ env_undefine(var) { register struct env_lst *ep; - if (ep = env_find(var)) { + if ((ep = env_find(var))) { ep->prev->next = ep->next; if (ep->next) ep->next->prev = ep->prev; @@ -1804,7 +1818,7 @@ env_export(var) { register struct env_lst *ep; - if (ep = env_find(var)) + if ((ep = env_find(var))) ep->export = 1; } @@ -1814,7 +1828,7 @@ env_unexport(var) { register struct env_lst *ep; - if (ep = env_find(var)) + if ((ep = env_find(var))) ep->export = 0; } @@ -1867,7 +1881,7 @@ env_default(init, welldefined) return NULL; /* guessing here too -- eichin -- XXX */ } if (nep) { - while (nep = nep->next) { + while ((nep = nep->next)) { if (nep->export && (nep->welldefined == welldefined)) return(nep->var); } @@ -1881,7 +1895,7 @@ env_getvalue(var) { register struct env_lst *ep; - if (ep = env_find(var)) + if ((ep = env_find(var))) return(ep->value); return(NULL); } @@ -1982,6 +1996,7 @@ auth_help() return 0; } +int auth_cmd(argc, argv) int argc; char *argv[]; @@ -2088,6 +2103,7 @@ EncryptHelp() return 0; } +int encrypt_cmd(argc, argv) int argc; char *argv[]; @@ -2191,6 +2207,7 @@ forw_status() return(0); } +int forw_set(f_flags) int f_flags; { @@ -2198,7 +2215,7 @@ forw_set(f_flags) return(0); } - static int +static int forw_help() { struct forwlist *c; @@ -2214,6 +2231,7 @@ forw_help() return 0; } +int forw_cmd(argc, argv) int argc; char *argv[]; @@ -2285,7 +2303,7 @@ filestuff(fd) * Print status about the connection. */ /*ARGSUSED*/ - static +static int status(argc, argv) int argc; char *argv[]; @@ -2449,7 +2467,7 @@ tn(argc, argv) } else { #endif temp = inet_addr(hostp); - if (temp & 0xffffffff != INADDR_NONE) { + if ((temp & 0xffffffff) != INADDR_NONE) { sin.sin_addr.s_addr = temp; sin.sin_family = AF_INET; (void) strncpy(_hostname, hostp, sizeof(_hostname) - 1); @@ -2584,8 +2602,9 @@ tn(argc, argv) user = getenv("USER"); if (user == NULL || - (pw = getpwnam(user)) && pw->pw_uid != getuid()) { - if (pw = getpwuid(getuid())) + ((pw = getpwnam(user)) && pw->pw_uid != getuid())) { + pw = getpwuid(getuid()); + if (pw) user = pw->pw_name; else user = NULL; @@ -2605,6 +2624,7 @@ tn(argc, argv) (void) NetClose(net); ExitString("Connection closed by foreign host.\r\n",1); /*NOTREACHED*/ + return 0; } #define HELPINDENT (sizeof ("connect")) @@ -2678,7 +2698,7 @@ static Command cmdtab[] = { #endif { "environ", envhelp, env_cmd, 0 }, { "?", helphelp, help, 0 }, - 0 + { 0, 0, 0, 0 } }; static char crmodhelp[] = "deprecated command -- use 'toggle crmod' instead"; @@ -2688,7 +2708,7 @@ static Command cmdtab2[] = { { "help", 0, help, 0 }, { "escape", escapehelp, setescape, 0 }, { "crmod", crmodhelp, togcrmod, 0 }, - 0 + { 0, 0, 0, 0 } }; @@ -2697,7 +2717,7 @@ static Command cmdtab2[] = { */ /*VARARGS1*/ - static +static int call(va_alist) va_dcl { @@ -2723,7 +2743,7 @@ getcmd(name) { Command *cm; - if (cm = (Command *) genget(name, (char **) cmdtab, sizeof(Command))) + if ((cm = (Command *) genget(name, (char **) cmdtab, sizeof(Command)))) return cm; return (Command *) genget(name, (char **) cmdtab2, sizeof(Command)); } @@ -2812,7 +2832,7 @@ command(top, tbuf, cnt) /* * Help command. */ - static +static int help(argc, argv) int argc; char *argv[]; @@ -2845,6 +2865,7 @@ help(argc, argv) static char *rcname = 0; static char rcbuf[128]; +void cmdrc(m1, m2) char *m1, *m2; { @@ -3040,7 +3061,7 @@ sourceroute(arg, cpp, lenp) for (c = 0;;) { if (c == ':') cp2 = 0; - else for (cp2 = cp; c = *cp2; cp2++) { + else for (cp2 = cp; (c = *cp2); cp2++) { if (c == ',') { *cp2++ = '\0'; if (*cp2 == '@') @@ -3058,7 +3079,7 @@ sourceroute(arg, cpp, lenp) if ((tmp = inet_addr(cp)) != -1) { sin_addr.s_addr = tmp; - } else if (host = gethostbyname(cp)) { + } else if ((host = gethostbyname(cp))) { #if defined(h_addr) memcpy((caddr_t)&sin_addr, host->h_addr_list[0], sizeof(sin_addr)); diff --git a/src/appl/telnet/telnet/externs.h b/src/appl/telnet/telnet/externs.h index f35cdedaf..81652a2ad 100644 --- a/src/appl/telnet/telnet/externs.h +++ b/src/appl/telnet/telnet/externs.h @@ -258,19 +258,31 @@ extern void command P((int, char *, int)), Dump P((int, unsigned char *, int)), init_3270 P((void)), + init_terminal P((void)), + init_telnet P((void)), + init_network P((void)), + init_sys P((void)), printoption P((char *, int, int)), printsub P((int, unsigned char *, int)), sendnaws P((void)), + sendabort P((void)), + sendeof P((void)), + sendayt P((void)), + sendsusp P((void)), setconnmode P((int)), setcommandmode P((void)), setneturg P((void)), + set_escape_char P((char *)), sys_telnet_init P((void)), telnet P((char *)), tel_enter_binary P((int)), + tel_leave_binary P((int)), + TerminalDefaultChars P((void)), TerminalFlushOutput P((void)), TerminalNewMode P((int)), TerminalRestoreState P((void)), TerminalSaveState P((void)), + TerminalSpeeds P((long *, long *)), tninit P((void)), upcase P((char *)), willoption P((int)), @@ -290,6 +302,10 @@ extern void lm_mode P((unsigned char *, int, int)); extern void + ExitString P((char *, int)), + Exit P((int)), + SetForExit P((void)), + EmptyTerminal P((void)), slc_init P((void)), slcstate P((void)), slc_mode_export P((void)), @@ -301,15 +317,38 @@ extern void slc_start_reply P((void)), slc_add_reply P((int, int, int)), slc_end_reply P((void)); + extern int - slc_update P((void)); + quit P((void)), + ttyflush P((int)), + rlogin_susp P((void)), + tn P((int, char **)), + getconnmode P((void)), + netflush P((void)), + NetClose P((int)), + opt_welldefined P((char *)), + process_rings P((int, int, int, int, int, int)), + slc_update P((void)), + Scheduler P((int)), + SetSockOpt P((int, int, int, int)), + stilloob P((void)), + telrcv P((void)), + telnet_spin P((void)), + TerminalWrite P((char *, int)), + TerminalRead P((char *, int)), + TerminalAutoFlush P((void)), + TerminalSpecialChars P((int)), + TerminalWindowSize P((long *, long *)); + extern void + env_init P((void)), env_opt P((unsigned char *, int)), env_opt_start P((void)), env_opt_start_info P((void)), env_opt_add P((unsigned char *)), - env_opt_end P((int)); + env_opt_end P((int)), + optionstatus P((void)); extern unsigned char *env_default P((int, int)), diff --git a/src/appl/telnet/telnet/main.c b/src/appl/telnet/telnet/main.c index d22b1affe..f6b8d1c13 100644 --- a/src/appl/telnet/telnet/main.c +++ b/src/appl/telnet/telnet/main.c @@ -41,7 +41,9 @@ char copyright[] = #include #include - +#ifdef ENCRYPTION +#include +#endif # include @@ -110,6 +112,7 @@ usage() /* see forward.c -- indicate that we're in telnet, not telnetd. */ char *line = 0; +int main(argc, argv) int argc; char *argv[]; @@ -132,7 +135,7 @@ main(argc, argv) TerminalSaveState(); - if (prompt = strrchr(argv[0], '/')) + if ((prompt = strrchr(argv[0], '/'))) ++prompt; else prompt = argv[0]; diff --git a/src/appl/telnet/telnet/ring.c b/src/appl/telnet/telnet/ring.c index a1d62f115..fdff682b5 100644 --- a/src/appl/telnet/telnet/ring.c +++ b/src/appl/telnet/telnet/ring.c @@ -103,7 +103,8 @@ static u_long ring_clock = 0; /* Buffer state transition routines */ - ring_init(ring, buffer, count) +int +ring_init(ring, buffer, count) Ring *ring; unsigned char *buffer; int count; diff --git a/src/appl/telnet/telnet/ring.h b/src/appl/telnet/telnet/ring.h index 2a36781e5..8624e0a0e 100644 --- a/src/appl/telnet/telnet/ring.h +++ b/src/appl/telnet/telnet/ring.h @@ -103,3 +103,6 @@ extern void extern void ring_clear_mark(), ring_mark(); + +extern int + ring_at_mark P((Ring *)); diff --git a/src/appl/telnet/telnet/telnet.c b/src/appl/telnet/telnet/telnet.c index 75d78b481..ccab0afe9 100644 --- a/src/appl/telnet/telnet/telnet.c +++ b/src/appl/telnet/telnet/telnet.c @@ -33,7 +33,12 @@ /* based on @(#)telnet.c 8.1 (Berkeley) 6/6/93 */ +#ifdef HAVE_UNISTD_H +#include +#endif + #include +#include #if defined(unix) #include @@ -54,6 +59,20 @@ #include "types.h" #include "general.h" +#ifdef AUTHENTICATION +#include +#endif + +#ifdef ENCRYPTION +#include +#endif + +#if defined(AUTHENTICATION) || defined(ENCRYPTION) +#include +#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */ + +static int is_unique P((char *, char **, char **)); + #define strip(x) ((x)&0x7f) @@ -728,7 +747,7 @@ mklist(buf, name) return(unknown); } - int +static int is_unique(name, as, ae) register char *name, **as, **ae; { @@ -858,7 +877,7 @@ suboption() TerminalSpeeds(&ispeed, &ospeed); - sprintf((char *)temp, "%c%c%c%c%d,%d%c%c", IAC, SB, TELOPT_TSPEED, + sprintf((char *)temp, "%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED, TELQUAL_IS, ospeed, ispeed, IAC, SE); len = strlen((char *)temp+4) + 4; /* temp[3] is 0 ... */ @@ -1215,7 +1234,7 @@ slc_init() #define initfunc(func, flags) { \ spcp = &spc_data[func]; \ - if (spcp->valp = tcval(func)) { \ + if ((spcp->valp = tcval(func)) != NULL) { \ spcp->val = *spcp->valp; \ spcp->mylevel = SLC_VARIABLE|flags; \ } else { \ @@ -1623,12 +1642,12 @@ env_opt_add(ep) if (ep == NULL || *ep == '\0') { /* Send user defined variables first. */ env_default(1, 0); - while (ep = env_default(0, 0)) + while ((ep = env_default(0, 0)) != NULL) env_opt_add(ep); /* Now add the list of well know variables. */ env_default(1, 1); - while (ep = env_default(0, 1)) + while ((ep = env_default(0, 1)) != NULL) env_opt_add(ep); return; } @@ -1658,7 +1677,7 @@ env_opt_add(ep) else *opt_replyp++ = ENV_USERVAR; for (;;) { - while (c = *ep++) { + while ((c = *ep++)) { switch(c&0xff) { case IAC: *opt_replyp++ = IAC; @@ -1672,7 +1691,7 @@ env_opt_add(ep) } *opt_replyp++ = c; } - if (ep = vp) { + if ((ep = vp) != NULL) { #ifdef OLD_ENVIRON if (telopt_environ == TELOPT_OLD_ENVIRON) *opt_replyp++ = old_env_value; diff --git a/src/appl/telnet/telnet/terminal.c b/src/appl/telnet/telnet/terminal.c index a72852c2d..611270373 100644 --- a/src/appl/telnet/telnet/terminal.c +++ b/src/appl/telnet/telnet/terminal.c @@ -41,6 +41,10 @@ #include "externs.h" #include "types.h" +#ifdef ENCRYPTION +#include +#endif + Ring ttyoring, ttyiring; unsigned char ttyobuf[2*BUFSIZ], ttyibuf[BUFSIZ]; diff --git a/src/appl/telnet/telnet/utilities.c b/src/appl/telnet/telnet/utilities.c index 82ad84178..b4e8d0f01 100644 --- a/src/appl/telnet/telnet/utilities.c +++ b/src/appl/telnet/telnet/utilities.c @@ -38,6 +38,7 @@ #define SLC_NAMES #include #include +#include #include #include @@ -52,6 +53,14 @@ #include "externs.h" +#ifdef AUTHENTICATION +#include +#endif + +#ifdef ENCRYPTION +#include +#endif + FILE *NetTrace = 0; /* Not in bss, since needs to stay */ int prettydump; -- 2.26.2