Use common bits/shm.h for more architectures.
[glibc.git] / nis / nis_table.c
blob0a7f54eac665b086a6c09ff407fda4c3cba2dd49
1 /* Copyright (c) 1997-2018 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <assert.h>
20 #include <string.h>
21 #include <rpcsvc/nis.h>
22 #include <libc-diag.h>
23 #include <shlib-compat.h>
25 #include "nis_xdr.h"
26 #include "nis_intern.h"
27 #include "libnsl.h"
30 struct ib_request *
31 __create_ib_request (const_nis_name name, unsigned int flags)
33 struct ib_request *ibreq = calloc (1, sizeof (struct ib_request));
34 nis_attr *search_val = NULL;
35 size_t search_len = 0;
36 size_t size = 0;
38 if (ibreq == NULL)
39 return NULL;
41 ibreq->ibr_flags = flags;
43 char *cptr = strdupa (name);
45 /* Not of "[key=value,key=value,...],foo.." format? */
46 if (cptr[0] != '[')
48 ibreq->ibr_name = strdup (cptr);
49 if (ibreq->ibr_name == NULL)
51 free (ibreq);
52 return NULL;
54 return ibreq;
57 /* "[key=value,...],foo" format */
58 ibreq->ibr_name = strchr (cptr, ']');
59 if (ibreq->ibr_name == NULL || ibreq->ibr_name[1] != ',')
61 /* The object has not really been built yet so we use free. */
62 free (ibreq);
63 return NULL;
66 /* Check if we have an entry of "[key=value,],bar". If, remove the "," */
67 if (ibreq->ibr_name[-1] == ',')
68 ibreq->ibr_name[-1] = '\0';
69 else
70 ibreq->ibr_name[0] = '\0';
71 ibreq->ibr_name += 2;
72 ibreq->ibr_name = strdup (ibreq->ibr_name);
73 if (ibreq->ibr_name == NULL)
75 free_null:
76 while (search_len-- > 0)
78 free (search_val[search_len].zattr_ndx);
79 free (search_val[search_len].zattr_val.zattr_val_val);
81 free (search_val);
82 nis_free_request (ibreq);
83 return NULL;
86 ++cptr; /* Remove "[" */
88 while (cptr != NULL && cptr[0] != '\0')
90 char *key = cptr;
91 char *val = strchr (cptr, '=');
93 cptr = strchr (key, ',');
94 if (cptr != NULL)
95 *cptr++ = '\0';
97 if (__glibc_unlikely (val == NULL))
99 nis_free_request (ibreq);
100 return NULL;
102 *val++ = '\0';
103 if (search_len + 1 >= size)
105 size += 1;
106 nis_attr *newp = realloc (search_val, size * sizeof (nis_attr));
107 if (newp == NULL)
108 goto free_null;
109 search_val = newp;
111 search_val[search_len].zattr_ndx = strdup (key);
112 if (search_val[search_len].zattr_ndx == NULL)
113 goto free_null;
115 search_val[search_len].zattr_val.zattr_val_len = strlen (val) + 1;
116 search_val[search_len].zattr_val.zattr_val_val = strdup (val);
117 if (search_val[search_len].zattr_val.zattr_val_val == NULL)
119 free (search_val[search_len].zattr_ndx);
120 goto free_null;
123 ++search_len;
126 ibreq->ibr_srch.ibr_srch_val = search_val;
127 ibreq->ibr_srch.ibr_srch_len = search_len;
129 return ibreq;
131 libnsl_hidden_nolink_def (__create_ib_request, GLIBC_PRIVATE)
133 static const struct timeval RPCTIMEOUT = {10, 0};
135 static char *
136 get_tablepath (char *name, dir_binding *bptr)
138 enum clnt_stat result;
139 nis_result res;
140 struct ns_request req;
142 memset (&res, '\0', sizeof (res));
144 req.ns_name = name;
145 req.ns_object.ns_object_len = 0;
146 req.ns_object.ns_object_val = NULL;
148 result = clnt_call (bptr->clnt, NIS_LOOKUP, (xdrproc_t) _xdr_ns_request,
149 (caddr_t) &req, (xdrproc_t) _xdr_nis_result,
150 (caddr_t) &res, RPCTIMEOUT);
152 const char *cptr;
153 if (result == RPC_SUCCESS && NIS_RES_STATUS (&res) == NIS_SUCCESS
154 && __type_of (NIS_RES_OBJECT (&res)) == NIS_TABLE_OBJ)
155 cptr = NIS_RES_OBJECT (&res)->TA_data.ta_path;
156 else
157 cptr = "";
159 char *str = strdup (cptr);
161 if (result == RPC_SUCCESS)
162 xdr_free ((xdrproc_t) _xdr_nis_result, (char *) &res);
164 return str;
168 nis_error
169 __follow_path (char **tablepath, char **tableptr, struct ib_request *ibreq,
170 dir_binding *bptr)
172 if (*tablepath == NULL)
174 *tablepath = get_tablepath (ibreq->ibr_name, bptr);
175 if (*tablepath == NULL)
176 return NIS_NOMEMORY;
178 *tableptr = *tablepath;
181 /* Since tableptr is only set here, and it's set when tablepath is NULL,
182 which it is initially defined as, we know it will always be set here. */
183 DIAG_PUSH_NEEDS_COMMENT;
184 DIAG_IGNORE_NEEDS_COMMENT (4.7, "-Wmaybe-uninitialized");
186 if (*tableptr == NULL)
187 return NIS_NOTFOUND;
189 char *newname = strsep (tableptr, ":");
190 if (newname[0] == '\0')
191 return NIS_NOTFOUND;
193 DIAG_POP_NEEDS_COMMENT;
195 newname = strdup (newname);
196 if (newname == NULL)
197 return NIS_NOMEMORY;
199 free (ibreq->ibr_name);
200 ibreq->ibr_name = newname;
202 return NIS_SUCCESS;
204 libnsl_hidden_nolink_def (__follow_path, GLIBC_PRIVATE)
207 nis_result *
208 nis_list (const_nis_name name, unsigned int flags,
209 int (*callback) (const_nis_name name,
210 const nis_object *object,
211 const void *userdata),
212 const void *userdata)
214 nis_result *res = malloc (sizeof (nis_result));
215 ib_request *ibreq;
216 int status;
217 enum clnt_stat clnt_status;
218 int count_links = 0; /* We will only follow NIS_MAXLINKS links! */
219 int done = 0;
220 nis_name *names;
221 nis_name namebuf[2] = {NULL, NULL};
222 int name_nr = 0;
223 nis_cb *cb = NULL;
224 char *tableptr;
225 char *tablepath = NULL;
226 int first_try = 0; /* Do we try the old binding at first ? */
227 nis_result *allres = NULL;
229 if (res == NULL)
230 return NULL;
232 if (name == NULL)
234 status = NIS_BADNAME;
235 err_out:
236 nis_freeresult (allres);
237 memset (res, '\0', sizeof (nis_result));
238 NIS_RES_STATUS (res) = status;
239 return res;
242 ibreq = __create_ib_request (name, flags);
243 if (ibreq == NULL)
245 status = NIS_BADNAME;
246 goto err_out;
249 if ((flags & EXPAND_NAME)
250 && ibreq->ibr_name[strlen (ibreq->ibr_name) - 1] != '.')
252 names = nis_getnames (ibreq->ibr_name);
253 free (ibreq->ibr_name);
254 ibreq->ibr_name = NULL;
255 if (names == NULL)
257 nis_free_request (ibreq);
258 status = NIS_BADNAME;
259 goto err_out;
261 ibreq->ibr_name = strdup (names[name_nr]);
262 if (ibreq->ibr_name == NULL)
264 nis_freenames (names);
265 nis_free_request (ibreq);
266 status = NIS_NOMEMORY;
267 goto err_out;
270 else
272 names = namebuf;
273 names[name_nr] = ibreq->ibr_name;
276 cb = NULL;
278 while (!done)
280 dir_binding bptr;
281 directory_obj *dir = NULL;
283 memset (res, '\0', sizeof (nis_result));
285 status = __nisfind_server (ibreq->ibr_name,
286 ibreq->ibr_srch.ibr_srch_val != NULL,
287 &dir, &bptr, flags & ~MASTER_ONLY);
288 if (status != NIS_SUCCESS)
290 NIS_RES_STATUS (res) = status;
291 goto fail3;
294 while (__nisbind_connect (&bptr) != NIS_SUCCESS)
295 if (__glibc_unlikely (__nisbind_next (&bptr) != NIS_SUCCESS))
297 NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE;
298 goto fail;
301 if (callback != NULL)
303 assert (cb == NULL);
304 cb = __nis_create_callback (callback, userdata, flags);
305 ibreq->ibr_cbhost.ibr_cbhost_len = 1;
306 ibreq->ibr_cbhost.ibr_cbhost_val = cb->serv;
309 again:
310 clnt_status = clnt_call (bptr.clnt, NIS_IBLIST,
311 (xdrproc_t) _xdr_ib_request, (caddr_t) ibreq,
312 (xdrproc_t) _xdr_nis_result,
313 (caddr_t) res, RPCTIMEOUT);
315 if (__glibc_unlikely (clnt_status != RPC_SUCCESS))
316 NIS_RES_STATUS (res) = NIS_RPCERROR;
317 else
318 switch (NIS_RES_STATUS (res))
319 { /* start switch */
320 case NIS_PARTIAL:
321 case NIS_SUCCESS:
322 case NIS_S_SUCCESS:
323 if (__type_of (NIS_RES_OBJECT (res)) == NIS_LINK_OBJ
324 && (flags & FOLLOW_LINKS)) /* We are following links. */
326 free (ibreq->ibr_name);
327 ibreq->ibr_name = NULL;
328 /* If we hit the link limit, bail. */
329 if (__glibc_unlikely (count_links > NIS_MAXLINKS))
331 NIS_RES_STATUS (res) = NIS_LINKNAMEERROR;
332 ++done;
333 break;
335 ++count_links;
336 ibreq->ibr_name =
337 strdup (NIS_RES_OBJECT (res)->LI_data.li_name);
338 if (ibreq->ibr_name == NULL)
340 NIS_RES_STATUS (res) = NIS_NOMEMORY;
341 fail:
342 __nisbind_destroy (&bptr);
343 nis_free_directory (dir);
344 fail3:
345 free (tablepath);
346 if (cb)
348 __nis_destroy_callback (cb);
349 ibreq->ibr_cbhost.ibr_cbhost_len = 0;
350 ibreq->ibr_cbhost.ibr_cbhost_val = NULL;
352 if (names != namebuf)
353 nis_freenames (names);
354 nis_free_request (ibreq);
355 nis_freeresult (allres);
356 return res;
358 if (NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len)
359 if (ibreq->ibr_srch.ibr_srch_len == 0)
361 ibreq->ibr_srch.ibr_srch_len =
362 NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len;
363 ibreq->ibr_srch.ibr_srch_val =
364 NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_val;
366 /* The following is a non-obvious optimization. A
367 nis_freeresult call would call xdr_free as the
368 following code. But it also would unnecessarily
369 free the result structure. We avoid this here
370 along with the necessary tests. */
371 xdr_free ((xdrproc_t) _xdr_nis_result, (char *)res);
372 memset (res, '\0', sizeof (*res));
373 first_try = 1; /* Try at first the old binding */
374 goto again;
376 else if ((flags & FOLLOW_PATH)
377 && NIS_RES_STATUS (res) == NIS_PARTIAL)
379 enum nis_error err = __follow_path (&tablepath, &tableptr,
380 ibreq, &bptr);
381 if (err != NIS_SUCCESS)
383 if (err == NIS_NOMEMORY)
384 NIS_RES_STATUS (res) = err;
385 ++done;
387 else
389 /* The following is a non-obvious optimization. A
390 nis_freeresult call would call xdr_free as the
391 following code. But it also would unnecessarily
392 free the result structure. We avoid this here
393 along with the necessary tests. */
394 xdr_free ((xdrproc_t) _xdr_nis_result, (char *) res);
395 memset (res, '\0', sizeof (*res));
396 first_try = 1;
397 goto again;
400 else if ((flags & (FOLLOW_PATH | ALL_RESULTS))
401 == (FOLLOW_PATH | ALL_RESULTS))
403 if (allres == NULL)
405 allres = res;
406 res = malloc (sizeof (nis_result));
407 if (res == NULL)
409 res = allres;
410 allres = NULL;
411 NIS_RES_STATUS (res) = NIS_NOMEMORY;
412 goto fail;
414 NIS_RES_STATUS (res) = NIS_RES_STATUS (allres);
416 else
418 nis_object *objects_val
419 = realloc (NIS_RES_OBJECT (allres),
420 (NIS_RES_NUMOBJ (allres)
421 + NIS_RES_NUMOBJ (res))
422 * sizeof (nis_object));
423 if (objects_val == NULL)
425 NIS_RES_STATUS (res) = NIS_NOMEMORY;
426 goto fail;
428 NIS_RES_OBJECT (allres) = objects_val;
429 memcpy (NIS_RES_OBJECT (allres) + NIS_RES_NUMOBJ (allres),
430 NIS_RES_OBJECT (res),
431 NIS_RES_NUMOBJ (res) * sizeof (nis_object));
432 NIS_RES_NUMOBJ (allres) += NIS_RES_NUMOBJ (res);
433 NIS_RES_NUMOBJ (res) = 0;
434 free (NIS_RES_OBJECT (res));
435 NIS_RES_OBJECT (res) = NULL;
436 NIS_RES_STATUS (allres) = NIS_RES_STATUS (res);
437 xdr_free ((xdrproc_t) _xdr_nis_result, (char *) res);
439 enum nis_error err = __follow_path (&tablepath, &tableptr,
440 ibreq, &bptr);
441 if (err != NIS_SUCCESS)
443 /* Prepare for the nis_freeresult call. */
444 memset (res, '\0', sizeof (*res));
446 if (err == NIS_NOMEMORY)
447 NIS_RES_STATUS (allres) = err;
448 ++done;
451 else
452 ++done;
453 break;
454 case NIS_CBRESULTS:
455 if (cb != NULL)
457 __nis_do_callback (&bptr, &res->cookie, cb);
458 NIS_RES_STATUS (res) = cb->result;
460 if (!(flags & ALL_RESULTS))
461 ++done;
462 else
464 enum nis_error err
465 = __follow_path (&tablepath, &tableptr, ibreq, &bptr);
466 if (err != NIS_SUCCESS)
468 if (err == NIS_NOMEMORY)
469 NIS_RES_STATUS (res) = err;
470 ++done;
474 break;
475 case NIS_SYSTEMERROR:
476 case NIS_NOSUCHNAME:
477 case NIS_NOT_ME:
478 /* If we had first tried the old binding, do nothing, but
479 get a new binding */
480 if (!first_try)
482 if (__nisbind_next (&bptr) != NIS_SUCCESS)
484 ++done;
485 break; /* No more servers to search */
487 while (__nisbind_connect (&bptr) != NIS_SUCCESS)
489 if (__nisbind_next (&bptr) != NIS_SUCCESS)
491 ++done;
492 break; /* No more servers to search */
495 goto again;
497 break;
498 default:
499 if (!first_try)
501 /* Try the next domainname if we don't follow a link. */
502 free (ibreq->ibr_name);
503 ibreq->ibr_name = NULL;
504 if (__glibc_unlikely (count_links))
506 NIS_RES_STATUS (res) = NIS_LINKNAMEERROR;
507 ++done;
508 break;
510 ++name_nr;
511 if (names[name_nr] == NULL)
513 ++done;
514 break;
516 ibreq->ibr_name = strdup (names[name_nr]);
517 if (ibreq->ibr_name == NULL)
519 NIS_RES_STATUS (res) = NIS_NOMEMORY;
520 goto fail;
522 first_try = 1; /* Try old binding at first */
523 goto again;
525 break;
527 first_try = 0;
529 if (cb)
531 __nis_destroy_callback (cb);
532 ibreq->ibr_cbhost.ibr_cbhost_len = 0;
533 ibreq->ibr_cbhost.ibr_cbhost_val = NULL;
534 cb = NULL;
537 __nisbind_destroy (&bptr);
538 nis_free_directory (dir);
541 free (tablepath);
543 if (names != namebuf)
544 nis_freenames (names);
546 nis_free_request (ibreq);
548 if (allres)
550 nis_freeresult (res);
551 return allres;
554 return res;
556 libnsl_hidden_nolink_def (nis_list, GLIBC_2_1)
558 nis_result *
559 nis_add_entry (const_nis_name name, const nis_object *obj2, unsigned int flags)
561 nis_result *res = calloc (1, sizeof (nis_result));
562 if (res == NULL)
563 return NULL;
565 if (name == NULL)
567 NIS_RES_STATUS (res) = NIS_BADNAME;
568 return res;
571 ib_request *ibreq = __create_ib_request (name, flags);
572 if (ibreq == NULL)
574 NIS_RES_STATUS (res) = NIS_BADNAME;
575 return res;
578 nis_object obj;
579 memcpy (&obj, obj2, sizeof (nis_object));
581 size_t namelen = strlen (name);
582 char buf1[namelen + 20];
583 char buf4[namelen + 20];
585 if (obj.zo_name == NULL || strlen (obj.zo_name) == 0)
586 obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1));
588 if (obj.zo_owner == NULL || strlen (obj.zo_owner) == 0)
589 obj.zo_owner = nis_local_principal ();
591 if (obj.zo_group == NULL || strlen (obj.zo_group) == 0)
592 obj.zo_group = nis_local_group ();
594 obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4));
596 ibreq->ibr_obj.ibr_obj_val = nis_clone_object (&obj, NULL);
597 if (ibreq->ibr_obj.ibr_obj_val == NULL)
599 nis_free_request (ibreq);
600 NIS_RES_STATUS (res) = NIS_NOMEMORY;
601 return res;
603 ibreq->ibr_obj.ibr_obj_len = 1;
605 nis_error status = __do_niscall (ibreq->ibr_name, NIS_IBADD,
606 (xdrproc_t) _xdr_ib_request,
607 (caddr_t) ibreq,
608 (xdrproc_t) _xdr_nis_result,
609 (caddr_t) res, 0, NULL);
610 if (__glibc_unlikely (status != NIS_SUCCESS))
611 NIS_RES_STATUS (res) = status;
613 nis_free_request (ibreq);
615 return res;
617 libnsl_hidden_nolink_def (nis_add_entry, GLIBC_2_1)
619 nis_result *
620 nis_modify_entry (const_nis_name name, const nis_object *obj2,
621 unsigned int flags)
623 nis_object obj;
624 nis_result *res;
625 nis_error status;
626 ib_request *ibreq;
627 size_t namelen = strlen (name);
628 char buf1[namelen + 20];
629 char buf4[namelen + 20];
631 res = calloc (1, sizeof (nis_result));
632 if (res == NULL)
633 return NULL;
635 ibreq = __create_ib_request (name, flags);
636 if (ibreq == NULL)
638 NIS_RES_STATUS (res) = NIS_BADNAME;
639 return res;
642 memcpy (&obj, obj2, sizeof (nis_object));
644 if (obj.zo_name == NULL || strlen (obj.zo_name) == 0)
645 obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1));
647 if (obj.zo_owner == NULL || strlen (obj.zo_owner) == 0)
648 obj.zo_owner = nis_local_principal ();
650 if (obj.zo_group == NULL || strlen (obj.zo_group) == 0)
651 obj.zo_group = nis_local_group ();
653 obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4));
655 ibreq->ibr_obj.ibr_obj_val = nis_clone_object (&obj, NULL);
656 if (ibreq->ibr_obj.ibr_obj_val == NULL)
658 nis_free_request (ibreq);
659 NIS_RES_STATUS (res) = NIS_NOMEMORY;
660 return res;
662 ibreq->ibr_obj.ibr_obj_len = 1;
664 status = __do_niscall (ibreq->ibr_name, NIS_IBMODIFY,
665 (xdrproc_t) _xdr_ib_request,
666 (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
667 (caddr_t) res, 0, NULL);
668 if (__glibc_unlikely (status != NIS_SUCCESS))
669 NIS_RES_STATUS (res) = status;
671 nis_free_request (ibreq);
673 return res;
675 libnsl_hidden_nolink_def (nis_modify_entry, GLIBC_2_1)
677 nis_result *
678 nis_remove_entry (const_nis_name name, const nis_object *obj,
679 unsigned int flags)
681 nis_result *res;
682 ib_request *ibreq;
683 nis_error status;
685 res = calloc (1, sizeof (nis_result));
686 if (res == NULL)
687 return NULL;
689 if (name == NULL)
691 NIS_RES_STATUS (res) = NIS_BADNAME;
692 return res;
695 ibreq = __create_ib_request (name, flags);
696 if (ibreq == NULL)
698 NIS_RES_STATUS (res) = NIS_BADNAME;
699 return res;
702 if (obj != NULL)
704 ibreq->ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
705 if (ibreq->ibr_obj.ibr_obj_val == NULL)
707 nis_free_request (ibreq);
708 NIS_RES_STATUS (res) = NIS_NOMEMORY;
709 return res;
711 ibreq->ibr_obj.ibr_obj_len = 1;
714 if ((status = __do_niscall (ibreq->ibr_name, NIS_IBREMOVE,
715 (xdrproc_t) _xdr_ib_request,
716 (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
717 (caddr_t) res, 0, NULL)) != NIS_SUCCESS)
718 NIS_RES_STATUS (res) = status;
720 nis_free_request (ibreq);
722 return res;
724 libnsl_hidden_nolink_def (nis_remove_entry, GLIBC_2_1)
726 nis_result *
727 nis_first_entry (const_nis_name name)
729 nis_result *res;
730 ib_request *ibreq;
731 nis_error status;
733 res = calloc (1, sizeof (nis_result));
734 if (res == NULL)
735 return NULL;
737 if (name == NULL)
739 NIS_RES_STATUS (res) = NIS_BADNAME;
740 return res;
743 ibreq = __create_ib_request (name, 0);
744 if (ibreq == NULL)
746 NIS_RES_STATUS (res) = NIS_BADNAME;
747 return res;
750 status = __do_niscall (ibreq->ibr_name, NIS_IBFIRST,
751 (xdrproc_t) _xdr_ib_request,
752 (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
753 (caddr_t) res, 0, NULL);
755 if (__glibc_unlikely (status != NIS_SUCCESS))
756 NIS_RES_STATUS (res) = status;
758 nis_free_request (ibreq);
760 return res;
762 libnsl_hidden_nolink_def (nis_first_entry, GLIBC_2_1)
764 nis_result *
765 nis_next_entry (const_nis_name name, const netobj *cookie)
767 nis_result *res;
768 ib_request *ibreq;
769 nis_error status;
771 res = calloc (1, sizeof (nis_result));
772 if (res == NULL)
773 return NULL;
775 if (name == NULL)
777 NIS_RES_STATUS (res) = NIS_BADNAME;
778 return res;
781 ibreq = __create_ib_request (name, 0);
782 if (ibreq == NULL)
784 NIS_RES_STATUS (res) = NIS_BADNAME;
785 return res;
788 if (cookie != NULL)
790 ibreq->ibr_cookie.n_bytes = cookie->n_bytes;
791 ibreq->ibr_cookie.n_len = cookie->n_len;
794 status = __do_niscall (ibreq->ibr_name, NIS_IBNEXT,
795 (xdrproc_t) _xdr_ib_request,
796 (caddr_t) ibreq, (xdrproc_t) _xdr_nis_result,
797 (caddr_t) res, 0, NULL);
799 if (__glibc_unlikely (status != NIS_SUCCESS))
800 NIS_RES_STATUS (res) = status;
802 if (cookie != NULL)
804 /* Don't give cookie free, it is not from us */
805 ibreq->ibr_cookie.n_bytes = NULL;
806 ibreq->ibr_cookie.n_len = 0;
809 nis_free_request (ibreq);
811 return res;
813 libnsl_hidden_nolink_def (nis_next_entry, GLIBC_2_1)