]> sourceware.org Git - glibc.git/blame - nis/nis_table.c
Update.
[glibc.git] / nis / nis_table.c
CommitLineData
6f0ee462 1/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
e61abf83
UD
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
19
20#include <string.h>
21#include <rpcsvc/nis.h>
91eee4dd
UD
22
23#include "nis_xdr.h"
e61abf83
UD
24#include "nis_intern.h"
25
d6db1d53
UD
26
27static struct ib_request *
a1129917 28__create_ib_request (const_nis_name name, unsigned int flags)
e61abf83 29{
d6db1d53
UD
30 struct ib_request *ibreq = calloc (1, sizeof (ib_request));
31 char buf[strlen (name) + 1];
32 nis_attr *search_val = NULL;
33 int search_len = 0;
34 char *cptr;
35 size_t size = 0;
e61abf83 36
d6db1d53 37 ibreq->ibr_flags = flags;
e61abf83 38
d6db1d53 39 cptr = strcpy (buf, name);
e61abf83
UD
40
41 /* Not of "[key=value,key=value,...],foo.." format? */
42 if (cptr[0] != '[')
43 {
d6db1d53
UD
44 ibreq->ibr_name = strdup (cptr);
45 return ibreq;
e61abf83
UD
46 }
47
d6db1d53
UD
48 /* "[key=value,...],foo" format */
49 ibreq->ibr_name = strchr (cptr, ']');
50 if (ibreq->ibr_name == NULL || ibreq->ibr_name[1] != ',')
51 return NULL;
e61abf83 52
d6db1d53
UD
53 /* Check if we have an entry of "[key=value,],bar". If, remove the "," */
54 if (ibreq->ibr_name[-1] == ',')
55 ibreq->ibr_name[-1] = '\0';
56 else
57 ibreq->ibr_name[0] = '\0';
58 ibreq->ibr_name += 2;
59 ibreq->ibr_name = strdup (ibreq->ibr_name);
e61abf83 60
d6db1d53 61 ++cptr; /* Remove "[" */
e61abf83 62
d6db1d53 63 while (cptr != NULL && cptr[0] != '\0')
e61abf83 64 {
d6db1d53
UD
65 char *key = cptr;
66 char *val = strchr (cptr, '=');
67
68 cptr = strchr (key, ',');
69 if (cptr != NULL)
70 *cptr++ = '\0';
e61abf83 71
e61abf83
UD
72 if (!val)
73 {
d6db1d53
UD
74 nis_free_request (ibreq);
75 return NULL;
e61abf83 76 }
d6db1d53
UD
77 *val++ = '\0';
78 if ((search_len + 1) >= size)
79 {
80 size += 1;
81 if (size == 1)
82 search_val = malloc (size * sizeof (nis_attr));
83 else
84 search_val = realloc (search_val, size * sizeof (nis_attr));
85 if (search_val == NULL)
e61abf83 86 {
d6db1d53
UD
87 nis_free_request (ibreq);
88 return NULL;
e61abf83
UD
89 }
90 }
d6db1d53
UD
91 search_val[search_len].zattr_ndx = strdup (key);
92 if ((search_val[search_len].zattr_ndx) == NULL)
93 {
94 nis_free_request (ibreq);
95 return NULL;
96 }
97 search_val[search_len].zattr_val.zattr_val_len = strlen (val) + 1;
98 search_val[search_len].zattr_val.zattr_val_val = strdup (val);
99 if (search_val[search_len].zattr_val.zattr_val_val == NULL)
100 {
101 nis_free_request (ibreq);
102 return NULL;
103 }
104 ++search_len;
e61abf83 105 }
e61abf83 106
d6db1d53
UD
107 ibreq->ibr_srch.ibr_srch_val = search_val;
108 ibreq->ibr_srch.ibr_srch_len = search_len;
e61abf83
UD
109
110 return ibreq;
111}
112
e852e889
UD
113static struct timeval RPCTIMEOUT = {10, 0};
114
115static char *
116__get_tablepath (char *name, dir_binding *bptr)
117{
118 enum clnt_stat result;
119 nis_result *res = calloc (1, sizeof (nis_result));
120 struct ns_request req;
121
122 if (res == NULL)
123 return NULL;
124
125 req.ns_name = name;
126 req.ns_object.ns_object_len = 0;
127 req.ns_object.ns_object_val = NULL;
128
129 result = clnt_call (bptr->clnt, NIS_LOOKUP, (xdrproc_t) _xdr_ns_request,
130 (caddr_t) &req, (xdrproc_t) _xdr_nis_result,
131 (caddr_t) res, RPCTIMEOUT);
132
133 if (result == RPC_SUCCESS && NIS_RES_STATUS (res) == NIS_SUCCESS &&
134 __type_of (NIS_RES_OBJECT (res)) == NIS_TABLE_OBJ)
135 {
136 char *cptr = strdup (NIS_RES_OBJECT (res)->TA_data.ta_path);
137 nis_freeresult (res);
138 return cptr;
139 }
140 else
141 {
142 nis_freeresult (res);
143 return strdup ("");
144 }
145}
146
e61abf83 147nis_result *
a1129917 148nis_list (const_nis_name name, unsigned int flags,
c131718c 149 int (*callback) (const_nis_name name,
e61abf83
UD
150 const nis_object *object,
151 const void *userdata),
152 const void *userdata)
153{
154 nis_result *res = NULL;
d6db1d53 155 ib_request *ibreq;
2d7da676 156 int status;
e852e889 157 enum clnt_stat clnt_status;
650425ce 158 int count_links = 0; /* We will only follow NIS_MAXLINKS links! */
2d7da676
UD
159 int done = 0;
160 nis_name *names;
161 nis_name namebuf[2] = {NULL, NULL};
162 int name_nr = 0;
650425ce 163 nis_cb *cb = NULL;
e852e889
UD
164 char *tableptr, *tablepath = NULL;
165 int have_tablepath = 0;
166 int first_try = 0; /* Do we try the old binding at first ? */
e61abf83
UD
167
168 res = calloc (1, sizeof (nis_result));
91eee4dd
UD
169 if (res == NULL)
170 return NULL;
e61abf83 171
d6db1d53
UD
172 if (name == NULL)
173 {
174 NIS_RES_STATUS (res) = NIS_BADNAME;
175 return res;
176 }
177
178 if ((ibreq = __create_ib_request (name, flags)) == NULL)
e61abf83 179 {
91eee4dd 180 NIS_RES_STATUS (res) = NIS_BADNAME;
e61abf83
UD
181 return res;
182 }
183
d6db1d53
UD
184 if ((flags & EXPAND_NAME) &&
185 ibreq->ibr_name[strlen (ibreq->ibr_name) - 1] != '.')
e61abf83 186 {
dfd2257a
UD
187 names = nis_getnames (ibreq->ibr_name);
188 free (ibreq->ibr_name);
189 ibreq->ibr_name = NULL;
2d7da676 190 if (names == NULL)
e61abf83 191 {
91eee4dd 192 NIS_RES_STATUS (res) = NIS_BADNAME;
e61abf83
UD
193 return res;
194 }
dfd2257a 195 ibreq->ibr_name = strdup (names[name_nr]);
2d7da676
UD
196 }
197 else
650425ce
UD
198 {
199 names = namebuf;
dfd2257a 200 names[name_nr] = ibreq->ibr_name;
650425ce 201 }
e61abf83 202
650425ce
UD
203 cb = NULL;
204
e852e889 205 while (!done)
2d7da676 206 {
e852e889
UD
207 dir_binding bptr;
208 directory_obj *dir = NULL;
650425ce 209
e852e889 210 memset (res, '\0', sizeof (nis_result));
650425ce 211
e852e889
UD
212 status = __nisfind_server (ibreq->ibr_name, &dir);
213 if (status != NIS_SUCCESS)
214 {
215 NIS_RES_STATUS (res) = status;
216 return res;
217 }
650425ce 218
e852e889
UD
219 status = __nisbind_create (&bptr, dir->do_servers.do_servers_val,
220 dir->do_servers.do_servers_len, flags);
221 if (status != NIS_SUCCESS)
222 {
223 NIS_RES_STATUS (res) = status;
224 nis_free_directory (dir);
225 return res;
226 }
6f0ee462 227
e852e889
UD
228 while (__nisbind_connect (&bptr) != NIS_SUCCESS)
229 if (__nisbind_next (&bptr) != NIS_SUCCESS)
230 {
231 __nisbind_destroy (&bptr);
232 nis_free_directory (dir);
233 NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE;
234 return res;
235 }
6f0ee462 236
650425ce
UD
237 if (callback != NULL)
238 {
239 cb = __nis_create_callback (callback, userdata, flags);
dfd2257a
UD
240 ibreq->ibr_cbhost.ibr_cbhost_len = 1;
241 ibreq->ibr_cbhost.ibr_cbhost_val = cb->serv;
e852e889 242 }
650425ce 243
e852e889
UD
244 again:
245 clnt_status = clnt_call (bptr.clnt, NIS_IBLIST,
246 (xdrproc_t) _xdr_ib_request, (caddr_t) ibreq,
247 (xdrproc_t) _xdr_nis_result,
248 (caddr_t) res, RPCTIMEOUT);
249
250 if (clnt_status != RPC_SUCCESS)
251 NIS_RES_STATUS (res) = NIS_RPCERROR;
252 else
253 switch (NIS_RES_STATUS (res))
254 { /* start switch */
255 case NIS_PARTIAL:
256 case NIS_SUCCESS:
257 case NIS_S_SUCCESS:
258 if (__type_of (NIS_RES_OBJECT (res)) == NIS_LINK_OBJ &&
259 flags & FOLLOW_LINKS) /* We are following links. */
260 {
261 free (ibreq->ibr_name);
262 /* If we hit the link limit, bail. */
263 if (count_links > NIS_MAXLINKS)
264 {
265 NIS_RES_STATUS (res) = NIS_LINKNAMEERROR;
266 ++done;
267 break;
268 }
269 ++count_links;
270 ibreq->ibr_name =
271 strdup (NIS_RES_OBJECT (res)->LI_data.li_name);
272 if (NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len)
273 if (ibreq->ibr_srch.ibr_srch_len == 0)
650425ce 274 {
e852e889
UD
275 ibreq->ibr_srch.ibr_srch_len =
276 NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len;
277 ibreq->ibr_srch.ibr_srch_val =
278 NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_val;
650425ce 279 }
e852e889
UD
280 nis_freeresult (res);
281 res = calloc (1, sizeof (nis_result));
282 if (res == NULL)
283 {
284 if (have_tablepath)
285 free (tablepath);
286 __nisbind_destroy (&bptr);
287 nis_free_directory (dir);
288 return NULL;
289 }
290 first_try = 1; /* Try at first the old binding */
291 goto again;
292 }
293 else if ((flags & FOLLOW_PATH) &&
294 NIS_RES_STATUS (res) == NIS_PARTIAL)
295 {
296 if (!have_tablepath)
297 {
298 tablepath = __get_tablepath (ibreq->ibr_name, &bptr);
299 tableptr = tablepath;
300 have_tablepath = 1;
301 }
302 if (tableptr == NULL)
303 {
304 ++done;
305 break;
306 }
307 free (ibreq->ibr_name);
308 ibreq->ibr_name = strsep (&tableptr, ":");
309 if (ibreq->ibr_name == NULL || ibreq->ibr_name[0] == '\0')
310 {
311 ibreq->ibr_name = strdup ("");
312 ++done;
313 }
314 else
315 {
316 ibreq->ibr_name = strdup (ibreq->ibr_name);
317 nis_freeresult (res);
318 res = calloc (1, sizeof (nis_result));
319 if (res == NULL)
650425ce 320 {
e852e889
UD
321 if (have_tablepath)
322 free (tablepath);
323 __nisbind_destroy (&bptr);
324 nis_free_directory (dir);
325 return NULL;
650425ce 326 }
e852e889
UD
327 first_try = 1;
328 goto again;
329 }
330 }
331 else
2d7da676 332 ++done;
e852e889
UD
333 break;
334 case NIS_CBRESULTS:
335 if (cb != NULL)
336 {
337 __nis_do_callback (&bptr, &res->cookie, cb);
338 NIS_RES_STATUS (res) = cb->result;
339
340 if (!(flags & ALL_RESULTS))
650425ce 341 ++done;
e852e889
UD
342 else
343 {
344 if (!have_tablepath)
345 {
346 tablepath = __get_tablepath (ibreq->ibr_name, &bptr);
347 tableptr = tablepath;
348 have_tablepath = 1;
349 }
350 if (tableptr == NULL)
351 {
352 ++done;
353 break;
354 }
355 free (ibreq->ibr_name);
356 ibreq->ibr_name = strsep (&tableptr, ":");
357 if (ibreq->ibr_name == NULL || ibreq->ibr_name[0] == '\0')
358 {
359 ibreq->ibr_name = strdup ("");
360 ++done;
361 }
362 else
363 ibreq->ibr_name = strdup (ibreq->ibr_name);
364 }
365 }
366 break;
367 case NIS_SYSTEMERROR:
368 case NIS_NOSUCHNAME:
369 case NIS_NOT_ME:
370 /* If we had first tried the old binding, do nothing, but
371 get a new binding */
372 if (!first_try)
373 {
374 if (__nisbind_next (&bptr) != NIS_SUCCESS)
375 {
376 ++done;
377 break; /* No more servers to search */
378 }
379 while (__nisbind_connect (&bptr) != NIS_SUCCESS)
380 {
381 if (__nisbind_next (&bptr) != NIS_SUCCESS)
382 {
383 ++done;
384 break; /* No more servers to search */
385 }
386 }
387 goto again;
388 }
389 break;
390 default:
391 if (!first_try)
392 {
393 /* Try the next domainname if we don't follow a link. */
394 if (count_links)
395 {
396 free (ibreq->ibr_name);
397 NIS_RES_STATUS (res) = NIS_LINKNAMEERROR;
398 ++done;
399 break;
400 }
401 ++name_nr;
402 if (names[name_nr] == NULL)
403 {
404 ++done;
405 break;
406 }
407 ibreq->ibr_name = names[name_nr];
408 first_try = 1; /* Try old binding at first */
409 goto again;
410 }
411 break;
412 }
413 first_try = 0;
414
415 if (cb)
416 {
417 __nis_destroy_callback (cb);
418 ibreq->ibr_cbhost.ibr_cbhost_len = 0;
419 ibreq->ibr_cbhost.ibr_cbhost_val = NULL;
e61abf83 420 }
e852e889
UD
421
422 __nisbind_destroy (&bptr);
423 nis_free_directory (dir);
424 }
e61abf83 425
2d7da676
UD
426 if (names != namebuf)
427 nis_freenames (names);
428
dfd2257a 429 nis_free_request (ibreq);
e61abf83
UD
430
431 return res;
432}
433
434nis_result *
a1129917 435nis_add_entry (const_nis_name name, const nis_object *obj2, unsigned int flags)
e61abf83 436{
91eee4dd 437 nis_object obj;
e61abf83 438 nis_result *res;
e61abf83 439 nis_error status;
d6db1d53
UD
440 ib_request *ibreq;
441 size_t namelen = strlen (name);
442 char buf1[namelen + 20];
443 char buf4[namelen + 20];
e61abf83
UD
444
445 res = calloc (1, sizeof (nis_result));
91eee4dd
UD
446 if (res == NULL)
447 return NULL;
448
d6db1d53 449 if (name == NULL)
91eee4dd 450 {
d6db1d53 451 NIS_RES_STATUS (res) = NIS_BADNAME;
91eee4dd
UD
452 return res;
453 }
e61abf83 454
d6db1d53 455 if ((ibreq = __create_ib_request (name, flags)) == NULL)
e61abf83 456 {
91eee4dd 457 NIS_RES_STATUS (res) = NIS_BADNAME;
e61abf83
UD
458 return res;
459 }
460
91eee4dd 461 memcpy (&obj, obj2, sizeof (nis_object));
e61abf83 462
91eee4dd
UD
463 if (obj.zo_name == NULL || strlen (obj.zo_name) == 0)
464 obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1));
ce37fa88 465
91eee4dd
UD
466 if (obj.zo_owner == NULL || strlen (obj.zo_owner) == 0)
467 obj.zo_owner = nis_local_principal ();
ce37fa88 468
91eee4dd
UD
469 if (obj.zo_group == NULL || strlen (obj.zo_group) == 0)
470 obj.zo_group = nis_local_group ();
ce37fa88 471
91eee4dd
UD
472 obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4));
473
474 ibreq->ibr_obj.ibr_obj_val = nis_clone_object (&obj, NULL);
475 if (ibreq->ibr_obj.ibr_obj_val == NULL)
476 {
477 NIS_RES_STATUS (res) = NIS_NOMEMORY;
478 return res;
479 }
480 ibreq->ibr_obj.ibr_obj_len = 1;
ce37fa88 481
dfd2257a 482 if ((status = __do_niscall (ibreq->ibr_name, NIS_IBADD,
91eee4dd 483 (xdrproc_t) _xdr_ib_request,
dfd2257a 484 (caddr_t) ibreq,
91eee4dd 485 (xdrproc_t) _xdr_nis_result,
650425ce 486 (caddr_t) res, 0, NULL)) != NIS_SUCCESS)
91eee4dd 487 NIS_RES_STATUS (res) = status;
ce37fa88 488
dfd2257a 489 nis_free_request (ibreq);
e61abf83
UD
490
491 return res;
492}
493
494nis_result *
a1129917
UD
495nis_modify_entry (const_nis_name name, const nis_object *obj2,
496 unsigned int flags)
e61abf83 497{
91eee4dd 498 nis_object obj;
e61abf83 499 nis_result *res;
e61abf83 500 nis_error status;
d6db1d53
UD
501 ib_request *ibreq;
502 size_t namelen = strlen (name);
503 char buf1[namelen + 20];
504 char buf4[namelen + 20];
e61abf83
UD
505
506 res = calloc (1, sizeof (nis_result));
d6db1d53
UD
507 if (res == NULL)
508 return NULL;
e61abf83 509
d6db1d53 510 if (( ibreq =__create_ib_request (name, flags)) == NULL)
e61abf83 511 {
91eee4dd 512 NIS_RES_STATUS (res) = NIS_BADNAME;
e61abf83
UD
513 return res;
514 }
515
91eee4dd 516 memcpy (&obj, obj2, sizeof (nis_object));
e61abf83 517
91eee4dd
UD
518 if (obj.zo_name == NULL || strlen (obj.zo_name) == 0)
519 obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1));
ce37fa88 520
91eee4dd
UD
521 if (obj.zo_owner == NULL || strlen (obj.zo_owner) == 0)
522 obj.zo_owner = nis_local_principal ();
ce37fa88 523
91eee4dd
UD
524 if (obj.zo_group == NULL || strlen (obj.zo_group) == 0)
525 obj.zo_group = nis_local_group ();
ce37fa88 526
91eee4dd
UD
527 obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4));
528
529 ibreq->ibr_obj.ibr_obj_val = nis_clone_object (&obj, NULL);
530 if (ibreq->ibr_obj.ibr_obj_val == NULL)
531 {
532 NIS_RES_STATUS (res) = NIS_NOMEMORY;
533 return res;
534 }
535 ibreq->ibr_obj.ibr_obj_len = 1;
ce37fa88 536
dfd2257a 537 if ((status = __do_niscall (ibreq->ibr_name, NIS_IBMODIFY,
91eee4dd
UD
538 (xdrproc_t) _xdr_ib_request,
539 (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
650425ce 540 (caddr_t) res, 0, NULL)) != NIS_SUCCESS)
91eee4dd 541 NIS_RES_STATUS (res) = status;
ce37fa88 542
dfd2257a 543 nis_free_request (ibreq);
e61abf83
UD
544
545 return res;
546}
547
548nis_result *
c131718c 549nis_remove_entry (const_nis_name name, const nis_object *obj,
a1129917 550 unsigned int flags)
e61abf83
UD
551{
552 nis_result *res;
d6db1d53 553 ib_request *ibreq;
e61abf83
UD
554 nis_error status;
555
556 res = calloc (1, sizeof (nis_result));
91eee4dd
UD
557 if (res == NULL)
558 return NULL;
559
d6db1d53 560 if (name == NULL)
91eee4dd 561 {
d6db1d53 562 NIS_RES_STATUS (res) = NIS_BADNAME;
91eee4dd
UD
563 return res;
564 }
e61abf83 565
d6db1d53 566 if ((ibreq =__create_ib_request (name, flags)) == NULL)
e61abf83 567 {
91eee4dd 568 NIS_RES_STATUS (res) = NIS_BADNAME;
e61abf83
UD
569 return res;
570 }
571
e61abf83
UD
572 if (obj != NULL)
573 {
dfd2257a 574 ibreq->ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
91eee4dd
UD
575 if (ibreq->ibr_obj.ibr_obj_val == NULL)
576 {
577 NIS_RES_STATUS (res) = NIS_NOMEMORY;
578 return res;
579 }
dfd2257a 580 ibreq->ibr_obj.ibr_obj_len = 1;
e61abf83
UD
581 }
582
dfd2257a 583 if ((status = __do_niscall (ibreq->ibr_name, NIS_IBREMOVE,
91eee4dd
UD
584 (xdrproc_t) _xdr_ib_request,
585 (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
650425ce 586 (caddr_t) res, 0, NULL)) != NIS_SUCCESS)
91eee4dd 587 NIS_RES_STATUS (res) = status;
e61abf83 588
dfd2257a 589 nis_free_request (ibreq);
e61abf83
UD
590
591 return res;
592}
593
594nis_result *
c131718c 595nis_first_entry (const_nis_name name)
e61abf83
UD
596{
597 nis_result *res;
d6db1d53 598 ib_request *ibreq;
e61abf83
UD
599 nis_error status;
600
601 res = calloc (1, sizeof (nis_result));
91eee4dd
UD
602 if (res == NULL)
603 return NULL;
604
d6db1d53 605 if (name == NULL)
91eee4dd 606 {
d6db1d53 607 NIS_RES_STATUS (res) = NIS_BADNAME;
91eee4dd
UD
608 return res;
609 }
e61abf83 610
d6db1d53 611 if ((ibreq =__create_ib_request (name, 0)) == NULL)
e61abf83 612 {
91eee4dd 613 NIS_RES_STATUS (res) = NIS_BADNAME;
e61abf83
UD
614 return res;
615 }
616
dfd2257a 617 if ((status = __do_niscall (ibreq->ibr_name, NIS_IBFIRST,
91eee4dd
UD
618 (xdrproc_t) _xdr_ib_request,
619 (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
650425ce 620 (caddr_t) res, 0, NULL)) != NIS_SUCCESS)
91eee4dd 621 NIS_RES_STATUS (res) = status;
e61abf83 622
dfd2257a 623 nis_free_request (ibreq);
e61abf83
UD
624
625 return res;
626}
627
628nis_result *
c131718c 629nis_next_entry (const_nis_name name, const netobj *cookie)
e61abf83
UD
630{
631 nis_result *res;
d6db1d53 632 ib_request *ibreq;
e61abf83
UD
633 nis_error status;
634
635 res = calloc (1, sizeof (nis_result));
91eee4dd
UD
636 if (res == NULL)
637 return NULL;
638
d6db1d53 639 if (name == NULL)
91eee4dd 640 {
d6db1d53 641 NIS_RES_STATUS (res) = NIS_BADNAME;
91eee4dd
UD
642 return res;
643 }
e61abf83 644
d6db1d53 645 if (( ibreq =__create_ib_request (name, 0)) == NULL)
e61abf83 646 {
91eee4dd 647 NIS_RES_STATUS (res) = NIS_BADNAME;
e61abf83
UD
648 return res;
649 }
650
651 if (cookie != NULL)
652 {
d6db1d53 653 ibreq->ibr_cookie.n_bytes = cookie->n_bytes;
dfd2257a 654 ibreq->ibr_cookie.n_len = cookie->n_len;
e61abf83
UD
655 }
656
dfd2257a 657 if ((status = __do_niscall (ibreq->ibr_name, NIS_IBNEXT,
91eee4dd
UD
658 (xdrproc_t) _xdr_ib_request,
659 (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
650425ce 660 (caddr_t) res, 0, NULL)) != NIS_SUCCESS)
91eee4dd 661 NIS_RES_STATUS (res) = status;
e61abf83 662
d6db1d53
UD
663 if (cookie != NULL)
664 {
665 /* Don't give cookie free, it is not from us */
666 ibreq->ibr_cookie.n_bytes = NULL;
667 ibreq->ibr_cookie.n_len = 0;
668 }
669
dfd2257a 670 nis_free_request (ibreq);
e61abf83
UD
671
672 return res;
673}
This page took 0.122721 seconds and 5 git commands to generate.