From: Ezra Peisach Date: Mon, 26 Feb 2001 20:25:23 +0000 (+0000) Subject: *adm_conn.c, adm_rw.c, kadm5_defs.h, kpasswd.c, main.c, X-Git-Tag: krb5-1.3-alpha1~1650 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2c6ab8e1e155ebf740f98703ea04034765ccc5a3;p=krb5.git *adm_conn.c, adm_rw.c, kadm5_defs.h, kpasswd.c, main.c, proto_serv.c, srv_net.c: Warnings cleanup including assignments in conditionals, shadowed variables, unused variables, prototypes. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13029 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/v5passwdd/ChangeLog b/src/kadmin/v5passwdd/ChangeLog index 09dd46121..c054294a8 100644 --- a/src/kadmin/v5passwdd/ChangeLog +++ b/src/kadmin/v5passwdd/ChangeLog @@ -1,3 +1,9 @@ +Mon Feb 26 15:22:44 2001 Ezra Peisach + + *adm_conn.c, adm_rw.c, kadm5_defs.h, kpasswd.c, main.c, + proto_serv.c, srv_net.c: Warnings cleanup including assignments in + conditionals, shadowed variables, unused variables, prototypes. + 2000-10-17 Ezra Peisach * adm_conn.c, kpasswd.c: Argument to krb5_read_password diff --git a/src/kadmin/v5passwdd/adm_conn.c b/src/kadmin/v5passwdd/adm_conn.c index e19343a08..4428be950 100644 --- a/src/kadmin/v5passwdd/adm_conn.c +++ b/src/kadmin/v5passwdd/adm_conn.c @@ -59,7 +59,7 @@ static krb5_error_code kadm_get_creds krb5_ccache , krb5_principal, krb5_creds *, - char *, + const char *, char *, krb5_timestamp)); static krb5_error_code kadm_contact_server @@ -126,7 +126,8 @@ kadm_get_ccache(kcontext, user, ccname, ccache, client) } /* Parse the name and form our principal */ - if (kret = krb5_parse_name(kcontext, name, client)) + kret = krb5_parse_name(kcontext, name, client); + if (kret) goto cleanup; if (!ccname) { @@ -184,7 +185,7 @@ kadm_get_creds(kcontext, ccache, client, creds, prompt, oldpw, tlife) krb5_ccache ccache; krb5_principal client; krb5_creds *creds; - char *prompt; + const char *prompt; char *oldpw; krb5_timestamp tlife; { @@ -199,10 +200,12 @@ kadm_get_creds(kcontext, ccache, client, creds, prompt, oldpw, tlife) client_name = (char *) NULL; /* Get the string form for our principal */ - if (kret = krb5_unparse_name(kcontext, client, &client_name)) + kret = krb5_unparse_name(kcontext, client, &client_name); + if (kret) return(kret); - if (kret = krb5_os_localaddr(kcontext, &my_addresses)) + kret = krb5_os_localaddr(kcontext, &my_addresses); + if (kret) goto cleanup; creds->client = client; @@ -212,15 +215,16 @@ kadm_get_creds(kcontext, ccache, client, creds, prompt, oldpw, tlife) * realm name is instance * realm name is realm name */ - if (kret = krb5_build_principal_ext(kcontext, - &creds->server, - client->realm.length, - client->realm.data, - strlen(KRB5_ADM_SERVICE_INSTANCE), - KRB5_ADM_SERVICE_INSTANCE, - client->realm.length, - client->realm.data, - 0)) + kret = krb5_build_principal_ext(kcontext, + &creds->server, + client->realm.length, + client->realm.data, + strlen(KRB5_ADM_SERVICE_INSTANCE), + KRB5_ADM_SERVICE_INSTANCE, + client->realm.length, + client->realm.data, + 0); + if (kret) goto cleanup; /* Attempt to retrieve an appropriate entry from the credentials cache. */ @@ -235,15 +239,16 @@ kadm_get_creds(kcontext, ccache, client, creds, prompt, oldpw, tlife) if (prompt != (char *) NULL) { /* Read the password */ old_pwsize = KRB5_ADM_MAX_PASSWORD_LEN; - if (kret = krb5_read_password(kcontext, - prompt, - (char *) NULL, - oldpw, - &old_pwsize)) + kret = krb5_read_password(kcontext, prompt, (char *) NULL, + oldpw, &old_pwsize); + if (kret) goto cleanup; } - if (kret = krb5_timeofday(kcontext, &jetzt)) + + kret = krb5_timeofday(kcontext, &jetzt); + if (kret) goto cleanup; + if (tlife > 0) creds->times.endtime = jetzt + tlife; else @@ -480,7 +485,8 @@ kadm_contact_server(kcontext, realmp, sockp, local, remote) } in_remote.sin_port = service->s_port; - if (kret = krb5_get_krbhst(kcontext, realmp, &hostlist)) + kret = krb5_get_krbhst(kcontext, realmp, &hostlist); + if (kret) goto cleanup; /* Now count the number of hosts in the realm */ @@ -610,7 +616,7 @@ krb5_adm_connect(kcontext, user, prompt, opassword, sockp, ctxp, ccachep, ccname, tlife) krb5_context kcontext; /* Context handle (In ) */ char *user; /* User specified (In ) */ - char *prompt; /* Old password prompt (In ) */ + const char *prompt; /* Old password prompt (In ) */ char *opassword; /* Old Password (I/O) */ int *sockp; /* Socket for conn. (Out) */ krb5_auth_context *ctxp; /* Auth context (Out) */ @@ -642,19 +648,16 @@ krb5_adm_connect(kcontext, user, prompt, opassword, sockp, ctxp, /* * Find the appropriate credentials cache and set up our identity. */ - if (kret = kadm_get_ccache(kcontext, user, ccname, ccachep, &client)) + kret = kadm_get_ccache(kcontext, user, ccname, ccachep, &client); + if (kret) goto cleanup; /* * Get initial credentials. */ - if (kret = kadm_get_creds(kcontext, - *ccachep, - client, - &creds, - prompt, - opassword, - tlife)) + kret = kadm_get_creds(kcontext, *ccachep, client, &creds, + prompt, opassword, tlife); + if (kret) goto cleanup; /* @@ -667,17 +670,17 @@ krb5_adm_connect(kcontext, user, prompt, opassword, sockp, ctxp, server_realm.length = client->realm.length; memcpy(server_realm.data, client->realm.data, server_realm.length); server_realm.data[server_realm.length] = '\0'; - if (kret = kadm_contact_server(kcontext, - &server_realm, - sockp, - &local_addr, - &remote_addr)) + + kret = kadm_contact_server(kcontext, &server_realm, sockp, + &local_addr, &remote_addr); + if (kret) goto cleanup; /* * Obtain our authorization context */ - if (kret = kadm_get_auth(kcontext, ctxp, local_addr, remote_addr)) + kret = kadm_get_auth(kcontext, ctxp, local_addr, remote_addr); + if (kret) goto cleanup; /* @@ -685,21 +688,21 @@ krb5_adm_connect(kcontext, user, prompt, opassword, sockp, ctxp, */ suppl_data.data = NULL; suppl_data.length = 0; - if (kret = krb5_mk_req_extended(kcontext, - ctxp, - AP_OPTS_MUTUAL_REQUIRED, - &suppl_data, - &creds, - &request_data)) + + kret = krb5_mk_req_extended(kcontext, ctxp, AP_OPTS_MUTUAL_REQUIRED, + &suppl_data, &creds, &request_data); + if (kret) goto cleanup; - if (kret = krb5_write_message(kcontext, sockp, &request_data)) + kret = krb5_write_message(kcontext, sockp, &request_data); + if (kret) goto cleanup; /* * Now read back the response. */ - if (kret = krb5_read_message(kcontext, sockp, &response_data)) { + kret = krb5_read_message(kcontext, sockp, &response_data); + if (kret) { goto cleanup; } else { diff --git a/src/kadmin/v5passwdd/adm_rw.c b/src/kadmin/v5passwdd/adm_rw.c index 2a5e48e23..08005a882 100644 --- a/src/kadmin/v5passwdd/adm_rw.c +++ b/src/kadmin/v5passwdd/adm_rw.c @@ -107,7 +107,7 @@ krb5_send_adm_cmd(kcontext, sock, ctx, nargs, arglist) krb5_int32 nargs; /* Number of arguments (In ) */ krb5_data *arglist; /* Components to write (In ) */ { - int writebufsize; + size_t writebufsize; int i; char *writebuf; krb5_error_code ret; @@ -116,7 +116,8 @@ krb5_send_adm_cmd(kcontext, sock, ctx, nargs, arglist) /* * First check that our auth context has the right flags in it. */ - if (ret = krb5_auth_con_getflags(kcontext, ctx, &ac_flags)) + ret = krb5_auth_con_getflags(kcontext, ctx, &ac_flags); + if (ret) return(ret); if ((ac_flags & (KRB5_AUTH_CONTEXT_RET_SEQUENCE| @@ -134,7 +135,8 @@ krb5_send_adm_cmd(kcontext, sock, ctx, nargs, arglist) writebufsize += arglist[i].length; /* for actual arg */ } - if (writebuf = (char *) malloc(writebufsize)) { + writebuf = (char *) malloc(writebufsize); + if (writebuf != NULL) { char *curr; krb5_data write_data, out_data; krb5_replay_data replay_data; @@ -157,15 +159,14 @@ krb5_send_adm_cmd(kcontext, sock, ctx, nargs, arglist) write_data.data = writebuf; /* Generate the message */ - if (!(ret = krb5_mk_priv(kcontext, - ctx, - &write_data, - &out_data, - &replay_data))) { + ret = krb5_mk_priv(kcontext, ctx, &write_data, + &out_data, &replay_data); + if (!ret) { /* Write the message */ - if (ret = krb5_write_message(kcontext, sock, &out_data)) + ret = krb5_write_message(kcontext, sock, &out_data); + krb5_free_data_contents(kcontext, &out_data); + if (ret) goto cleanup; - krb5_xfree(out_data.data); } cleanup: @@ -201,7 +202,7 @@ krb5_send_adm_reply(kcontext, sock, ctx, cmd_stat, ncomps, complist) krb5_int32 ncomps; /* Number of arguments (In ) */ krb5_data *complist; /* Components to write (In ) */ { - int writebufsize; + size_t writebufsize; int i; char *writebuf; krb5_error_code ret; @@ -210,7 +211,8 @@ krb5_send_adm_reply(kcontext, sock, ctx, cmd_stat, ncomps, complist) /* * First check that our auth context has the right flags in it. */ - if (ret = krb5_auth_con_getflags(kcontext, ctx, &ac_flags)) + ret = krb5_auth_con_getflags(kcontext, ctx, &ac_flags); + if (ret) return(ret); if ((ac_flags & (KRB5_AUTH_CONTEXT_RET_SEQUENCE| @@ -228,7 +230,8 @@ krb5_send_adm_reply(kcontext, sock, ctx, cmd_stat, ncomps, complist) writebufsize += complist[i].length; /* for actual arg */ } - if (writebuf = (char *) malloc(writebufsize)) { + writebuf = (char *) malloc(writebufsize); + if (writebuf != NULL) { char *curr; krb5_data write_data, out_data; krb5_replay_data replay_data; @@ -255,15 +258,14 @@ krb5_send_adm_reply(kcontext, sock, ctx, cmd_stat, ncomps, complist) write_data.data = writebuf; /* Generate the message */ - if (!(ret = krb5_mk_priv(kcontext, - ctx, - &write_data, - &out_data, - &replay_data))) { + ret = krb5_mk_priv(kcontext, ctx, &write_data, &out_data, + &replay_data); + if (!ret) { /* Write the message */ - if (ret = krb5_write_message(kcontext, sock, &out_data)) + ret = krb5_write_message(kcontext, sock, &out_data); + krb5_free_data_contents(kcontext, &out_data); + if (ret) goto cleanup; - krb5_xfree(out_data.data); } cleanup: @@ -305,7 +307,8 @@ krb5_read_adm_cmd(kcontext, sock, ctx, nargs, arglist) /* * First check that our auth context has the right flags in it. */ - if (ret = krb5_auth_con_getflags(kcontext, ctx, &ac_flags)) + ret = krb5_auth_con_getflags(kcontext, ctx, &ac_flags); + if (ret) return(ret); if ((ac_flags & (KRB5_AUTH_CONTEXT_RET_SEQUENCE| @@ -336,8 +339,9 @@ krb5_read_adm_cmd(kcontext, sock, ctx, nargs, arglist) if (*nargs > 0) { /* Get the memory for the list */ - if (*arglist = (krb5_data *) - malloc((size_t) (*nargs) * sizeof(krb5_data))) { + *arglist = (krb5_data *) + malloc((size_t) (*nargs) * sizeof(krb5_data)); + if (*arglist != NULL) { krb5_data *xarglist; xarglist = *arglist; @@ -434,7 +438,8 @@ krb5_read_adm_reply(kcontext, sock, ctx, cmd_stat, ncomps, complist) /* * First check that our auth context has the right flags in it. */ - if (ret = krb5_auth_con_getflags(kcontext, ctx, &ac_flags)) + ret = krb5_auth_con_getflags(kcontext, ctx, &ac_flags); + if (ret) return(ret); if ((ac_flags & (KRB5_AUTH_CONTEXT_RET_SEQUENCE| @@ -467,14 +472,15 @@ krb5_read_adm_reply(kcontext, sock, ctx, cmd_stat, ncomps, complist) if (*ncomps > 0) { /* Get the memory for the list */ - if (*complist = (krb5_data *) - malloc((size_t) ((*ncomps) * sizeof(krb5_data)))) { + *complist = (krb5_data *) + malloc((size_t) ((*ncomps) * sizeof(krb5_data))); + if (*complist) { krb5_data *xcomplist; - + xcomplist = *complist; memset((char *) (xcomplist), 0, (size_t) ((*ncomps) * sizeof(krb5_data))); - + replyok = 1; /* Copy out each list entry */ for (i=0; i<*ncomps; i++) { diff --git a/src/kadmin/v5passwdd/kadm5_defs.h b/src/kadmin/v5passwdd/kadm5_defs.h index 92ec7f341..8201f2913 100644 --- a/src/kadmin/v5passwdd/kadm5_defs.h +++ b/src/kadmin/v5passwdd/kadm5_defs.h @@ -110,7 +110,7 @@ * Inter-module function prototypes */ -krb5_keytab key_keytab_id(); +krb5_keytab key_keytab_id KRB5_PROTOTYPE((void)); krb5_error_code key_open_db KRB5_PROTOTYPE((krb5_context)); krb5_error_code key_close_db KRB5_PROTOTYPE((krb5_context)); @@ -226,7 +226,7 @@ void net_finish int)); krb5_error_code net_dispatch KRB5_PROTOTYPE((krb5_context, int)); -krb5_principal net_server_princ(); +krb5_principal net_server_princ KRB5_PROTOTYPE((void)); /* proto_serv.c */ krb5_error_code proto_init diff --git a/src/kadmin/v5passwdd/kpasswd.c b/src/kadmin/v5passwdd/kpasswd.c index 7d57524cd..2e435f426 100644 --- a/src/kadmin/v5passwdd/kpasswd.c +++ b/src/kadmin/v5passwdd/kpasswd.c @@ -37,6 +37,7 @@ #include "k5-int.h" #include "adm_defs.h" #include "adm.h" +#include "krb5/adm_proto.h" #ifdef HAVE_STRING_H #include @@ -67,7 +68,9 @@ static const char *kpwd_usage_error_fmt = "%s: usage is %s [-u user]\n"; static const char *kpwd_getoptstring = "u:"; #endif /* LANGUAGES_SUPPORTED */ static const char *kpwd_extra_args = "extra arguments"; +#if 0 static const char *kpwd_bad_option_fmt = "%s: unrecognized option -%c.\n"; +#endif static const char *kpwd_no_memory_fmt = "%s: not enough resources to allocate %d bytes for %s.\n"; static const char *kpwd_bad_client_fmt = "%s: %s%s%s %s not recognized by the server.\n"; static const char *kpwd_no_server_fmt = "%s: cannot find server for %s.\n"; @@ -80,14 +83,18 @@ static const char *kpwd_pwd_unacceptable = "%s: your new password is unacceptab static const char *kpwd_read_pass_error = "%s: error (%s) reading passwords.\n"; static const char *kpwd_password_text = "passwords"; +#if 0 static const char *kpwd_realm_text = "realm name"; +#endif static const char *kpwd_args_text = "arguments"; static const char *kpwd_try_again_text = "try again"; static const char *kpwd_seeyalater_text = "password not changed"; +#if 0 static const char *kpwd_mime_text = "MIME-enable"; static const char *kpwd_language_text = "set language"; +#endif static const char *kpwd_check_pwd_text = "check password"; static const char *kpwd_change_pwd_text = "change password"; static const char *kpwd_quit_text = "quit"; @@ -122,13 +129,13 @@ usage(invocation, more_info) } static const char * -kpwd_reply_to_string(stat) - krb5_int32 stat; +kpwd_reply_to_string(status) + krb5_int32 status; { - int index; + int idx; const char *rval; - switch (stat) { + switch (status) { case KRB5_ADM_SUCCESS: case KRB5_ADM_CMD_UNKNOWN: case KRB5_ADM_PW_UNACCEPT: @@ -136,8 +143,8 @@ kpwd_reply_to_string(stat) case KRB5_ADM_NOT_IN_TKT: case KRB5_ADM_CANT_CHANGE: case KRB5_ADM_LANG_NOT_SUPPORTED: - index = (int) stat; - rval = kpwd_replies[index]; + idx = (int) status; + rval = kpwd_replies[idx]; break; default: rval = kpwd_replies_unknown; @@ -164,6 +171,7 @@ kpwd_print_sreply(progname, ncomps, complist) } } +int main(argc, argv) int argc; char *argv[]; @@ -281,16 +289,12 @@ main(argc, argv) /* * Establish the connection. */ - if (kret = krb5_adm_connect(kcontext, - name, - (opwd_prompt) ? - opwd_prompt : kpwd_old_password_prompt, - opassword, - &conn_socket, - &auth_context, - &ccache, - (char *) NULL, - 0)) { + kret = krb5_adm_connect(kcontext, name, + (opwd_prompt) ? + opwd_prompt : kpwd_old_password_prompt, + opassword, &conn_socket, &auth_context, + &ccache, (char *) NULL, 0); + if (kret) { switch (kret) { case KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN: fprintf(stderr, kpwd_bad_client_fmt, argv[0], @@ -421,8 +425,8 @@ main(argc, argv) npass_len = KRB5_ADM_MAX_PASSWORD_LEN; if (!(kret = krb5_read_password(kcontext, - (char *) kpwd_change_prompt_1, - (char *) kpwd_change_prompt_2, + kpwd_change_prompt_1, + kpwd_change_prompt_2, npassword, &npass_len))) { krb5_data check_data[2]; @@ -432,7 +436,7 @@ main(argc, argv) krb5_data set_data[3]; krb5_int32 set_status; krb5_int32 set_ncomps; - krb5_int32 *set_reply; + krb5_data *set_reply; check_data[0].data = KRB5_ADM_CHECKPW_CMD; check_data[0].length = strlen(check_data[0].data); diff --git a/src/kadmin/v5passwdd/main.c b/src/kadmin/v5passwdd/main.c index 9a4409db4..a411b21ab 100644 --- a/src/kadmin/v5passwdd/main.c +++ b/src/kadmin/v5passwdd/main.c @@ -7,6 +7,7 @@ #include #include +#include #include "kadm5_defs.h" static krb5_keytab keytab; @@ -36,7 +37,7 @@ unhandled_signal(signo) /* NOTREACHED */ } -void usage() +static void usage() { fprintf(stderr, "Usage: kadmind [-r realm] [-m] [-nofork] " "[-D debuglevel] [-T keytable] [-port port-number]\n"); @@ -45,7 +46,7 @@ void usage() int main(int argc, char *argv[]) { - int ret, rlen, nofork, oldnames = 0; + int ret, nofork; int timeout = -1; krb5_error_code code; int debug_level = 0; @@ -102,22 +103,24 @@ int main(int argc, char *argv[]) if (argc != 0) usage(); - if (ret = krb5_init_context(&context)) { - fprintf(stderr, "%s: %s while initializing context, aborting\n", - programname, error_message(ret)); - exit(1); + ret = krb5_init_context(&context); + if (ret) { + fprintf(stderr, "%s: %s while initializing context, aborting\n", + programname, error_message(ret)); + exit(1); } krb5_klog_init(context, "admin_server", programname, 1); - if (ret = kadm5_get_config_params(context, NULL, NULL, ¶ms, - ¶ms)) { - krb5_klog_syslog(LOG_ERR, "%s: %s while initializing, aborting\n", - programname, error_message(ret)); - fprintf(stderr, "%s: %s while initializing, aborting\n", - programname, error_message(ret)); - krb5_klog_close(); - exit(1); + ret = kadm5_get_config_params(context, NULL, NULL, ¶ms, + ¶ms); + if (ret) { + krb5_klog_syslog(LOG_ERR, "%s: %s while initializing, aborting\n", + programname, error_message(ret)); + fprintf(stderr, "%s: %s while initializing, aborting\n", + programname, error_message(ret)); + krb5_klog_close(context); + exit(1); } #define REQUIRED_PARAMS (KADM5_CONFIG_REALM | KADM5_CONFIG_ACL_FILE | \ @@ -128,9 +131,9 @@ int main(int argc, char *argv[]) "(%x) while initializing, aborting\n", programname, (params.mask & REQUIRED_PARAMS) ^ REQUIRED_PARAMS); fprintf(stderr, "%s: Missing required configuration values " - "(%x) while initializing, aborting\n", programname, + "(%lx) while initializing, aborting\n", programname, (params.mask & REQUIRED_PARAMS) ^ REQUIRED_PARAMS); - krb5_klog_close(); + krb5_klog_close(context); exit(1); } @@ -171,9 +174,10 @@ int main(int argc, char *argv[]) krb5_klog_syslog(LOG_INFO, "starting"); - if (code = net_init(context, params.realm, debug_level, - (params.mask&KADM5_CONFIG_KADMIND_PORT)? - params.kadmind_port:0)) { + code = net_init(context, params.realm, debug_level, + (params.mask&KADM5_CONFIG_KADMIND_PORT)? + params.kadmind_port:0); + if (code) { krb5_klog_syslog(LOG_ERR, "%s: %s while initializing network", programname, error_message(code)); fprintf(stderr, "%s: %s while initializing network\n", @@ -181,11 +185,13 @@ int main(int argc, char *argv[]) exit(1); } - if (code = proto_init(context, debug_level, timeout)) { - krb5_klog_syslog(LOG_ERR, "%s: %s while initializing proto", - programname, error_message(code)); - fprintf(stderr, "%s: %s while initializing proto\n", - programname, error_message(code)); + + code = proto_init(context, debug_level, timeout); + if (code) { + krb5_klog_syslog(LOG_ERR, "%s: %s while initializing proto", + programname, error_message(code)); + fprintf(stderr, "%s: %s while initializing proto\n", + programname, error_message(code)); } if ( @@ -196,7 +202,8 @@ int main(int argc, char *argv[]) #endif /* POSIX_SETJMP */ ) { - if (code = net_dispatch(context, !nofork)) { + code = net_dispatch(context, !nofork); + if (code) { krb5_klog_syslog(LOG_ERR, "%s: %s while dispatching requests", programname, error_message(code)); fprintf(stderr, "%s: %s while dispatching requests\n", @@ -209,7 +216,7 @@ int main(int argc, char *argv[]) net_finish(context, debug_level); krb5_klog_syslog(LOG_INFO, "finished, exiting"); - krb5_klog_close(); + krb5_klog_close(context); exit(2); } @@ -259,15 +266,16 @@ pwd_change(kcontext, debug_level, auth_context, ticket, /* check to see if the min_time has passed. this is stolen from chpass_principal_wrapper */ - if (ret = krb5_timeofday(kcontext, &now)) { + ret = krb5_timeofday(kcontext, &now); + if (ret) { sprintf(err_str, error_message(ret)); return(KRB5_ADM_SYSTEM_ERROR); - } + } - if((ret = kadm5_get_principal(global_server_handle, principal, - &princ, - KADM5_PRINCIPAL_NORMAL_MASK)) != - KADM5_OK) { + if((ret = kadm5_get_principal(global_server_handle, principal, + &princ, + KADM5_PRINCIPAL_NORMAL_MASK)) != + KADM5_OK) { sprintf(err_str, error_message(ret)); return(KRB5_ADM_SYSTEM_ERROR); } @@ -285,25 +293,28 @@ pwd_change(kcontext, debug_level, auth_context, ticket, sprintf(err_str, error_message(ret)); return(KRB5_ADM_PW_UNACCEPT); } - if (ret = kadm5_free_policy_ent(global_server_handle, &pol)) { + + ret = kadm5_free_policy_ent(global_server_handle, &pol); + if (ret) { (void) kadm5_free_principal_ent(global_server_handle, &princ); sprintf(err_str, error_message(ret)); return(KRB5_ADM_SYSTEM_ERROR); } } - if (ret = kadm5_free_principal_ent(global_server_handle, &princ)) { - sprintf(err_str, error_message(ret)); - return(KRB5_ADM_SYSTEM_ERROR); + + ret = kadm5_free_principal_ent(global_server_handle, &princ); + if (ret) { + sprintf(err_str, error_message(ret)); + return(KRB5_ADM_SYSTEM_ERROR); } /* ok, it's not too early to change the password. change it. */ - - if (ret = kadm5_chpass_principal_util(global_server_handle, - principal, - newdata->data, - NULL, - err_str, err_str_len)) - return(KRB5_ADM_PW_UNACCEPT); - + + ret = kadm5_chpass_principal_util(global_server_handle, + principal, newdata->data, + NULL, err_str, err_str_len); + if (ret) + return(KRB5_ADM_PW_UNACCEPT); + return(KRB5_ADM_SUCCESS); } diff --git a/src/kadmin/v5passwdd/proto_serv.c b/src/kadmin/v5passwdd/proto_serv.c index 419f8611d..013d8fb40 100644 --- a/src/kadmin/v5passwdd/proto_serv.c +++ b/src/kadmin/v5passwdd/proto_serv.c @@ -177,17 +177,19 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) /* * First setup the replay cache. */ - if (kret = krb5_get_server_rcache(kcontext, - krb5_princ_component(kcontext, - net_server_princ(), - 0), - &rcache)) { + kret = krb5_get_server_rcache(kcontext, + krb5_princ_component(kcontext, + net_server_princ(), + 0), + &rcache); + if (kret) { com_err(programname, kret, proto_rcache_msg, my_id); goto cleanup; } /* Initialize the auth context */ - if (kret = krb5_auth_con_init(kcontext, &auth_context)) { + kret = krb5_auth_con_init(kcontext, &auth_context); + if (kret) { com_err(programname, kret, proto_auth_con_msg, my_id); goto cleanup; } @@ -216,9 +218,8 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) ntohl(sv_addr->sin_addr.s_addr), ntohl(cl_addr->sin_addr.s_addr))); /* Now, read in the AP_REQ message and decode it. */ - if (kret = krb5_read_message(kcontext, - (krb5_pointer) &cl_sock, - &in_data)) { + kret = krb5_read_message(kcontext, (krb5_pointer) &cl_sock, &in_data); + if (kret) { com_err(programname, kret, proto_ap_req_msg, my_id); goto cleanup; } @@ -227,13 +228,10 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) ("= %d:parse message(%d bytes)\n", my_id, in_data.length)); /* Parse the AP_REQ message */ - if (kret = krb5_rd_req(kcontext, - &auth_context, - &in_data, - net_server_princ(), - key_keytab_id(), - &ap_options, - &ticket)) { + kret = krb5_rd_req(kcontext, &auth_context, &in_data, + net_server_princ(), key_keytab_id(), + &ap_options, &ticket); + if (kret) { com_err(programname, kret, proto_rd_req_msg, my_id); goto err_reply; } @@ -248,16 +246,17 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) DPRINT(DEBUG_PROTO, proto_debug_level, ("= %d:make AP_REP\n", my_id)); - if (kret = krb5_mk_rep(kcontext, auth_context, &out_data)) { + kret = krb5_mk_rep(kcontext, auth_context, &out_data); + if (kret) { com_err(programname, kret, proto_mk_rep_msg, my_id); goto cleanup; } DPRINT(DEBUG_PROTO, proto_debug_level, ("= %d:write AP_REP(%d bytes)\n", my_id, out_data.length)); - if (kret = krb5_write_message(kcontext, - (krb5_pointer) &cl_sock, - &out_data)) { + kret = krb5_write_message(kcontext, (krb5_pointer) &cl_sock, + &out_data); + if (kret) { com_err(programname, kret, proto_wr_rep_msg, my_id); goto cleanup; } @@ -297,7 +296,7 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) * Read a command and figure out what to do. */ if (proto_proto_timeout > 0) - alarm(proto_proto_timeout); + alarm((unsigned) proto_proto_timeout); num_args = 0; DPRINT(DEBUG_PROTO, proto_debug_level, ("= %d:waiting for command\n", my_id)); diff --git a/src/kadmin/v5passwdd/srv_net.c b/src/kadmin/v5passwdd/srv_net.c index 94a93128e..14115e3b3 100644 --- a/src/kadmin/v5passwdd/srv_net.c +++ b/src/kadmin/v5passwdd/srv_net.c @@ -85,7 +85,9 @@ typedef struct _net_slave_info { * Error messages. */ static const char *net_waiterr_msg = "\004child wait failed - cannot reap children"; +#if 0 static const char *net_def_realm_fmt = "%s: cannot get default realm (%s).\n"; +#endif static const char *net_no_mem_fmt = "%s: cannot get memory.\n"; static const char *net_parse_srv_fmt = "%s: cannot parse server name %s (%s).\n"; static const char *net_no_hostname_fmt = "%s: cannot get our host name (%s).\n"; @@ -108,7 +110,6 @@ static krb5_principal net_service_principal = (krb5_principal) NULL; static int net_server_addr_init = 0; static struct sockaddr_in net_server_addr; static int net_listen_socket = -1; -static int net_slaves_active = 0; static int net_max_slaves = 0; static net_slave_info *net_slave_table = (net_slave_info *) NULL; @@ -475,9 +476,8 @@ net_init(kcontext, realm, debug_level, port) ("- name of service is %s\n", net_service_name)); /* Now formulate the principal name */ - if (kret = krb5_parse_name(kcontext, - net_service_name, - &net_service_principal)) { + kret = krb5_parse_name(kcontext, net_service_name, &net_service_principal); + if (kret) { fprintf(stderr, net_parse_srv_fmt, programname, net_service_name, error_message(kret)); goto done;