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