dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / krb5 / kadm5 / clnt / clnt_policy.c
blobdc4f9509e24c3d471c9b1d79de891f4647e94d1f
1 /*
2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
7 /*
8 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
10 * Openvision retains the copyright to derivative works of
11 * this source code. Do *NOT* create a derivative of this
12 * source code before consulting with your legal department.
13 * Do *NOT* integrate *ANY* of this source code into another
14 * product before consulting with your legal department.
16 * For further information, read the top-level Openvision
17 * copyright which is contained in the top-level MIT Kerberos
18 * copyright.
20 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
26 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
28 * $Header$
31 static char *rcsid = "$Header$";
33 #include <rpc/rpc.h> /* SUNWresync121 XXX */
34 #include <kadm5/admin.h>
35 #include <kadm5/kadm_rpc.h>
36 #include "client_internal.h"
37 #include <stdlib.h>
38 #include <string.h>
39 #include <errno.h>
41 kadm5_ret_t
42 kadm5_create_policy(void *server_handle,
43 kadm5_policy_ent_t policy, long mask)
45 cpol_arg arg;
46 generic_ret *r;
47 kadm5_server_handle_t handle = server_handle;
49 CHECK_HANDLE(server_handle);
51 if(policy == (kadm5_policy_ent_t) NULL)
52 return EINVAL;
54 arg.mask = mask;
55 arg.api_version = handle->api_version;
56 memcpy(&arg.rec, policy, sizeof(kadm5_policy_ent_rec));
57 r = create_policy_2(&arg, handle->clnt);
58 if(r == NULL)
59 return KADM5_RPC_ERROR;
61 return r->code;
64 kadm5_ret_t
65 kadm5_delete_policy(void *server_handle, char *name)
67 dpol_arg arg;
68 generic_ret *r;
69 kadm5_server_handle_t handle = server_handle;
71 CHECK_HANDLE(server_handle);
73 if(name == NULL)
74 return EINVAL;
76 arg.name = name;
77 arg.api_version = handle->api_version;
79 r = delete_policy_2(&arg, handle->clnt);
80 if(r == NULL)
81 return KADM5_RPC_ERROR;
83 return r->code;
86 kadm5_ret_t
87 kadm5_modify_policy(void *server_handle,
88 kadm5_policy_ent_t policy, long mask)
90 mpol_arg arg;
91 generic_ret *r;
92 kadm5_server_handle_t handle = server_handle;
94 CHECK_HANDLE(server_handle);
96 if(policy == (kadm5_policy_ent_t) NULL)
97 return EINVAL;
99 arg.mask = mask;
100 arg.api_version = handle->api_version;
102 memcpy(&arg.rec, policy, sizeof(kadm5_policy_ent_rec));
103 r = modify_policy_2(&arg, handle->clnt);
104 if(r == NULL)
105 return KADM5_RPC_ERROR;
107 return r->code;
110 kadm5_ret_t
111 kadm5_get_policy(void *server_handle, char *name, kadm5_policy_ent_t ent)
113 gpol_arg arg;
114 gpol_ret *r;
115 kadm5_server_handle_t handle = server_handle;
117 CHECK_HANDLE(server_handle);
119 arg.name = name;
120 arg.api_version = handle->api_version;
122 if(name == NULL)
123 return EINVAL;
125 r = get_policy_2(&arg, handle->clnt);
126 if(r == NULL)
127 return KADM5_RPC_ERROR;
128 if (handle->api_version == KADM5_API_VERSION_1) {
129 kadm5_policy_ent_t *entp;
131 entp = (kadm5_policy_ent_t *) ent;
132 if(r->code == 0) {
133 if (!(*entp = (kadm5_policy_ent_t)
134 malloc(sizeof(kadm5_policy_ent_rec))))
135 return ENOMEM;
136 memcpy(*entp, &r->rec, sizeof(**entp));
137 } else {
138 *entp = NULL;
140 } else {
141 if (r->code == 0)
142 memcpy(ent, &r->rec, sizeof(r->rec));
145 return r->code;
148 kadm5_ret_t
149 kadm5_get_policies(void *server_handle,
150 char *exp, char ***pols, int *count)
152 gpols_arg arg;
153 gpols_ret *r;
154 kadm5_server_handle_t handle = server_handle;
156 CHECK_HANDLE(server_handle);
158 if(pols == NULL || count == NULL)
159 return EINVAL;
160 arg.exp = exp;
161 arg.api_version = handle->api_version;
162 r = get_pols_2(&arg, handle->clnt);
163 if(r == NULL)
164 return KADM5_RPC_ERROR;
165 if(r->code == 0) {
166 *count = r->count;
167 *pols = r->pols;
168 } else {
169 *count = 0;
170 *pols = NULL;
173 return r->code;