krb5 commit: Improve libkadm5 client RPC thread safety

Greg Hudson ghudson at mit.edu
Fri Feb 26 16:09:13 EST 2016


https://github.com/krb5/krb5/commit/0937ccdd4e97c474bc1b79e059f1301ae6c851ea
commit 0937ccdd4e97c474bc1b79e059f1301ae6c851ea
Author: Simo Sorce <simo at redhat.com>
Date:   Sun Dec 20 17:03:07 2015 -0500

    Improve libkadm5 client RPC thread safety
    
    Change the stubs in client_rpc.c to use thread-safe signatures (as
    would be output by rpcgen -M), and adjust callers accordingly.
    
    [ghudson at mit.edu: simplify library wrappers; rewrite commit message]
    
    ticket: 8371 (new)

 src/lib/kadm5/clnt/client_init.c      |   21 +-
 src/lib/kadm5/clnt/client_principal.c |  212 +++++++---------
 src/lib/kadm5/clnt/client_rpc.c       |  442 ++++++++++-----------------------
 src/lib/kadm5/clnt/clnt_policy.c      |   51 ++---
 src/lib/kadm5/clnt/clnt_privs.c       |   13 +-
 src/lib/kadm5/kadm_rpc.h              |   66 +++--
 6 files changed, 297 insertions(+), 508 deletions(-)

