dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / krb5 / kadm5 / misc_free.c
blob26d0882e0d7de82043cedec42bdfbfc782fa4017
1 /*
2 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4 * Openvision retains the copyright to derivative works of
5 * this source code. Do *NOT* create a derivative of this
6 * source code before consulting with your legal department.
7 * Do *NOT* integrate *ANY* of this source code into another
8 * product before consulting with your legal department.
10 * For further information, read the top-level Openvision
11 * copyright which is contained in the top-level MIT Kerberos
12 * copyright.
14 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
20 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
22 * $Header$
25 static char *rcsid = "$Header$";
26 #include "server_internal.h"
27 #include <kadm5/admin.h>
28 #include <stdlib.h>
30 kadm5_ret_t
31 kadm5_free_policy_ent(void *server_handle, kadm5_policy_ent_t val)
33 kadm5_server_handle_t handle = server_handle;
35 _KADM5_CHECK_HANDLE(server_handle);
37 if(val) {
38 free(val->policy);
39 if (handle->api_version == KADM5_API_VERSION_1)
40 free(val);
42 return KADM5_OK;
45 kadm5_ret_t
46 kadm5_free_name_list(void *server_handle, char **names, int count)
48 _KADM5_CHECK_HANDLE(server_handle);
50 while (count--)
51 free(names[count]);
52 free(names);
53 return KADM5_OK;
56 /* XXX this ought to be in libkrb5.a, but isn't */
57 kadm5_ret_t krb5_free_key_data_contents(context, key)
58 krb5_context context;
59 krb5_key_data *key;
61 int i, idx;
63 idx = (key->key_data_ver == 1 ? 1 : 2);
64 for (i = 0; i < idx; i++) {
65 if (key->key_data_contents[i]) {
66 memset(key->key_data_contents[i], 0, key->key_data_length[i]);
67 free(key->key_data_contents[i]);
70 return KADM5_OK;
73 kadm5_ret_t kadm5_free_key_data(void *server_handle,
74 krb5_int16 *n_key_data,
75 krb5_key_data *key_data)
77 kadm5_server_handle_t handle = server_handle;
78 int i, nkeys = (int) *n_key_data;
80 _KADM5_CHECK_HANDLE(server_handle);
82 if (key_data == NULL)
83 return KADM5_OK;
85 for (i = 0; i < nkeys; i++)
86 krb5_free_key_data_contents(handle->context, &key_data[i]);
87 free(key_data);
88 return KADM5_OK;
91 kadm5_ret_t
92 kadm5_free_principal_ent(void *server_handle,
93 kadm5_principal_ent_t val)
95 kadm5_server_handle_t handle = server_handle;
96 int i;
98 _KADM5_CHECK_HANDLE(server_handle);
100 if(val) {
101 if(val->principal)
102 krb5_free_principal(handle->context, val->principal);
103 if(val->mod_name)
104 krb5_free_principal(handle->context, val->mod_name);
105 free(val->policy);
106 if (handle->api_version > KADM5_API_VERSION_1) {
107 if (val->n_key_data) {
108 for (i = 0; i < val->n_key_data; i++)
109 krb5_free_key_data_contents(handle->context,
110 &val->key_data[i]);
111 free(val->key_data);
113 if (val->tl_data) {
114 krb5_tl_data *tl;
116 while (val->tl_data) {
117 tl = val->tl_data->tl_data_next;
118 free(val->tl_data->tl_data_contents);
119 free(val->tl_data);
120 val->tl_data = tl;
125 if (handle->api_version == KADM5_API_VERSION_1)
126 free(val);
128 return KADM5_OK;