xref: /titanic_50/usr/src/lib/krb5/kadm5/clnt/client_rpc.c (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
1 /*
2  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 /*
9  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
10  *
11  *	Openvision retains the copyright to derivative works of
12  *	this source code.  Do *NOT* create a derivative of this
13  *	source code before consulting with your legal department.
14  *	Do *NOT* integrate *ANY* of this source code into another
15  *	product before consulting with your legal department.
16  *
17  *	For further information, read the top-level Openvision
18  *	copyright which is contained in the top-level MIT Kerberos
19  *	copyright.
20  *
21  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
22  *
23  */
24 
25 
26 #include <rpc/rpc.h> /* SUNWresync121 XXX */
27 #include <kadm5/kadm_rpc.h>
28 #include <krb5.h>
29 #include <kadm5/admin.h>
30 #ifdef HAVE_MEMORY_H
31 #include <memory.h>
32 #endif
33 
34 /* Default timeout can be changed using clnt_control() */
35 static struct timeval TIMEOUT = { 25, 0 };
36 
37 generic_ret *
38 create_principal_1(argp, clnt)
39 	cprinc_arg *argp;
40 	CLIENT *clnt;
41 {
42 	static generic_ret res;
43 
44 	if (clnt == NULL)
45 		return (NULL);
46 	memset((char *)&res, 0, sizeof(res));
47 	if (clnt_call(clnt, CREATE_PRINCIPAL, (xdrproc_t) xdr_cprinc_arg,
48 		(caddr_t) argp, (xdrproc_t) xdr_generic_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
49 		return (NULL);
50 	}
51 	return (&res);
52 }
53 
54 generic_ret *
55 create_principal3_1(argp, clnt)
56 	cprinc3_arg *argp;
57 	CLIENT *clnt;
58 {
59 	static generic_ret res;
60 
61 	if (clnt == NULL)
62 		return (NULL);
63 	memset((char *)&res, 0, sizeof(res));
64 	if (clnt_call(clnt, CREATE_PRINCIPAL3, xdr_cprinc3_arg,
65 		      (caddr_t) argp, /* SUNWresync121 XXX */
66 		      xdr_generic_ret,
67 		      (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
68 		return (NULL);
69 	}
70 	return (&res);
71 }
72 
73 generic_ret *
74 delete_principal_1(argp, clnt)
75 	dprinc_arg *argp;
76 	CLIENT *clnt;
77 {
78 	static generic_ret res;
79 
80 	if (clnt == NULL)
81 		return (NULL);
82 	memset((char *)&res, 0, sizeof(res));
83 	if (clnt_call(clnt, DELETE_PRINCIPAL, xdr_dprinc_arg, (caddr_t) argp,
84 		xdr_generic_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
85 		return (NULL);
86 	}
87 	return (&res);
88 }
89 
90 generic_ret *
91 modify_principal_1(argp, clnt)
92 	mprinc_arg *argp;
93 	CLIENT *clnt;
94 {
95 	static generic_ret res;
96 
97 	if (clnt == NULL)
98 		return (NULL);
99 	memset((char *)&res, 0, sizeof(res));
100 	if (clnt_call(clnt, MODIFY_PRINCIPAL, xdr_mprinc_arg, (caddr_t) argp,
101 		xdr_generic_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
102 		return (NULL);
103 	}
104 	return (&res);
105 }
106 
107 generic_ret *
108 rename_principal_1(argp, clnt)
109 	rprinc_arg *argp;
110 	CLIENT *clnt;
111 {
112 	static generic_ret res;
113 
114 	if (clnt == NULL)
115 		return (NULL);
116 	memset((char *)&res, 0, sizeof(res));
117 	if (clnt_call(clnt, RENAME_PRINCIPAL, xdr_rprinc_arg, (caddr_t) argp,
118 		xdr_generic_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
119 		return (NULL);
120 	}
121 	return (&res);
122 }
123 
124 gprinc_ret *
125 get_principal_1(argp, clnt)
126 	gprinc_arg *argp;
127 	CLIENT *clnt;
128 {
129 	static gprinc_ret res;
130 
131 	if (clnt == NULL)
132 		return (NULL);
133 	memset((char *)&res, 0, sizeof(res));
134 	if (clnt_call(clnt, GET_PRINCIPAL, xdr_gprinc_arg, (caddr_t) argp,
135 		xdr_gprinc_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
136 		return (NULL);
137 	}
138 	return (&res);
139 }
140 
141 gprincs_ret *
142 get_princs_1(argp, clnt)
143 	gprincs_arg *argp;
144 	CLIENT *clnt;
145 {
146 	static gprincs_ret res;
147 
148 	if (clnt == NULL)
149 		return (NULL);
150 	memset((char *)&res, 0, sizeof(res));
151 	if (clnt_call(clnt, GET_PRINCS, xdr_gprincs_arg, (caddr_t) argp,
152 		      xdr_gprincs_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
153 	     return (NULL);
154 	}
155 	return (&res);
156 }
157 
158 generic_ret *
159 chpass_principal_1(argp, clnt)
160 	chpass_arg *argp;
161 	CLIENT *clnt;
162 {
163 	static generic_ret res;
164 
165 	if (clnt == NULL)
166 		return (NULL);
167 	memset((char *)&res, 0, sizeof(res));
168 	if (clnt_call(clnt, CHPASS_PRINCIPAL, xdr_chpass_arg, (caddr_t) argp,
169 		xdr_generic_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
170 		return (NULL);
171 	}
172 	return (&res);
173 }
174 
175 generic_ret *
176 chpass_principal3_1(argp, clnt)
177 	chpass3_arg *argp;
178 	CLIENT *clnt;
179 {
180 	static generic_ret res;
181 
182 	if (clnt == NULL)
183 		return (NULL);
184 	memset((char *)&res, 0, sizeof(res));
185 	if (clnt_call(clnt, CHPASS_PRINCIPAL3, xdr_chpass3_arg,
186 		      (caddr_t) argp, /* SUNWresync 121 XXX */
187 		      xdr_generic_ret, (caddr_t) &res,
188 		      TIMEOUT) != RPC_SUCCESS) {
189 		return (NULL);
190 	}
191 	return (&res);
192 }
193 
194 generic_ret *
195 setv4key_principal_1(argp, clnt)
196 	setv4key_arg *argp;
197 	CLIENT *clnt;
198 {
199 	static generic_ret res;
200 
201 	if (clnt == NULL)
202 		return (NULL);
203 	memset((char *)&res, 0, sizeof(res));
204 	if (clnt_call(clnt, SETV4KEY_PRINCIPAL, xdr_setv4key_arg,
205 		      (caddr_t) argp, /* SUNWresync121 XXX */
206 		      xdr_generic_ret, (caddr_t) &res,
207 		      TIMEOUT) != RPC_SUCCESS) {
208 		return (NULL);
209 	}
210 	return (&res);
211 }
212 
213 generic_ret *
214 setkey_principal_1(argp, clnt)
215 	setkey_arg *argp;
216 	CLIENT *clnt;
217 {
218 	static generic_ret res;
219 
220 	if (clnt == NULL)
221 		return (NULL);
222 	memset((char *)&res, 0, sizeof(res));
223 	if (clnt_call(clnt, SETKEY_PRINCIPAL, xdr_setkey_arg,
224 		      (caddr_t) argp, /* SUNWresync121 XXX */
225 		      xdr_generic_ret, (caddr_t) &res,
226 		      TIMEOUT) != RPC_SUCCESS) {
227 		return (NULL);
228 	}
229 	return (&res);
230 }
231 
232 generic_ret *
233 setkey_principal3_1(argp, clnt)
234 	setkey3_arg *argp;
235 	CLIENT *clnt;
236 {
237 	static generic_ret res;
238 
239 	if (clnt == NULL)
240 		return (NULL);
241 	memset((char *)&res, 0, sizeof(res));
242 	if (clnt_call(clnt, SETKEY_PRINCIPAL3, xdr_setkey3_arg,
243 		      (caddr_t) argp, /* SUNWresync121 XXX */
244 		      xdr_generic_ret, (caddr_t) &res,
245 		      TIMEOUT) != RPC_SUCCESS) {
246 		return (NULL);
247 	}
248 	return (&res);
249 }
250 
251 chrand_ret *
252 chrand_principal_1(argp, clnt)
253 	chrand_arg *argp;
254 	CLIENT *clnt;
255 {
256 	static chrand_ret res;
257 
258 	if (clnt == NULL)
259 		return (NULL);
260 	memset((char *)&res, 0, sizeof(res));
261 	if (clnt_call(clnt, CHRAND_PRINCIPAL, xdr_chrand_arg, (caddr_t) argp,
262 		xdr_chrand_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
263 		return (NULL);
264 	}
265 	return (&res);
266 }
267 
268 chrand_ret *
269 chrand_principal3_1(argp, clnt)
270 	chrand3_arg *argp;
271 	CLIENT *clnt;
272 {
273 	static chrand_ret res;
274 
275 	if (clnt == NULL)
276 		return (NULL);
277 	memset((char *)&res, 0, sizeof(res));
278 	if (clnt_call(clnt, CHRAND_PRINCIPAL3, xdr_chrand3_arg,
279 		      (caddr_t) argp, /* SUNWresync121 XXX */
280 		      xdr_chrand_ret, (caddr_t) &res,
281 		      TIMEOUT) != RPC_SUCCESS) {
282 		return (NULL);
283 	}
284 	return (&res);
285 }
286 
287 generic_ret *
288 create_policy_1(argp, clnt)
289 	cpol_arg *argp;
290 	CLIENT *clnt;
291 {
292 	static generic_ret res;
293 
294 	if (clnt == NULL)
295 		return (NULL);
296 	memset((char *)&res, 0, sizeof(res));
297 	if (clnt_call(clnt, CREATE_POLICY, xdr_cpol_arg, (caddr_t) argp,
298 		xdr_generic_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
299 		return (NULL);
300 	}
301 	return (&res);
302 }
303 
304 generic_ret *
305 delete_policy_1(argp, clnt)
306 	dpol_arg *argp;
307 	CLIENT *clnt;
308 {
309 	static generic_ret res;
310 
311 	if (clnt == NULL)
312 		return (NULL);
313 	memset((char *)&res, 0, sizeof(res));
314 	if (clnt_call(clnt, DELETE_POLICY, xdr_dpol_arg, (caddr_t) argp,
315 		xdr_generic_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
316 		return (NULL);
317 	}
318 	return (&res);
319 }
320 
321 generic_ret *
322 modify_policy_1(argp, clnt)
323 	mpol_arg *argp;
324 	CLIENT *clnt;
325 {
326 	static generic_ret res;
327 
328 	if (clnt == NULL)
329 		return (NULL);
330 	memset((char *)&res, 0, sizeof(res));
331 	if (clnt_call(clnt, MODIFY_POLICY, xdr_mpol_arg, (caddr_t) argp,
332 		xdr_generic_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
333 		return (NULL);
334 	}
335 	return (&res);
336 }
337 
338 gpol_ret *
339 get_policy_1(argp, clnt)
340 	gpol_arg *argp;
341 	CLIENT *clnt;
342 {
343 	static gpol_ret res;
344 
345 	if (clnt == NULL)
346 		return (NULL);
347 	memset((char *)&res, 0, sizeof(res));
348 	if (clnt_call(clnt, GET_POLICY, xdr_gpol_arg, (caddr_t) argp,
349 		xdr_gpol_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
350 		return (NULL);
351 	}
352 	return (&res);
353 }
354 
355 gpols_ret *
356 get_pols_1(argp, clnt)
357 	gpols_arg *argp;
358 	CLIENT *clnt;
359 {
360 	static gpols_ret res;
361 
362 	if (clnt == NULL)
363 		return (NULL);
364 	memset((char *)&res, 0, sizeof(res));
365 	if (clnt_call(clnt, GET_POLS, xdr_gpols_arg, (caddr_t) argp,
366 		      xdr_gpols_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
367 	     return (NULL);
368 	}
369 	return (&res);
370 }
371 
372 getprivs_ret *get_privs_1(argp, clnt)
373    void *argp;
374    CLIENT *clnt;
375 {
376      static getprivs_ret res;
377 
378 	if (clnt == NULL)
379 		return (NULL);
380      memset((char *)&res, 0, sizeof(res));
381      if (clnt_call(clnt, GET_PRIVS, xdr_u_int, (caddr_t) argp,
382 		   xdr_getprivs_ret, (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
383 	  return (NULL);
384      }
385      return (&res);
386 }
387 
388 generic_ret *
389 init_1(argp, clnt, rpc_err_code)
390    void *argp;
391    CLIENT *clnt;
392    enum clnt_stat *rpc_err_code;
393 {
394      static generic_ret res;
395 
396      enum clnt_stat retval;
397 
398 	if (clnt == NULL)
399 		return (NULL);
400      memset((char *)&res, 0, sizeof(res));
401      retval = clnt_call(clnt, INIT, xdr_u_int, (caddr_t) argp,
402 		   xdr_generic_ret, (caddr_t) &res, TIMEOUT);
403 
404      if (retval != RPC_SUCCESS) {
405 	  *rpc_err_code = retval;
406 	  return (NULL);
407      }
408      return (&res);
409 }
410