From 48c955640085b84684d990b07e6496c999e8623f Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Mon, 4 Jun 2001 21:26:34 +0000 Subject: [PATCH] * misc.c, schpw.c: Cleanup assignments in conditionals git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13268 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/server/ChangeLog | 6 ++++- src/kadmin/server/misc.c | 36 +++++++++++++++++------------ src/kadmin/server/schpw.c | 45 +++++++++++++++++++++++-------------- 3 files changed, 55 insertions(+), 32 deletions(-) diff --git a/src/kadmin/server/ChangeLog b/src/kadmin/server/ChangeLog index 07775f6cd..511881b82 100644 --- a/src/kadmin/server/ChangeLog +++ b/src/kadmin/server/ChangeLog @@ -1,4 +1,8 @@ -Sun Feb 18 16:23:59 2001 Ezra Peisach +2001-06-04 Ezra Peisach + + * misc.c, schpw.c: Cleanup assignments in conditionals. + +2001-02-18 Ezra Peisach * kadm_rpc_svc.c, server_stubs.c: Rename all server side dispatch routines to end in _svc so as to not conflict with prototypes of diff --git a/src/kadmin/server/misc.c b/src/kadmin/server/misc.c index 9dc3d9d28..ea0e4ce80 100644 --- a/src/kadmin/server/misc.c +++ b/src/kadmin/server/misc.c @@ -44,13 +44,13 @@ chpass_principal_wrapper(void *server_handle, kadm5_principal_ent_rec princ; kadm5_server_handle_t handle = server_handle; - if (ret = krb5_timeofday(handle->context, &now)) + ret = krb5_timeofday(handle->context, &now); + if (ret) return ret; - if((ret = kadm5_get_principal(handle->lhandle, principal, - &princ, - KADM5_PRINCIPAL_NORMAL_MASK)) != - KADM5_OK) + ret = kadm5_get_principal(handle->lhandle, principal, + &princ, KADM5_PRINCIPAL_NORMAL_MASK); + if(ret != KADM5_OK) return ret; if(princ.aux_attributes & KADM5_POLICY) { if((ret=kadm5_get_policy(handle->lhandle, @@ -64,12 +64,16 @@ chpass_principal_wrapper(void *server_handle, (void) kadm5_free_principal_ent(handle->lhandle, &princ); return KADM5_PASS_TOOSOON; } - if (ret = kadm5_free_policy_ent(handle->lhandle, &pol)) { + + ret = kadm5_free_policy_ent(handle->lhandle, &pol); + if (ret) { (void) kadm5_free_principal_ent(handle->lhandle, &princ); return ret; } } - if (ret = kadm5_free_principal_ent(handle->lhandle, &princ)) + + ret = kadm5_free_principal_ent(handle->lhandle, &princ); + if (ret) return ret; return kadm5_chpass_principal(server_handle, principal, password); @@ -107,13 +111,13 @@ randkey_principal_wrapper(void *server_handle, kadm5_principal_ent_rec princ; kadm5_server_handle_t handle = server_handle; - if (ret = krb5_timeofday(handle->context, &now)) + ret = krb5_timeofday(handle->context, &now); + if (ret) return ret; - if((ret = kadm5_get_principal(handle->lhandle, - principal, &princ, - KADM5_PRINCIPAL_NORMAL_MASK)) != - OSA_ADB_OK) + ret = kadm5_get_principal(handle->lhandle, principal, + &princ, KADM5_PRINCIPAL_NORMAL_MASK); + if(ret != OSA_ADB_OK) return ret; if(princ.aux_attributes & KADM5_POLICY) { if((ret=kadm5_get_policy(handle->lhandle, @@ -127,12 +131,16 @@ randkey_principal_wrapper(void *server_handle, (void) kadm5_free_principal_ent(handle->lhandle, &princ); return KADM5_PASS_TOOSOON; } - if (ret = kadm5_free_policy_ent(handle->lhandle, &pol)) { + + ret = kadm5_free_policy_ent(handle->lhandle, &pol); + if (ret) { (void) kadm5_free_principal_ent(handle->lhandle, &princ); return ret; } } - if (ret = kadm5_free_principal_ent(handle->lhandle, &princ)) + + ret = kadm5_free_principal_ent(handle->lhandle, &princ); + if (ret) return ret; return kadm5_randkey_principal(server_handle, principal, keys, n_keys); } diff --git a/src/kadmin/server/schpw.c b/src/kadmin/server/schpw.c index 9de81160b..c65555bf5 100644 --- a/src/kadmin/server/schpw.c +++ b/src/kadmin/server/schpw.c @@ -92,21 +92,24 @@ process_chpw_request(context, server_handle, realm, s, keytab, sin, req, rep) ap_req.data = ptr; ptr += ap_req.length; - if (ret = krb5_auth_con_init(context, &auth_context)) { + ret = krb5_auth_con_init(context, &auth_context); + if (ret) { numresult = KRB5_KPASSWD_HARDERROR; strcpy(strresult, "Failed initializing auth context"); goto chpwfail; } - if (ret = krb5_auth_con_setflags(context, auth_context, - KRB5_AUTH_CONTEXT_DO_SEQUENCE)) { + ret = krb5_auth_con_setflags(context, auth_context, + KRB5_AUTH_CONTEXT_DO_SEQUENCE); + if (ret) { numresult = KRB5_KPASSWD_HARDERROR; strcpy(strresult, "Failed initializing auth context"); goto chpwfail; } - if (ret = krb5_build_principal(context, &changepw, strlen(realm), realm, - "kadmin", "changepw", NULL)) { + ret = krb5_build_principal(context, &changepw, strlen(realm), realm, + "kadmin", "changepw", NULL); + if (ret) { numresult = KRB5_KPASSWD_HARDERROR; strcpy(strresult, "Failed building kadmin/changepw principal"); goto chpwfail; @@ -188,8 +191,9 @@ process_chpw_request(context, server_handle, realm, s, keytab, sin, req, rep) specified. when rd_priv is called, *only* a remote address is specified. Are we having fun yet? */ - if (ret = krb5_auth_con_setaddrs(context, auth_context, NULL, - &remote_kaddr)) { + ret = krb5_auth_con_setaddrs(context, auth_context, NULL, + &remote_kaddr); + if (ret) { numresult = KRB5_KPASSWD_HARDERROR; strcpy(strresult, "Failed storing client internet address"); goto chpwfail; @@ -205,7 +209,8 @@ process_chpw_request(context, server_handle, realm, s, keytab, sin, req, rep) /* construct the ap-rep */ - if (ret = krb5_mk_rep(context, auth_context, &ap_rep)) { + ret = krb5_mk_rep(context, auth_context, &ap_rep); + if (ret) { numresult = KRB5_KPASSWD_AUTHERROR; strcpy(strresult, "Failed replying to application request"); goto chpwfail; @@ -216,7 +221,8 @@ process_chpw_request(context, server_handle, realm, s, keytab, sin, req, rep) cipher.length = (req->data + req->length) - ptr; cipher.data = ptr; - if (ret = krb5_rd_priv(context, auth_context, &cipher, &clear, &replay)) { + ret = krb5_rd_priv(context, auth_context, &cipher, &clear, &replay); + if (ret) { numresult = KRB5_KPASSWD_HARDERROR; strcpy(strresult, "Failed decrypting request"); goto chpwfail; @@ -269,14 +275,16 @@ chpwfail: cipher.length = 0; if (ap_rep.length) { - if (ret = krb5_auth_con_setaddrs(context, auth_context, &local_kaddr, - NULL)) { + ret = krb5_auth_con_setaddrs(context, auth_context, &local_kaddr, + NULL); + if (ret) { numresult = KRB5_KPASSWD_HARDERROR; strcpy(strresult, "Failed storing client and server internet addresses"); } else { - if (ret = krb5_mk_priv(context, auth_context, &clear, &cipher, - &replay)) { + ret = krb5_mk_priv(context, auth_context, &clear, &cipher, + &replay); + if (ret) { numresult = KRB5_KPASSWD_HARDERROR; strcpy(strresult, "Failed encrypting reply"); } @@ -298,7 +306,8 @@ chpwfail: krberror.ctime = 0; krberror.cusec = 0; krberror.susec = 0; - if (ret = krb5_timeofday(context, &krberror.stime)) + ret = krb5_timeofday(context, &krberror.stime); + if (ret) goto bailout; /* this is really icky. but it's what all the other callers @@ -309,9 +318,11 @@ chpwfail: krberror.error = KRB_ERR_GENERIC; krberror.client = NULL; - if (ret = krb5_build_principal(context, &krberror.server, - strlen(realm), realm, - "kadmin", "changepw", NULL)) + + ret = krb5_build_principal(context, &krberror.server, + strlen(realm), realm, + "kadmin", "changepw", NULL); + if (ret) goto bailout; krberror.text.length = 0; krberror.e_data = clear; -- 2.26.2