summaryrefslogtreecommitdiff
path: root/nis/nis_call.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-05-20 19:22:30 +0000
committerUlrich Drepper <drepper@redhat.com>2006-05-20 19:22:30 +0000
commita17fa6100dd400cd0c64aab1803c2047c95bfd5b (patch)
tree3f1c005d18d338defaeaa489fd34c2c6e4fd7690 /nis/nis_call.c
parent1d4f062ab84f24cab893a9211e3e72b2f1f470ce (diff)
downloadglibc-a17fa6100dd400cd0c64aab1803c2047c95bfd5b.tar.gz
* nis/nis_call.c (__prepare_niscall): New function. Split outcvs/fedora-glibc-20060521T2153
from __do_niscall. * nis/nis_table.c (__create_ib_request): Renamed from create_ib_request and exported. (__follow_path): New function. Split out from nis_list. * nis/nis_xdr.h: Add libnsl_hidden_proto for _xdr_ib_request and _xdr_nis_result. * nis/nis_xdr.c: Add libnsl_hidden_def for _xdr_ib_request and _xdr_nis_result. * nis/libnsl.h: Declare __prepare_niscall, __create_ib_request, and __follow_path. * nis/Versions: Export __prepare_niscall, __create_ib_request, __follow_path, __do_niscall3, _xdr_ib_request, and _xdr_nis_result from libnsl for version GLIBC_PRIVATE. * nis/nisplus-parser.h: Remove _nss_nisplus_parse_pwent_chk. Remove entry parameter from _nss_nisplus_parse_pwent and _nss_nisplus_parse_grent. * nis/nss_nisplus/nisplus-parser.c: Likewise. * nis/nss_nisplus/nisplus-pwd.c: Remove support for SETENT_BATCH_READ again. Rewrite getpwent handling to not use nis_first_entry and nis_next_entry. Roll out own niscall handling. * nis/nss_nisplus/nisplus-grp.c: Likewise. * sunrpc/xdr_rec.c: Fix typo in comment. 2006-05-18 David Woodhouse <dwmw2@redhat.com>
Diffstat (limited to 'nis/nis_call.c')
-rw-r--r--nis/nis_call.c68
1 files changed, 43 insertions, 25 deletions
diff --git a/nis/nis_call.c b/nis/nis_call.c
index 499d042e3c..bd6bcc50ab 100644
--- a/nis/nis_call.c
+++ b/nis/nis_call.c
@@ -531,50 +531,68 @@ __nisfind_server (const_nis_name name, directory_obj **dir)
return result;
}
+
nis_error
-__do_niscall (const_nis_name name, u_long prog, xdrproc_t xargs,
- caddr_t req, xdrproc_t xres, caddr_t resp, unsigned int flags,
- nis_cb *cb)
+__prepare_niscall (const_nis_name name, directory_obj **dirp,
+ dir_binding *bptrp, unsigned int flags)
{
- nis_error retcode;
- dir_binding bptr;
- directory_obj *dir = NULL;
+ nis_error retcode = __nisfind_server (name, dirp);
+ if (__builtin_expect (retcode != NIS_SUCCESS, 0))
+ return retcode;
+
nis_server *server;
u_int server_len;
- int saved_errno = errno;
-
- retcode = __nisfind_server (name, &dir);
- if (retcode != NIS_SUCCESS)
- return retcode;
if (flags & MASTER_ONLY)
{
- server = dir->do_servers.do_servers_val;
+ server = (*dirp)->do_servers.do_servers_val;
server_len = 1;
}
else
{
- server = dir->do_servers.do_servers_val;
- server_len = dir->do_servers.do_servers_len;
+ server = (*dirp)->do_servers.do_servers_val;
+ server_len = (*dirp)->do_servers.do_servers_len;
}
- retcode = __nisbind_create (&bptr, server, server_len, flags);
+ retcode = __nisbind_create (bptrp, server, server_len, flags);
+ if (retcode == NIS_SUCCESS)
+ {
+ do
+ if (__nisbind_connect (bptrp) == NIS_SUCCESS)
+ return NIS_SUCCESS;
+ while (__nisbind_next (bptrp) == NIS_SUCCESS);
+
+ __nisbind_destroy (bptrp);
+ memset (bptrp, '\0', sizeof (*bptrp));
+
+ retcode = NIS_NAMEUNREACHABLE;
+ }
+
+ nis_free_directory (*dirp);
+ *dirp = NULL;
+
+ return retcode;
+}
+
+
+nis_error
+__do_niscall (const_nis_name name, u_long prog, xdrproc_t xargs,
+ caddr_t req, xdrproc_t xres, caddr_t resp, unsigned int flags,
+ nis_cb *cb)
+{
+ dir_binding bptr;
+ directory_obj *dir = NULL;
+ int saved_errno = errno;
+
+ nis_error retcode = __prepare_niscall (name, &dir, &bptr, flags);
if (retcode == NIS_SUCCESS)
{
- while (__nisbind_connect (&bptr) != NIS_SUCCESS)
- {
- if (__nisbind_next (&bptr) != NIS_SUCCESS)
- {
- nis_free_directory (dir);
- return NIS_NAMEUNREACHABLE;
- }
- }
retcode = __do_niscall3 (&bptr, prog, xargs, req, xres, resp, flags, cb);
__nisbind_destroy (&bptr);
- }
- nis_free_directory (dir);
+ nis_free_directory (dir);
+ }
__set_errno (saved_errno);