diff --git a/src/lib/kadm5/clnt/client_init.c b/src/lib/kadm5/clnt/client_init.c
index b96cc35..092ca2c 100644
--- a/src/lib/kadm5/clnt/client_init.c
+++ b/src/lib/kadm5/clnt/client_init.c
@@ -158,7 +158,7 @@ init_any(krb5_context context, char *client_name, enum init_type init_type,
     kadm5_config_params params_local;
 
     int code = 0;
-    generic_ret *r;
+    generic_ret r = { 0, 0 };
 
     initialize_ovk_error_table();
 /*      initialize_adb_error_table(); */
@@ -295,8 +295,7 @@ init_any(krb5_context context, char *client_name, enum init_type init_type,
         goto cleanup;
     }
 
-    r = init_2(&handle->api_version, handle->clnt);
-    if (r == NULL) {
+    if (init_2(&handle->api_version, &r, handle->clnt)) {
         code = KADM5_RPC_ERROR;
 #ifdef DEBUG
         clnt_perror(handle->clnt, "init_2 null resp");
@@ -304,27 +303,27 @@ init_any(krb5_context context, char *client_name, enum init_type init_type,
         goto error;
     }
     /* Drop down to v3 wire protocol if server does not support v4 */
-    if (r->code == KADM5_NEW_SERVER_API_VERSION &&
+    if (r.code == KADM5_NEW_SERVER_API_VERSION &&
         handle->api_version == KADM5_API_VERSION_4) {
         handle->api_version = KADM5_API_VERSION_3;
-        r = init_2(&handle->api_version, handle->clnt);
-        if (r == NULL) {
+        memset(&r, 0, sizeof(generic_ret));
+        if (init_2(&handle->api_version, &r, handle->clnt)) {
             code = KADM5_RPC_ERROR;
             goto error;
         }
     }
     /* Drop down to v2 wire protocol if server does not support v3 */
-    if (r->code == KADM5_NEW_SERVER_API_VERSION &&
+    if (r.code == KADM5_NEW_SERVER_API_VERSION &&
         handle->api_version == KADM5_API_VERSION_3) {
         handle->api_version = KADM5_API_VERSION_2;
-        r = init_2(&handle->api_version, handle->clnt);
-        if (r == NULL) {
+        memset(&r, 0, sizeof(generic_ret));
+        if (init_2(&handle->api_version, &r, handle->clnt)) {
             code = KADM5_RPC_ERROR;
             goto error;
         }
     }
-    if (r->code) {
-        code = r->code;
+    if (r.code) {
+        code = r.code;
         goto error;
     }
 
diff --git a/src/lib/kadm5/clnt/client_principal.c b/src/lib/kadm5/clnt/client_principal.c
index 5718e17..18714bf 100644
--- a/src/lib/kadm5/clnt/client_principal.c
+++ b/src/lib/kadm5/clnt/client_principal.c
@@ -26,7 +26,7 @@ kadm5_create_principal(void *server_handle,
                        kadm5_principal_ent_t princ, long mask,
                        char *pw)
 {
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     cprinc_arg          arg;
     kadm5_server_handle_t handle = server_handle;
 
@@ -54,11 +54,9 @@ kadm5_create_principal(void *server_handle,
         arg.rec.tl_data = NULL;
     }
 
-    r = create_principal_2(&arg, handle->clnt);
-
-    if(r == NULL)
+    if (create_principal_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -68,7 +66,7 @@ kadm5_create_principal_3(void *server_handle,
                          krb5_key_salt_tuple *ks_tuple,
                          char *pw)
 {
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     cprinc3_arg         arg;
     kadm5_server_handle_t handle = server_handle;
 
@@ -98,18 +96,16 @@ kadm5_create_principal_3(void *server_handle,
         arg.rec.tl_data = NULL;
     }
 
-    r = create_principal3_2(&arg, handle->clnt);
-
-    if(r == NULL)
+    if (create_principal3_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
 kadm5_delete_principal(void *server_handle, krb5_principal principal)
 {
     dprinc_arg          arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -118,10 +114,9 @@ kadm5_delete_principal(void *server_handle, krb5_principal principal)
         return EINVAL;
     arg.princ = principal;
     arg.api_version = handle->api_version;
-    r = delete_principal_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (delete_principal_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -129,7 +124,7 @@ kadm5_modify_principal(void *server_handle,
                        kadm5_principal_ent_t princ, long mask)
 {
     mprinc_arg          arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -153,11 +148,9 @@ kadm5_modify_principal(void *server_handle,
 
     arg.rec.mod_name = NULL;
 
-    r = modify_principal_2(&arg, handle->clnt);
-
-    if(r == NULL)
+    if (modify_principal_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -166,7 +159,7 @@ kadm5_get_principal(void *server_handle,
                     long mask)
 {
     gprinc_arg  arg;
-    gprinc_ret  *r;
+    gprinc_ret  r;
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -176,13 +169,13 @@ kadm5_get_principal(void *server_handle,
     arg.princ = princ;
     arg.mask = mask;
     arg.api_version = handle->api_version;
-    r = get_principal_2(&arg, handle->clnt);
-    if(r == NULL)
+    memset(&r, 0, sizeof(gprinc_ret));
+    if (get_principal_2(&arg, &r, handle->clnt))
         eret();
-    if (r->code == 0)
-        memcpy(ent, &r->rec, sizeof(r->rec));
+    if (r.code == 0)
+        memcpy(ent, &r.rec, sizeof(r.rec));
 
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -190,7 +183,7 @@ kadm5_get_principals(void *server_handle,
                      char *exp, char ***princs, int *count)
 {
     gprincs_arg arg;
-    gprincs_ret *r;
+    gprincs_ret r;
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -199,18 +192,18 @@ kadm5_get_principals(void *server_handle,
         return EINVAL;
     arg.exp = exp;
     arg.api_version = handle->api_version;
-    r = get_princs_2(&arg, handle->clnt);
-    if(r == NULL)
+    memset(&r, 0, sizeof(gprincs_ret));
+    if (get_princs_2(&arg, &r, handle->clnt))
         eret();
-    if(r->code == 0) {
-        *count = r->count;
-        *princs = r->princs;
+    if (r.code == 0) {
+        *count = r.count;
+        *princs = r.princs;
     } else {
         *count = 0;
         *princs = NULL;
     }
 
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -218,7 +211,7 @@ kadm5_rename_principal(void *server_handle,
                        krb5_principal source, krb5_principal dest)
 {
     rprinc_arg          arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -228,10 +221,9 @@ kadm5_rename_principal(void *server_handle,
     arg.api_version = handle->api_version;
     if (source == NULL || dest == NULL)
         return EINVAL;
-    r = rename_principal_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (rename_principal_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -239,7 +231,7 @@ kadm5_chpass_principal(void *server_handle,
                        krb5_principal princ, char *password)
 {
     chpass_arg          arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -250,10 +242,9 @@ kadm5_chpass_principal(void *server_handle,
 
     if(princ == NULL)
         return EINVAL;
-    r = chpass_principal_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (chpass_principal_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -263,7 +254,7 @@ kadm5_chpass_principal_3(void *server_handle,
                          char *password)
 {
     chpass3_arg         arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -277,10 +268,9 @@ kadm5_chpass_principal_3(void *server_handle,
 
     if(princ == NULL)
         return EINVAL;
-    r = chpass_principal3_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (chpass_principal3_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -289,7 +279,7 @@ kadm5_setv4key_principal(void *server_handle,
                          krb5_keyblock *keyblock)
 {
     setv4key_arg        arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -300,10 +290,9 @@ kadm5_setv4key_principal(void *server_handle,
 
     if(princ == NULL || keyblock == NULL)
         return EINVAL;
-    r = setv4key_principal_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (setv4key_principal_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -313,7 +302,7 @@ kadm5_setkey_principal(void *server_handle,
                        int n_keys)
 {
     setkey_arg          arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -325,10 +314,9 @@ kadm5_setkey_principal(void *server_handle,
 
     if(princ == NULL || keyblocks == NULL)
         return EINVAL;
-    r = setkey_principal_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (setkey_principal_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -340,7 +328,7 @@ kadm5_setkey_principal_3(void *server_handle,
                          int n_keys)
 {
     setkey3_arg         arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -355,10 +343,9 @@ kadm5_setkey_principal_3(void *server_handle,
 
     if(princ == NULL || keyblocks == NULL)
         return EINVAL;
-    r = setkey_principal3_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (setkey_principal3_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -369,7 +356,7 @@ kadm5_setkey_principal_4(void *server_handle,
                          int n_key_data)
 {
     setkey4_arg         arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -382,10 +369,9 @@ kadm5_setkey_principal_4(void *server_handle,
 
     if (princ == NULL || key_data == NULL || n_key_data == 0)
         return EINVAL;
-    r = setkey_principal4_2(&arg, handle->clnt);
-    if (r == NULL)
+    if (setkey_principal4_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -396,9 +382,9 @@ kadm5_randkey_principal_3(void *server_handle,
                           krb5_keyblock **key, int *n_keys)
 {
     chrand3_arg         arg;
-    chrand_ret          *r;
+    chrand_ret          r;
     kadm5_server_handle_t handle = server_handle;
-    int                 i, ret;
+    int                 i;
 
     CHECK_HANDLE(server_handle);
 
@@ -410,29 +396,19 @@ kadm5_randkey_principal_3(void *server_handle,
 
     if(princ == NULL)
         return EINVAL;
-    r = chrand_principal3_2(&arg, handle->clnt);
-    if(r == NULL)
+    memset(&r, 0, sizeof(chrand_ret));
+    if (chrand_principal3_2(&arg, &r, handle->clnt))
         eret();
     if (n_keys)
-        *n_keys = r->n_keys;
+        *n_keys = r.n_keys;
     if (key) {
-        if(r->n_keys) {
-            *key = malloc(r->n_keys * sizeof(krb5_keyblock));
-            if (*key == NULL)
-                return ENOMEM;
-            for (i = 0; i < r->n_keys; i++) {
-                ret = krb5_copy_keyblock_contents(handle->context, &r->keys[i],
-                                                  &(*key)[i]);
-                if (ret) {
-                    free(*key);
-                    return ENOMEM;
-                }
-            }
-        } else
-            *key = NULL;
+        *key = r.keys;
+    } else {
+        for (i = 0; i < r.n_keys; i++)
+            krb5_free_keyblock_contents(handle->context, &r.keys[i]);
+        free(r.keys);
     }
-
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -441,9 +417,9 @@ kadm5_randkey_principal(void *server_handle,
                         krb5_keyblock **key, int *n_keys)
 {
     chrand_arg          arg;
-    chrand_ret          *r;
+    chrand_ret          r;
     kadm5_server_handle_t handle = server_handle;
-    int                 i, ret;
+    int                 i;
 
     CHECK_HANDLE(server_handle);
 
@@ -452,29 +428,19 @@ kadm5_randkey_principal(void *server_handle,
 
     if(princ == NULL)
         return EINVAL;
-    r = chrand_principal_2(&arg, handle->clnt);
-    if(r == NULL)
+    memset(&r, 0, sizeof(chrand_ret));
+    if (chrand_principal_2(&arg, &r, handle->clnt))
         eret();
     if (n_keys)
-        *n_keys = r->n_keys;
+        *n_keys = r.n_keys;
     if (key) {
-        if(r->n_keys) {
-            *key = malloc(r->n_keys * sizeof(krb5_keyblock));
-            if (*key == NULL)
-                return ENOMEM;
-            for (i = 0; i < r->n_keys; i++) {
-                ret = krb5_copy_keyblock_contents(handle->context, &r->keys[i],
-                                                  &(*key)[i]);
-                if (ret) {
-                    free(*key);
-                    return ENOMEM;
-                }
-            }
-        } else
-            *key = NULL;
+        *key = r.keys;
+    } else {
+        for (i = 0; i < r.n_keys; i++)
+            krb5_free_keyblock_contents(handle->context, &r.keys[i]);
+        free(r.keys);
     }
-
-    return r->code;
+    return r.code;
 }
 
 /* not supported on client side */
@@ -493,7 +459,7 @@ kadm5_purgekeys(void *server_handle,
                 int keepkvno)
 {
     purgekeys_arg       arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -504,10 +470,9 @@ kadm5_purgekeys(void *server_handle,
 
     if (princ == NULL)
         return EINVAL;
-    r = purgekeys_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (purgekeys_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -515,7 +480,7 @@ kadm5_get_strings(void *server_handle, krb5_principal principal,
                   krb5_string_attr **strings_out, int *count_out)
 {
     gstrings_arg arg;
-    gstrings_ret *r;
+    gstrings_ret r;
     kadm5_server_handle_t handle = server_handle;
 
     *strings_out = NULL;
@@ -526,14 +491,14 @@ kadm5_get_strings(void *server_handle, krb5_principal principal,
 
     arg.princ = principal;
     arg.api_version = handle->api_version;
-    r = get_strings_2(&arg, handle->clnt);
-    if (r == NULL)
+    memset(&r, 0, sizeof(gstrings_ret));
+    if (get_strings_2(&arg, &r, handle->clnt))
         eret();
-    if (r->code == 0) {
-        *strings_out = r->strings;
-        *count_out = r->count;
+    if (r.code == 0) {
+        *strings_out = r.strings;
+        *count_out = r.count;
     }
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -541,7 +506,7 @@ kadm5_set_string(void *server_handle, krb5_principal principal,
                  const char *key, const char *value)
 {
     sstring_arg arg;
-    generic_ret *r;
+    generic_ret r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -552,10 +517,9 @@ kadm5_set_string(void *server_handle, krb5_principal principal,
     arg.key = (char *)key;
     arg.value = (char *)value;
     arg.api_version = handle->api_version;
-    r = set_string_2(&arg, handle->clnt);
-    if (r == NULL)
+    if (set_string_2(&arg, &r, handle->clnt))
         eret();
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -564,7 +528,7 @@ kadm5_get_principal_keys(void *server_handle, krb5_principal princ,
                          int *n_key_data)
 {
     getpkeys_arg        arg;
-    getpkeys_ret        *r;
+    getpkeys_ret        r;
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -575,12 +539,12 @@ kadm5_get_principal_keys(void *server_handle, krb5_principal princ,
 
     if (princ == NULL || key_data == NULL || n_key_data == 0)
         return EINVAL;
-    r = get_principal_keys_2(&arg, handle->clnt);
-    if (r == NULL)
+    memset(&r, 0, sizeof(getpkeys_ret));
+    if (get_principal_keys_2(&arg, &r, handle->clnt))
         eret();
-    if (r->code == 0) {
-        *key_data = r->key_data;
-        *n_key_data = r->n_key_data;
+    if (r.code == 0) {
+        *key_data = r.key_data;
+        *n_key_data = r.n_key_data;
     }
-    return r->code;
+    return r.code;
 }
diff --git a/src/lib/kadm5/clnt/client_rpc.c b/src/lib/kadm5/clnt/client_rpc.c
index a5f74e6..df5455f 100644
--- a/src/lib/kadm5/clnt/client_rpc.c
+++ b/src/lib/kadm5/clnt/client_rpc.c
@@ -12,392 +12,210 @@
 /* Default timeout can be changed using clnt_control() */
 static struct timeval TIMEOUT = { 25, 0 };
 
-generic_ret *
-create_principal_2(cprinc_arg *argp, CLIENT *clnt)
+enum clnt_stat
+create_principal_2(cprinc_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, CREATE_PRINCIPAL,
-		      (xdrproc_t) xdr_cprinc_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, CREATE_PRINCIPAL,
+			 (xdrproc_t)xdr_cprinc_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-create_principal3_2(cprinc3_arg *argp, CLIENT *clnt)
+enum clnt_stat
+create_principal3_2(cprinc3_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, CREATE_PRINCIPAL3,
-		      (xdrproc_t) xdr_cprinc3_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, CREATE_PRINCIPAL3,
+			 (xdrproc_t)xdr_cprinc3_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-delete_principal_2(dprinc_arg *argp, CLIENT *clnt)
+enum clnt_stat
+delete_principal_2(dprinc_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, DELETE_PRINCIPAL,
-		      (xdrproc_t) xdr_dprinc_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, DELETE_PRINCIPAL,
+			 (xdrproc_t)xdr_dprinc_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-modify_principal_2(mprinc_arg *argp, CLIENT *clnt)
+enum clnt_stat
+modify_principal_2(mprinc_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, MODIFY_PRINCIPAL,
-		      (xdrproc_t) xdr_mprinc_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, MODIFY_PRINCIPAL,
+			 (xdrproc_t)xdr_mprinc_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-rename_principal_2(rprinc_arg *argp, CLIENT *clnt)
+enum clnt_stat
+rename_principal_2(rprinc_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, RENAME_PRINCIPAL,
-		      (xdrproc_t) xdr_rprinc_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, RENAME_PRINCIPAL,
+			 (xdrproc_t)xdr_rprinc_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-gprinc_ret *
-get_principal_2(gprinc_arg *argp, CLIENT *clnt)
+enum clnt_stat
+get_principal_2(gprinc_arg *argp, gprinc_ret *res, CLIENT *clnt)
 {
-	static gprinc_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, GET_PRINCIPAL,
-		      (xdrproc_t) xdr_gprinc_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_gprinc_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, GET_PRINCIPAL,
+			 (xdrproc_t)xdr_gprinc_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_gprinc_ret, (caddr_t)res, TIMEOUT);
 }
 
-gprincs_ret *
-get_princs_2(gprincs_arg *argp, CLIENT *clnt)
+enum clnt_stat
+get_princs_2(gprincs_arg *argp, gprincs_ret *res, CLIENT *clnt)
 {
-	static gprincs_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, GET_PRINCS,
-		      (xdrproc_t) xdr_gprincs_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_gprincs_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-	     return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, GET_PRINCS,
+			 (xdrproc_t)xdr_gprincs_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_gprincs_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-chpass_principal_2(chpass_arg *argp, CLIENT *clnt)
+enum clnt_stat
+chpass_principal_2(chpass_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, CHPASS_PRINCIPAL,
-		      (xdrproc_t) xdr_chpass_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, CHPASS_PRINCIPAL,
+			 (xdrproc_t)xdr_chpass_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-chpass_principal3_2(chpass3_arg *argp, CLIENT *clnt)
+enum clnt_stat
+chpass_principal3_2(chpass3_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, CHPASS_PRINCIPAL3,
-		      (xdrproc_t) xdr_chpass3_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, CHPASS_PRINCIPAL3,
+			 (xdrproc_t)xdr_chpass3_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-setv4key_principal_2(setv4key_arg *argp, CLIENT *clnt)
+enum clnt_stat
+setv4key_principal_2(setv4key_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, SETV4KEY_PRINCIPAL,
-		      (xdrproc_t) xdr_setv4key_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, SETV4KEY_PRINCIPAL,
+			 (xdrproc_t)xdr_setv4key_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-setkey_principal_2(setkey_arg *argp, CLIENT *clnt)
+enum clnt_stat
+setkey_principal_2(setkey_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, SETKEY_PRINCIPAL,
-		      (xdrproc_t) xdr_setkey_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, SETKEY_PRINCIPAL,
+			 (xdrproc_t)xdr_setkey_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-setkey_principal3_2(setkey3_arg *argp, CLIENT *clnt)
+enum clnt_stat
+setkey_principal3_2(setkey3_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, SETKEY_PRINCIPAL3,
-		      (xdrproc_t) xdr_setkey3_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, SETKEY_PRINCIPAL3,
+			 (xdrproc_t)xdr_setkey3_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-setkey_principal4_2(setkey4_arg *argp, CLIENT *clnt)
+enum clnt_stat
+setkey_principal4_2(setkey4_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, SETKEY_PRINCIPAL4,
-		      (xdrproc_t)xdr_setkey4_arg, (caddr_t)argp,
-		      (xdrproc_t)xdr_generic_ret, (caddr_t)&clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return NULL;
-	}
-	return &clnt_res;
+	return clnt_call(clnt, SETKEY_PRINCIPAL4,
+			 (xdrproc_t)xdr_setkey4_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-chrand_ret *
-chrand_principal_2(chrand_arg *argp, CLIENT *clnt)
+enum clnt_stat
+chrand_principal_2(chrand_arg *argp, chrand_ret *res, CLIENT *clnt)
 {
-	static chrand_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, CHRAND_PRINCIPAL,
-		      (xdrproc_t) xdr_chrand_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_chrand_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, CHRAND_PRINCIPAL,
+			 (xdrproc_t)xdr_chrand_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_chrand_ret, (caddr_t)res, TIMEOUT);
 }
 
-chrand_ret *
-chrand_principal3_2(chrand3_arg *argp, CLIENT *clnt)
+enum clnt_stat
+chrand_principal3_2(chrand3_arg *argp, chrand_ret *res, CLIENT *clnt)
 {
-	static chrand_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, CHRAND_PRINCIPAL3,
-		      (xdrproc_t) xdr_chrand3_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_chrand_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, CHRAND_PRINCIPAL3,
+			 (xdrproc_t)xdr_chrand3_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_chrand_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-create_policy_2(cpol_arg *argp, CLIENT *clnt)
+enum clnt_stat
+create_policy_2(cpol_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, CREATE_POLICY,
-		      (xdrproc_t) xdr_cpol_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, CREATE_POLICY,
+			 (xdrproc_t)xdr_cpol_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-delete_policy_2(dpol_arg *argp, CLIENT *clnt)
+enum clnt_stat
+delete_policy_2(dpol_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, DELETE_POLICY,
-		      (xdrproc_t) xdr_dpol_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, DELETE_POLICY,
+			 (xdrproc_t)xdr_dpol_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-modify_policy_2(mpol_arg *argp, CLIENT *clnt)
+enum clnt_stat
+modify_policy_2(mpol_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-	static generic_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, MODIFY_POLICY,
-		      (xdrproc_t) xdr_mpol_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, MODIFY_POLICY,
+			 (xdrproc_t)xdr_mpol_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-gpol_ret *
-get_policy_2(gpol_arg *argp, CLIENT *clnt)
+enum clnt_stat
+get_policy_2(gpol_arg *argp, gpol_ret *res, CLIENT *clnt)
 {
-	static gpol_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, GET_POLICY,
-		      (xdrproc_t) xdr_gpol_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_gpol_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-		return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, GET_POLICY,
+			 (xdrproc_t)xdr_gpol_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_gpol_ret, (caddr_t)res, TIMEOUT);
 }
 
-gpols_ret *
-get_pols_2(gpols_arg *argp, CLIENT *clnt)
+enum clnt_stat
+get_pols_2(gpols_arg *argp, gpols_ret *res, CLIENT *clnt)
 {
-	static gpols_ret clnt_res;
-
-	memset(&clnt_res, 0, sizeof(clnt_res));
-	if (clnt_call(clnt, GET_POLS,
-		      (xdrproc_t) xdr_gpols_arg, (caddr_t) argp,
-		      (xdrproc_t) xdr_gpols_ret, (caddr_t) &clnt_res,
-		      TIMEOUT) != RPC_SUCCESS) {
-	     return (NULL);
-	}
-	return (&clnt_res);
+	return clnt_call(clnt, GET_POLS,
+			 (xdrproc_t)xdr_gpols_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_gpols_ret, (caddr_t)res, TIMEOUT);
 }
 
-getprivs_ret *
-get_privs_2(void *argp, CLIENT *clnt)
+enum clnt_stat
+get_privs_2(void *argp, getprivs_ret *res, CLIENT *clnt)
 {
-     static getprivs_ret clnt_res;
-
-     memset(&clnt_res, 0, sizeof(clnt_res));
-     if (clnt_call(clnt, GET_PRIVS,
-		   (xdrproc_t) xdr_u_int32, (caddr_t) argp,
-		   (xdrproc_t) xdr_getprivs_ret, (caddr_t) &clnt_res,
-		   TIMEOUT) != RPC_SUCCESS) {
-	  return (NULL);
-     }
-     return (&clnt_res);
+	return clnt_call(clnt, GET_PRIVS,
+			 (xdrproc_t)xdr_u_int32, (caddr_t)argp,
+			 (xdrproc_t)xdr_getprivs_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-init_2(void *argp, CLIENT *clnt)
+enum clnt_stat
+init_2(void *argp, generic_ret *res, CLIENT *clnt)
 {
-     static generic_ret clnt_res;
-
-     memset(&clnt_res, 0, sizeof(clnt_res));
-     if (clnt_call(clnt, INIT,
-		   (xdrproc_t) xdr_u_int32, (caddr_t) argp,
-		   (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		   TIMEOUT) != RPC_SUCCESS) {
-	  return (NULL);
-     }
-     return (&clnt_res);
+	return clnt_call(clnt, INIT,
+			 (xdrproc_t)xdr_u_int32, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-purgekeys_2(purgekeys_arg *argp, CLIENT *clnt)
+enum clnt_stat
+purgekeys_2(purgekeys_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-     static generic_ret clnt_res;
-
-     memset(&clnt_res, 0, sizeof(clnt_res));
-     if (clnt_call(clnt, PURGEKEYS,
-		   (xdrproc_t) xdr_purgekeys_arg, (caddr_t) argp,
-		   (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		   TIMEOUT) != RPC_SUCCESS) {
-	  return (NULL);
-     }
-     return (&clnt_res);
+	return clnt_call(clnt, PURGEKEYS,
+			 (xdrproc_t)xdr_purgekeys_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-gstrings_ret *
-get_strings_2(gstrings_arg *argp, CLIENT *clnt)
+enum clnt_stat
+get_strings_2(gstrings_arg *argp, gstrings_ret *res, CLIENT *clnt)
 {
-     static gstrings_ret clnt_res;
-
-     memset(&clnt_res, 0, sizeof(clnt_res));
-     if (clnt_call(clnt, GET_STRINGS,
-		   (xdrproc_t) xdr_gstrings_arg, (caddr_t) argp,
-		   (xdrproc_t) xdr_gstrings_ret, (caddr_t) &clnt_res,
-		   TIMEOUT) != RPC_SUCCESS) {
-	  return (NULL);
-     }
-     return (&clnt_res);
+	return clnt_call(clnt, GET_STRINGS,
+			 (xdrproc_t)xdr_gstrings_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_gstrings_ret, (caddr_t)res, TIMEOUT);
 }
 
-generic_ret *
-set_string_2(sstring_arg *argp, CLIENT *clnt)
+enum clnt_stat
+set_string_2(sstring_arg *argp, generic_ret *res, CLIENT *clnt)
 {
-     static generic_ret clnt_res;
-
-     memset(&clnt_res, 0, sizeof(clnt_res));
-     if (clnt_call(clnt, SET_STRING,
-		   (xdrproc_t) xdr_sstring_arg, (caddr_t) argp,
-		   (xdrproc_t) xdr_generic_ret, (caddr_t) &clnt_res,
-		   TIMEOUT) != RPC_SUCCESS) {
-	  return (NULL);
-     }
-     return (&clnt_res);
+	return clnt_call(clnt, SET_STRING,
+			 (xdrproc_t)xdr_sstring_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_generic_ret, (caddr_t)res, TIMEOUT);
 }
 
-getpkeys_ret *
-get_principal_keys_2(getpkeys_arg *argp, CLIENT *clnt)
+enum clnt_stat
+get_principal_keys_2(getpkeys_arg *argp, getpkeys_ret *res, CLIENT *clnt)
 {
-     static getpkeys_ret clnt_res;
-
-     memset(&clnt_res, 0, sizeof(clnt_res));
-     if (clnt_call(clnt, EXTRACT_KEYS,
-		   (xdrproc_t)xdr_getpkeys_arg, (caddr_t)argp,
-		   (xdrproc_t)xdr_getpkeys_ret, (caddr_t)&clnt_res,
-		   TIMEOUT) != RPC_SUCCESS) {
-	  return NULL;
-     }
-     return &clnt_res;
+	return clnt_call(clnt, EXTRACT_KEYS,
+			 (xdrproc_t)xdr_getpkeys_arg, (caddr_t)argp,
+			 (xdrproc_t)xdr_getpkeys_ret, (caddr_t)res, TIMEOUT);
 }
diff --git a/src/lib/kadm5/clnt/clnt_policy.c b/src/lib/kadm5/clnt/clnt_policy.c
index 3b3823f..42ba86f 100644
--- a/src/lib/kadm5/clnt/clnt_policy.c
+++ b/src/lib/kadm5/clnt/clnt_policy.c
@@ -18,7 +18,7 @@ kadm5_create_policy(void *server_handle,
                     kadm5_policy_ent_t policy, long mask)
 {
     cpol_arg            arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -29,18 +29,16 @@ kadm5_create_policy(void *server_handle,
     arg.mask = mask;
     arg.api_version = handle->api_version;
     memcpy(&arg.rec, policy, sizeof(kadm5_policy_ent_rec));
-    r = create_policy_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (create_policy_2(&arg, &r, handle->clnt))
         return KADM5_RPC_ERROR;
-
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
 kadm5_delete_policy(void *server_handle, char *name)
 {
     dpol_arg            arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -51,11 +49,9 @@ kadm5_delete_policy(void *server_handle, char *name)
     arg.name = name;
     arg.api_version = handle->api_version;
 
-    r = delete_policy_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (delete_policy_2(&arg, &r, handle->clnt))
         return KADM5_RPC_ERROR;
-
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
@@ -63,7 +59,7 @@ kadm5_modify_policy(void *server_handle,
                     kadm5_policy_ent_t policy, long mask)
 {
     mpol_arg            arg;
-    generic_ret         *r;
+    generic_ret         r = { 0, 0 };
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -75,18 +71,16 @@ kadm5_modify_policy(void *server_handle,
     arg.api_version = handle->api_version;
 
     memcpy(&arg.rec, policy, sizeof(kadm5_policy_ent_rec));
-    r = modify_policy_2(&arg, handle->clnt);
-    if(r == NULL)
+    if (modify_policy_2(&arg, &r, handle->clnt))
         return KADM5_RPC_ERROR;
-
-    return r->code;
+    return r.code;
 }
 
 kadm5_ret_t
 kadm5_get_policy(void *server_handle, char *name, kadm5_policy_ent_t ent)
 {
     gpol_arg        arg;
-    gpol_ret        *r;
+    gpol_ret        r;
     kadm5_server_handle_t handle = server_handle;
 
     memset(ent, 0, sizeof(*ent));
@@ -99,13 +93,12 @@ kadm5_get_policy(void *server_handle, char *name, kadm5_policy_ent_t ent)
     if(name == NULL)
         return EINVAL;
 
-    r = get_policy_2(&arg, handle->clnt);
-    if(r == NULL)
+    memset(&r, 0, sizeof(gpol_ret));
+    if (get_policy_2(&arg, &r, handle->clnt))
         return KADM5_RPC_ERROR;
-    if (r->code == 0)
-        memcpy(ent, &r->rec, sizeof(r->rec));
-
-    return r->code;
+    if (r.code == 0)
+        memcpy(ent, &r.rec, sizeof(r.rec));
+    return r.code;
 }
 
 kadm5_ret_t
@@ -113,7 +106,7 @@ kadm5_get_policies(void *server_handle,
                    char *exp, char ***pols, int *count)
 {
     gpols_arg   arg;
-    gpols_ret   *r;
+    gpols_ret   r;
     kadm5_server_handle_t handle = server_handle;
 
     CHECK_HANDLE(server_handle);
@@ -122,16 +115,16 @@ kadm5_get_policies(void *server_handle,
         return EINVAL;
     arg.exp = exp;
     arg.api_version = handle->api_version;
-    r = get_pols_2(&arg, handle->clnt);
-    if(r == NULL)
+    memset(&r, 0, sizeof(gpols_ret));
+    if (get_pols_2(&arg, &r, handle->clnt))
         return KADM5_RPC_ERROR;
-    if(r->code == 0) {
-        *count = r->count;
-        *pols = r->pols;
+    if (r.code == 0) {
+        *count = r.count;
+        *pols = r.pols;
     } else {
         *count = 0;
         *pols = NULL;
     }
 
-    return r->code;
+    return r.code;
 }
diff --git a/src/lib/kadm5/clnt/clnt_privs.c b/src/lib/kadm5/clnt/clnt_privs.c
index ce55162..0627d72 100644
--- a/src/lib/kadm5/clnt/clnt_privs.c
+++ b/src/lib/kadm5/clnt/clnt_privs.c
@@ -11,17 +11,18 @@
 #include    <kadm5/admin.h>
 #include    <kadm5/kadm_rpc.h>
 #include    "client_internal.h"
+#include    <string.h>
 
 kadm5_ret_t kadm5_get_privs(void *server_handle, long *privs)
 {
-    getprivs_ret *r;
+    getprivs_ret r;
     kadm5_server_handle_t handle = server_handle;
 
-    r = get_privs_2(&handle->api_version, handle->clnt);
-    if (r == NULL)
+    memset(&r, 0, sizeof(getprivs_ret));
+    if (get_privs_2(&handle->api_version, &r, handle->clnt))
         return KADM5_RPC_ERROR;
-    else if (r->code == KADM5_OK)
-        *privs = r->privs;
+    else if (r.code == KADM5_OK)
+        *privs = r.privs;
 
-    return r->code;
+    return r.code;
 }
diff --git a/src/lib/kadm5/kadm_rpc.h b/src/lib/kadm5/kadm_rpc.h
index a75df11..b51156d 100644
--- a/src/lib/kadm5/kadm_rpc.h
+++ b/src/lib/kadm5/kadm_rpc.h
@@ -256,82 +256,96 @@ typedef struct getpkeys_ret getpkeys_ret;
 #define KADM 2112
 #define KADMVERS 2
 #define CREATE_PRINCIPAL 1
-extern  generic_ret * create_principal_2(cprinc_arg *, CLIENT *);
+extern  enum clnt_stat create_principal_2(cprinc_arg *, generic_ret *,
+					  CLIENT *);
 extern  generic_ret * create_principal_2_svc(cprinc_arg *, struct svc_req *);
 #define DELETE_PRINCIPAL 2
-extern  generic_ret * delete_principal_2(dprinc_arg *, CLIENT *);
+extern  enum clnt_stat delete_principal_2(dprinc_arg *, generic_ret *,
+					  CLIENT *);
 extern  generic_ret * delete_principal_2_svc(dprinc_arg *, struct svc_req *);
 #define MODIFY_PRINCIPAL 3
-extern  generic_ret * modify_principal_2(mprinc_arg *, CLIENT *);
+extern  enum clnt_stat modify_principal_2(mprinc_arg *, generic_ret *,
+					  CLIENT *);
 extern  generic_ret * modify_principal_2_svc(mprinc_arg *, struct svc_req *);
 #define RENAME_PRINCIPAL 4
-extern  generic_ret * rename_principal_2(rprinc_arg *, CLIENT *);
+extern  enum clnt_stat rename_principal_2(rprinc_arg *, generic_ret *,
+					  CLIENT *);
 extern  generic_ret * rename_principal_2_svc(rprinc_arg *, struct svc_req *);
 #define GET_PRINCIPAL 5
-extern  gprinc_ret * get_principal_2(gprinc_arg *, CLIENT *);
+extern  enum clnt_stat get_principal_2(gprinc_arg *, gprinc_ret *, CLIENT *);
 extern  gprinc_ret * get_principal_2_svc(gprinc_arg *, struct svc_req *);
 #define CHPASS_PRINCIPAL 6
-extern  generic_ret * chpass_principal_2(chpass_arg *, CLIENT *);
+extern  enum clnt_stat chpass_principal_2(chpass_arg *, generic_ret *,
+					  CLIENT *);
 extern  generic_ret * chpass_principal_2_svc(chpass_arg *, struct svc_req *);
 #define CHRAND_PRINCIPAL 7
-extern  chrand_ret * chrand_principal_2(chrand_arg *, CLIENT *);
+extern  enum clnt_stat chrand_principal_2(chrand_arg *, chrand_ret *,
+					  CLIENT *);
 extern  chrand_ret * chrand_principal_2_svc(chrand_arg *, struct svc_req *);
 #define CREATE_POLICY 8
-extern  generic_ret * create_policy_2(cpol_arg *, CLIENT *);
+extern  enum clnt_stat create_policy_2(cpol_arg *, generic_ret *, CLIENT *);
 extern  generic_ret * create_policy_2_svc(cpol_arg *, struct svc_req *);
 #define DELETE_POLICY 9
-extern  generic_ret * delete_policy_2(dpol_arg *, CLIENT *);
+extern  enum clnt_stat delete_policy_2(dpol_arg *, generic_ret *, CLIENT *);
 extern  generic_ret * delete_policy_2_svc(dpol_arg *, struct svc_req *);
 #define MODIFY_POLICY 10
-extern  generic_ret * modify_policy_2(mpol_arg *, CLIENT *);
+extern  enum clnt_stat modify_policy_2(mpol_arg *, generic_ret *, CLIENT *);
 extern  generic_ret * modify_policy_2_svc(mpol_arg *, struct svc_req *);
 #define GET_POLICY 11
-extern  gpol_ret * get_policy_2(gpol_arg *, CLIENT *);
+extern  enum clnt_stat get_policy_2(gpol_arg *, gpol_ret *, CLIENT *);
 extern  gpol_ret * get_policy_2_svc(gpol_arg *, struct svc_req *);
 #define GET_PRIVS 12
-extern  getprivs_ret * get_privs_2(void *, CLIENT *);
+extern  enum clnt_stat get_privs_2(void *, getprivs_ret *, CLIENT *);
 extern  getprivs_ret * get_privs_2_svc(krb5_ui_4 *, struct svc_req *);
 #define INIT 13
-extern  generic_ret * init_2(void *, CLIENT *);
+extern  enum clnt_stat init_2(void *, generic_ret *, CLIENT *);
 extern  generic_ret * init_2_svc(krb5_ui_4 *, struct svc_req *);
 #define GET_PRINCS 14
-extern  gprincs_ret * get_princs_2(gprincs_arg *, CLIENT *);
+extern  enum clnt_stat get_princs_2(gprincs_arg *, gprincs_ret *, CLIENT *);
 extern  gprincs_ret * get_princs_2_svc(gprincs_arg *, struct svc_req *);
 #define GET_POLS 15
-extern  gpols_ret * get_pols_2(gpols_arg *, CLIENT *);
+extern  enum clnt_stat get_pols_2(gpols_arg *, gpols_ret *, CLIENT *);
 extern  gpols_ret * get_pols_2_svc(gpols_arg *, struct svc_req *);
 #define SETKEY_PRINCIPAL 16
-extern  generic_ret * setkey_principal_2(setkey_arg *, CLIENT *);
+extern  enum clnt_stat setkey_principal_2(setkey_arg *, generic_ret *,
+					  CLIENT *);
 extern  generic_ret * setkey_principal_2_svc(setkey_arg *, struct svc_req *);
 #define SETV4KEY_PRINCIPAL 17
-extern  generic_ret * setv4key_principal_2(setv4key_arg *, CLIENT *);
+extern  enum clnt_stat setv4key_principal_2(setv4key_arg *, generic_ret *,
+					    CLIENT *);
 extern  generic_ret * setv4key_principal_2_svc(setv4key_arg *, struct svc_req *);
 #define CREATE_PRINCIPAL3 18
-extern  generic_ret * create_principal3_2(cprinc3_arg *, CLIENT *);
+extern  enum clnt_stat create_principal3_2(cprinc3_arg *, generic_ret *,
+					   CLIENT *);
 extern  generic_ret * create_principal3_2_svc(cprinc3_arg *, struct svc_req *);
 #define CHPASS_PRINCIPAL3 19
-extern  generic_ret * chpass_principal3_2(chpass3_arg *, CLIENT *);
+extern  enum clnt_stat chpass_principal3_2(chpass3_arg *, generic_ret *,
+					   CLIENT *);
 extern  generic_ret * chpass_principal3_2_svc(chpass3_arg *, struct svc_req *);
 #define CHRAND_PRINCIPAL3 20
-extern  chrand_ret * chrand_principal3_2(chrand3_arg *, CLIENT *);
+extern  enum clnt_stat chrand_principal3_2(chrand3_arg *, chrand_ret *,
+					   CLIENT *);
 extern  chrand_ret * chrand_principal3_2_svc(chrand3_arg *, struct svc_req *);
 #define SETKEY_PRINCIPAL3 21
-extern  generic_ret * setkey_principal3_2(setkey3_arg *, CLIENT *);
+extern  enum clnt_stat setkey_principal3_2(setkey3_arg *, generic_ret *,
+					   CLIENT *);
 extern  generic_ret * setkey_principal3_2_svc(setkey3_arg *, struct svc_req *);
 #define PURGEKEYS 22
-extern  generic_ret * purgekeys_2(purgekeys_arg *, CLIENT *);
+extern  enum clnt_stat purgekeys_2(purgekeys_arg *, generic_ret *, CLIENT *);
 extern  generic_ret * purgekeys_2_svc(purgekeys_arg *, struct svc_req *);
 #define GET_STRINGS 23
-extern  gstrings_ret * get_strings_2(gstrings_arg *, CLIENT *);
+extern  enum clnt_stat get_strings_2(gstrings_arg *, gstrings_ret *, CLIENT *);
 extern  gstrings_ret * get_strings_2_svc(gstrings_arg *, struct svc_req *);
 #define SET_STRING 24
-extern  generic_ret * set_string_2(sstring_arg *, CLIENT *);
+extern  enum clnt_stat set_string_2(sstring_arg *, generic_ret *, CLIENT *);
 extern  generic_ret * set_string_2_svc(sstring_arg *, struct svc_req *);
 #define SETKEY_PRINCIPAL4 25
-extern  generic_ret * setkey_principal4_2(setkey4_arg *, CLIENT *);
+extern  enum clnt_stat setkey_principal4_2(setkey4_arg *, generic_ret *,
+					   CLIENT *);
 extern  generic_ret * setkey_principal4_2_svc(setkey4_arg *, struct svc_req *);
 #define EXTRACT_KEYS 26
-extern  getpkeys_ret * get_principal_keys_2(getpkeys_arg *, CLIENT *);
+extern enum clnt_stat get_principal_keys_2(getpkeys_arg *, getpkeys_ret *,
+					   CLIENT *);
 extern  getpkeys_ret * get_principal_keys_2_svc(getpkeys_arg *, struct svc_req *);
 
 extern bool_t xdr_cprinc_arg ();


More information about the cvs-krb5 mailing list