From 244617a41d4df7719756be320f385bfc48fd4f28 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Fri, 1 Jun 2001 22:01:12 +0000 Subject: [PATCH] * login.c: Add braces around initializers. Cleanup assignments in conditionals. Include krb524.h if KRB4_CONVERT defined. * krlogind.c (main): Cleanup unused variables. (protocol): Cleanup ambiguous if-if-else warning. * krshd.c (main): Cleanup unused variables. * krlogin.c (setsignal): Declare as void. (server_message): Cleanup unused variables. * setenv.c (setenv): Declare as returning int and clean up assignments in conditionals. * kcmd.c (kcmd, rcmd_stream_init_krb5, v5_des_read): Clean up unused variables and assignments in conditionals. * forward.c (rd_and_store_for_creds): Likewise. * krcp.c (rsource): Likewise. * v4rcp.c (answer_auth): Likewise. * krsh.c (main): Declare as retuning int. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13257 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/bsd/ChangeLog | 24 +++++++++++++++++ src/appl/bsd/forward.c | 12 ++++++--- src/appl/bsd/kcmd.c | 48 ++++++++++++++++++++-------------- src/appl/bsd/krcp.c | 11 ++++---- src/appl/bsd/krlogin.c | 13 +++------ src/appl/bsd/krlogind.c | 19 +++++++------- src/appl/bsd/krsh.c | 1 + src/appl/bsd/krshd.c | 16 ++++++++---- src/appl/bsd/login.c | 58 +++++++++++++++++++++++++++-------------- src/appl/bsd/setenv.c | 5 ++-- src/appl/bsd/v4rcp.c | 6 +++-- 11 files changed, 135 insertions(+), 78 deletions(-) diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index b44534955..6d205c1aa 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,27 @@ +2001-06-01 Ezra Peisach + + * login.c: Add braces around initializers. Cleanup assignments in + conditionals. Include krb524.h if KRB4_CONVERT defined. + + * krlogind.c (main): Cleanup unused variables. + (protocol): Cleanup ambiguous if-if-else warning. + + * krshd.c (main): Cleanup unused variables. + + * krlogin.c (setsignal): Declare as void. + (server_message): Cleanup unused variables. + + * setenv.c (setenv): Declare as returning int and clean up + assignments in conditionals. + + * kcmd.c (kcmd, rcmd_stream_init_krb5, v5_des_read): Clean up + unused variables and assignments in conditionals. + * forward.c (rd_and_store_for_creds): Likewise. + * krcp.c (rsource): Likewise. + * v4rcp.c (answer_auth): Likewise. + + * krsh.c (main): Declare as retuning int. + 2001-05-25 Tom Yu * krlogind.c (protocol): Don't do TIOCPKT on systems with STREAMS diff --git a/src/appl/bsd/forward.c b/src/appl/bsd/forward.c index e266b2579..d1bbeccd9 100644 --- a/src/appl/bsd/forward.c +++ b/src/appl/bsd/forward.c @@ -45,7 +45,8 @@ rd_and_store_for_creds(context, auth_context, inbuf, ticket, ccache) *ccache = NULL; - if (retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL)) + retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL); + if (retval) return(retval); /* Set the KRB5CCNAME ENV variable to keep sessions @@ -56,13 +57,16 @@ rd_and_store_for_creds(context, auth_context, inbuf, ticket, ccache) sprintf(ccname, "FILE:/tmp/krb5cc_p%d", getpid()); setenv("KRB5CCNAME", ccname, 1); - if (retval = krb5_cc_resolve(context, ccname, ccache)) + retval = krb5_cc_resolve(context, ccname, ccache); + if (retval) goto cleanup; - if (retval = krb5_cc_initialize(context, *ccache, ticket->enc_part2->client)) + retval = krb5_cc_initialize(context, *ccache, ticket->enc_part2->client); + if (retval) goto cleanup; - if (retval = krb5_cc_store_cred(context, *ccache, *creds)) + retval = krb5_cc_store_cred(context, *ccache, *creds); + if (retval) goto cleanup; cleanup: diff --git a/src/appl/bsd/kcmd.c b/src/appl/bsd/kcmd.c index 353c611b5..903471fba 100644 --- a/src/appl/bsd/kcmd.c +++ b/src/appl/bsd/kcmd.c @@ -359,10 +359,12 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, goto bad2; } - if (status = krb5_cc_default(bsd_context, &cc)) + status = krb5_cc_default(bsd_context, &cc); + if (status) goto bad2; - if (status = krb5_cc_get_principal(bsd_context, cc, &get_cred->client)) { + status = krb5_cc_get_principal(bsd_context, cc, &get_cred->client); + if (status) { (void) krb5_cc_close(bsd_context, cc); goto bad2; } @@ -389,8 +391,9 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, goto bad2; /* Only need local address for mk_cred() to send to krlogind */ - if (status = krb5_auth_con_genaddrs(bsd_context, auth_context, s, - KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR)) + status = krb5_auth_con_genaddrs(bsd_context, auth_context, s, + KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR); + if (status) goto bad2; if (protonum == KCMD_PROTOCOL_COMPAT_HACK) { @@ -452,22 +455,25 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm, (void) write(s, locuser, strlen(locuser)+1); if (options & OPTS_FORWARD_CREDS) { /* Forward credentials */ - if (status = krb5_fwd_tgt_creds(bsd_context, auth_context, - host_save, - ret_cred->client, ret_cred->server, - 0, options & OPTS_FORWARDABLE_CREDS, - &outbuf)) { + status = krb5_fwd_tgt_creds(bsd_context, auth_context, + host_save, + ret_cred->client, ret_cred->server, + 0, options & OPTS_FORWARDABLE_CREDS, + &outbuf); + if (status) { fprintf(stderr, "kcmd: Error getting forwarded creds\n"); goto bad2; } /* Send forwarded credentials */ - if (status = krb5_write_message(bsd_context, (krb5_pointer)&s, &outbuf)) + status = krb5_write_message(bsd_context, (krb5_pointer)&s, &outbuf); + if (status) goto bad2; } else { /* Dummy write to signal no forwarding */ outbuf.length = 0; - if (status = krb5_write_message(bsd_context, (krb5_pointer)&s, &outbuf)) + status = krb5_write_message(bsd_context, (krb5_pointer)&s, &outbuf); + if (status) goto bad2; } @@ -814,7 +820,6 @@ void rcmd_stream_init_krb5(in_keyblock, encrypt_flag, lencheck, am_client, { krb5_error_code status; size_t blocksize; - krb5_boolean similar; if (!encrypt_flag) { rcmd_stream_init_normal(); @@ -835,8 +840,9 @@ void rcmd_stream_init_krb5(in_keyblock, encrypt_flag, lencheck, am_client, use_ivecs = 1; - if (status = krb5_c_block_size(bsd_context, keyblock->enctype, - &blocksize)) { + status = krb5_c_block_size(bsd_context, keyblock->enctype, + &blocksize); + if (status) { /* XXX what do I do? */ abort(); } @@ -952,9 +958,10 @@ static int v5_des_read(fd, buf, len, secondary) if ((cc = krb5_net_read(bsd_context, fd, &c, 1)) != 1) return 0; rd_len = (rd_len << 8) | c; - if (ret = krb5_c_encrypt_length(bsd_context, keyblock->enctype, - use_ivecs ? rd_len + 4 : rd_len, - &net_len)) { + ret = krb5_c_encrypt_length(bsd_context, keyblock->enctype, + use_ivecs ? rd_len + 4 : rd_len, + &net_len); + if (ret) { errno = ret; return(-1); } @@ -977,9 +984,10 @@ static int v5_des_read(fd, buf, len, secondary) plain.data = storage; /* decrypt info */ - if (ret = krb5_c_decrypt(bsd_context, keyblock, KCMD_KEYUSAGE, - use_ivecs ? encivec_i + secondary : 0, - &cipher, &plain)) { + ret = krb5_c_decrypt(bsd_context, keyblock, KCMD_KEYUSAGE, + use_ivecs ? encivec_i + secondary : 0, + &cipher, &plain); + if (ret) { /* probably out of sync */ errno = EIO; return(-1); diff --git a/src/appl/bsd/krcp.c b/src/appl/bsd/krcp.c index 21651057c..89e62ba10 100644 --- a/src/appl/bsd/krcp.c +++ b/src/appl/bsd/krcp.c @@ -471,10 +471,11 @@ int main(argc, argv) krb5_boolean similar; krb5_keyblock *key = &cred->keyblock; - if (status = krb5_c_enctype_compare(bsd_context, - ENCTYPE_DES_CBC_CRC, - cred->keyblock.enctype, - &similar)) + status = krb5_c_enctype_compare(bsd_context, + ENCTYPE_DES_CBC_CRC, + cred->keyblock.enctype, + &similar); + if (status) try_normal(orig_argv); /* doesn't return */ if (!similar) { @@ -891,7 +892,7 @@ void rsource(name, statp) closedir(d); return; } - while (dp = readdir(d)) { + while ((dp = readdir(d)) != NULL) { if (dp->d_ino == 0) continue; if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) diff --git a/src/appl/bsd/krlogin.c b/src/appl/bsd/krlogin.c index 3c96507c8..28103bb67 100644 --- a/src/appl/bsd/krlogin.c +++ b/src/appl/bsd/krlogin.c @@ -262,7 +262,7 @@ int server_message KRB5_PROTOTYPE((int)); void oob KRB5_PROTOTYPE((void)); krb5_sigtype lostpeer KRB5_PROTOTYPE((int)); #if __STDC__ -int setsignal(int sig, krb5_sigtype (*act)()); +void setsignal(int sig, krb5_sigtype (*act)()); #endif static int read_wrapper(int fd, char *buf, int size, int *got_esc); void try_normal(char **); @@ -935,6 +935,7 @@ static void doit(oldmask) /* * Trap a signal, unless it is being ignored. */ +void setsignal(sig, act) int sig; krb5_sigtype (*act)(); @@ -1393,8 +1394,6 @@ int server_message(mark) #ifndef POSIX_TERMIOS int out = FWRITE; #endif - int n; - int rcvd = 0; #ifdef POSIX_TERMIOS struct termios tty; #else @@ -1527,12 +1526,7 @@ reader(oldmask) int oldmask; #endif { -#if (defined(BSD) && BSD+0 >= 43) || defined(ultrix) - int pid = getpid(); -#else - int pid = -getpid(); -#endif -fd_set readset, excset, writeset; + fd_set readset, excset, writeset; int n, remaining, left; char *bufp = rcvbuf; char *cp; @@ -1807,7 +1801,6 @@ void try_normal(argv) { register char *nhost; #ifdef POSIX_SIGNALS - struct sigaction sa; sigset_t mask; #endif diff --git a/src/appl/bsd/krlogind.c b/src/appl/bsd/krlogind.c index 5415cf8e0..e9b4ad072 100644 --- a/src/appl/bsd/krlogind.c +++ b/src/appl/bsd/krlogind.c @@ -347,9 +347,8 @@ int main(argc, argv) { extern int opterr, optind; extern char * optarg; - int on = 1, fromlen, ch, i; + int on = 1, fromlen, ch; struct sockaddr_in from; - char *options; int debug_port = 0; int fd; int do_fork = 0; @@ -976,14 +975,13 @@ void protocol(f, p) int f, p; { unsigned char pibuf[BUFSIZ], qpibuf[BUFSIZ*2], fibuf[BUFSIZ], *pbp, *fbp; - register pcc = 0, fcc = 0; + register int pcc = 0, fcc = 0; int cc; - char cntl; #ifdef POSIX_SIGNALS struct sigaction sa; #endif #ifdef TIOCPKT - register tiocpkt_on = 0; + register int tiocpkt_on = 0; int on = 1; #endif @@ -1024,12 +1022,14 @@ void protocol(f, p) FD_SET(p, &obits); else FD_SET(f, &ibits); - if (pcc >= 0) - if (pcc) + if (pcc >= 0) { + if (pcc) { FD_SET(f, &obits); - else + } else { FD_SET(p, &ibits); - + } + } + if (select(8*sizeof(ibits), &ibits, &obits, &ebits, 0) < 0) { if (errno == EINTR) continue; @@ -1207,7 +1207,6 @@ do_krb_login(host_addr, hostname) char *host_addr, *hostname; { krb5_error_code status; - struct passwd *pwd; char *msg_fail = NULL; int valid_checksum; diff --git a/src/appl/bsd/krsh.c b/src/appl/bsd/krsh.c index c804a9535..8ec9980bd 100644 --- a/src/appl/bsd/krsh.c +++ b/src/appl/bsd/krsh.c @@ -122,6 +122,7 @@ void try_normal(char **); #define mask(s) (1 << ((s) - 1)) #endif /* POSIX_SIGNALS */ +int main(argc, argv0) int argc; char **argv0; diff --git a/src/appl/bsd/krshd.c b/src/appl/bsd/krshd.c index d5b41e687..59e517159 100644 --- a/src/appl/bsd/krshd.c +++ b/src/appl/bsd/krshd.c @@ -192,7 +192,9 @@ char *srvtab = NULL; krb5_keytab keytab = NULL; krb5_ccache ccache = NULL; int default_realm(krb5_principal principal); +#if defined(KERBEROS) && defined(LOG_OTHER_USERS) && !defined(LOG_ALL_LOGINS) static int princ_maps_to_lname(krb5_principal principal, char *luser); +#endif void fatal(int, const char *); @@ -276,9 +278,10 @@ int main(argc, argv) struct sockaddr_in from; extern int opterr, optind; extern char *optarg; - char *options; int ch; +#if 0 int i; +#endif int fd; int debug_port = 0; #ifdef KERBEROS @@ -1734,6 +1737,7 @@ void usage() +#if defined(KERBEROS) && defined(LOG_OTHER_USERS) && !defined(LOG_ALL_LOGINS) static int princ_maps_to_lname(principal, luser) krb5_principal principal; char *luser; @@ -1746,6 +1750,7 @@ static int princ_maps_to_lname(principal, luser) } return 0; } +#endif int default_realm(principal) @@ -1789,7 +1794,6 @@ recvauth(netfd, peersin, valid_checksum) krb5_auth_context auth_context = NULL; krb5_error_code status; struct sockaddr_in laddr; - char krb_vers[KRB_SENDAUTH_VLEN + 1]; int len; krb5_data inbuf; #ifdef KRB5_KRB4_COMPAT @@ -1820,11 +1824,13 @@ recvauth(netfd, peersin, valid_checksum) strcpy(v4_instance, "*"); #endif - if (status = krb5_auth_con_init(bsd_context, &auth_context)) + status = krb5_auth_con_init(bsd_context, &auth_context); + if (status) return status; - if (status = krb5_auth_con_genaddrs(bsd_context, auth_context, netfd, - KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR)) + status = krb5_auth_con_genaddrs(bsd_context, auth_context, netfd, + KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR); + if (status) return status; status = krb5_auth_con_getrcache(bsd_context, auth_context, &rcache); diff --git a/src/appl/bsd/login.c b/src/appl/bsd/login.c index 018eba987..d6ba8967c 100644 --- a/src/appl/bsd/login.c +++ b/src/appl/bsd/login.c @@ -184,6 +184,10 @@ typedef sigtype (*handler)(); #include #endif /* BIND_HACK */ +#ifdef KRB4_CONVERT +#include +#endif + /* Hacks to maintain compatability with Athena libkrb*/ #ifndef HAVE_KRB_SAVE_CREDENTIALS #define krb_save_credentials save_credentials @@ -315,6 +319,10 @@ extern int errno; char *getenv(); void dofork(); + + + +void term_init(); int doremotelogin(), do_krb_login(), rootterm(); void lgetstr(), getloginname(), checknologin(), sleepexit(); void dolastlog(), motd(), check_mail(); @@ -342,12 +350,12 @@ static struct login_confs { int *flag; } login_conf_set[] = { #ifdef KRB5_GET_TICKETS - "krb5_get_tickets", &login_krb5_get_tickets, + {"krb5_get_tickets", &login_krb5_get_tickets}, #endif #ifdef KRB5_KRB4_COMPAT - "krb4_get_tickets", &login_krb4_get_tickets, - "krb4_convert", &login_krb4_convert, - "krb4_run_aklog", &login_krb_run_aklog, + {"krb4_get_tickets", &login_krb4_get_tickets}, + {"krb4_convert", &login_krb4_convert}, + {"krb4_run_aklog", &login_krb_run_aklog}, #endif /* KRB5_KRB4_COMPAT */ }; @@ -581,16 +589,18 @@ int try_krb5 (me_p, pass) krb5_error_code code; krb5_principal me; - if (code = krb5_parse_name(kcontext, username, &me)) { + code = krb5_parse_name(kcontext, username, &me); + if (code) { com_err ("login", code, "when parsing name %s",username); return 0; } *me_p = me; - if (code = krb5_get_init_creds_password(kcontext, &my_creds, me, pass, - krb5_prompter_posix, NULL, - 0, NULL, NULL)) { + code = krb5_get_init_creds_password(kcontext, &my_creds, me, pass, + krb5_prompter_posix, NULL, + 0, NULL, NULL); + if (code) { if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY) fprintf (stderr, "%s: Kerberos password incorrect\n", @@ -621,6 +631,7 @@ int have_v5_tickets (me) #endif /* KRB5_GET_TICKETS */ #ifdef KRB4_CONVERT +int try_convert524(kcontext, me, use_ccache) krb5_context kcontext; krb5_principal me; @@ -705,6 +716,7 @@ try_convert524(kcontext, me, use_ccache) #endif #ifdef KRB4_GET_TICKETS +int try_krb4 (me, user_pwstring) krb5_principal me; char *user_pwstring; @@ -773,7 +785,9 @@ int verify_krb_v4_tgt (realm) AUTH_DAT authdata; unsigned long addr; static /*const*/ char rcmd[] = "rcmd"; +#if 0 char key[8]; +#endif int krbval, retval, have_keys; if (gethostname(hostname, sizeof(hostname)) == -1) { @@ -852,7 +866,6 @@ void destroy_tickets() { #ifdef KRB5_GET_TICKETS krb5_ccache cache; - krb5_error_code retval; if (login_krb5_get_tickets) { if(!krb5_cc_default(kcontext, &cache)) @@ -1327,9 +1340,10 @@ int main(argc, argv) break; if (got_v5_tickets) { - if (retval = krb5_verify_init_creds(kcontext, &my_creds, NULL, - NULL, &xtra_creds, - NULL)) { + retval = krb5_verify_init_creds(kcontext, &my_creds, NULL, + NULL, &xtra_creds, + NULL); + if (retval) { com_err("login", retval, "while verifying initial ticket"); #ifndef SYSLOG42 syslog(LOG_NOTICE|LOG_AUTH, @@ -1567,8 +1581,9 @@ int main(argc, argv) } else { mcreds.ticket_flags = 0; - if (retval = krb5_cc_retrieve_cred(kcontext, ccache, 0, - &mcreds, &save_v5creds)) { + retval = krb5_cc_retrieve_cred(kcontext, ccache, 0, + &mcreds, &save_v5creds); + if (retval) { syslog(LOG_ERR, "%s while retrieiving V5 initial ticket for copy", error_message(retval)); @@ -1642,11 +1657,12 @@ int main(argc, argv) /* set up credential cache -- obeying KRB5_ENV_CCNAME set earlier */ /* (KRB5_ENV_CCNAME == "KRB5CCNAME" via osconf.h) */ - if (retval = krb5_cc_default(kcontext, &ccache)) { + if ((retval = krb5_cc_default(kcontext, &ccache))) { com_err(argv[0], retval, "while getting default ccache"); - } else if (retval = krb5_cc_initialize(kcontext, ccache, me)) { + } else if ((retval = krb5_cc_initialize(kcontext, ccache, me))) { com_err(argv[0], retval, "when initializing cache"); - } else if (retval = krb5_cc_store_cred(kcontext, ccache, &my_creds)) { + } else if ((retval = krb5_cc_store_cred(kcontext, ccache, + &my_creds))) { com_err(argv[0], retval, "while storing credentials"); } else if (xtra_creds && (retval = krb5_cc_copy_creds(kcontext, xtra_creds, @@ -1661,8 +1677,8 @@ int main(argc, argv) syslog(LOG_ERR, "%s while re-initializing V5 ccache as user", error_message(retval)); - } else if (retval = krb5_cc_store_cred(kcontext, ccache, - &save_v5creds)) { + } else if ((retval = krb5_cc_store_cred(kcontext, ccache, + &save_v5creds))) { syslog(LOG_ERR, "%s while re-storing V5 credentials as user", error_message(retval)); @@ -1855,6 +1871,7 @@ speed_t b_speeds[] = { }; #endif +void term_init (do_rlogin) { int line_speed = -1; @@ -1999,7 +2016,7 @@ void getloginname() if (p < nbuf + UT_NAMESIZE) *p++ = ch; } - if (p > nbuf) + if (p > nbuf) { if (nbuf[0] == '-') fprintf(stderr, "login names may not start with '-'.\n"); @@ -2008,6 +2025,7 @@ void getloginname() username = nbuf; break; } + } } } diff --git a/src/appl/bsd/setenv.c b/src/appl/bsd/setenv.c index 96d4a1e9e..fad8f594e 100644 --- a/src/appl/bsd/setenv.c +++ b/src/appl/bsd/setenv.c @@ -25,6 +25,7 @@ * Set the value of the environmental variable "name" to be * "value". If rewrite is set, replace any current value. */ +int setenv(name, value, rewrite) register char *name, *value; int rewrite; @@ -42,7 +43,7 @@ setenv(name, value, rewrite) if (!rewrite) return(0); if (strlen(C) >= l_value) { /* old larger; copy over */ - while (*C++ = *value++); + while ((*C++ = *value++)); return(0); } } @@ -74,7 +75,7 @@ setenv(name, value, rewrite) malloc((u_int)((int)(C - name) + l_value + 2)))) return(-1); for (C = environ[offset]; (*C = *name++) &&( *C != '='); ++C); - for (*C++ = '='; *C++ = *value++;); + for (*C++ = '='; (*C++ = *value++);); return(0); } diff --git a/src/appl/bsd/v4rcp.c b/src/appl/bsd/v4rcp.c index 326778350..4bff50fea 100644 --- a/src/appl/bsd/v4rcp.c +++ b/src/appl/bsd/v4rcp.c @@ -1013,7 +1013,8 @@ answer_auth() local.sin_addr.s_addr = inet_addr(envaddr); #endif local.sin_family = AF_INET; - if (envaddr = getenv("KRB5LOCALPORT")) + envaddr = getenv("KRB5LOCALPORT"); + if (envaddr) local.sin_port = htons(atoi(envaddr)); else local.sin_port = 0; @@ -1028,7 +1029,8 @@ answer_auth() foreign.sin_addr.s_addr = inet_addr(envaddr); #endif foreign.sin_family = AF_INET; - if (envaddr = getenv("KRB5REMOTEPORT")) + envaddr = getenv("KRB5REMOTEPORT"); + if (envaddr) foreign.sin_port = htons(atoi(envaddr)); else foreign.sin_port = 0; -- 2.26.2