about summary refs log tree commit diff
path: root/nis/nss_nis
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-12-08 03:06:47 +0000
committerUlrich Drepper <drepper@redhat.com>1997-12-08 03:06:47 +0000
commitd71b808a96f0fd1b6cd82c41698b518bf345692b (patch)
tree7b86cfd6b465c72888d7e85a61c08cafabf5747b /nis/nss_nis
parent6195235142bd246d972cf1d88b4e208071a3e318 (diff)
downloadglibc-d71b808a96f0fd1b6cd82c41698b518bf345692b.tar.gz
glibc-d71b808a96f0fd1b6cd82c41698b518bf345692b.tar.xz
glibc-d71b808a96f0fd1b6cd82c41698b518bf345692b.zip
1997-12-08 03:24  Ulrich Drepper  <drepper@cygnus.com>

	* Makeconfig: Define $(rt) to rt if linuxthreads is available.
	* Makefile (subdirs): Replace rt by $(rt).

	* shlib-versions: Use version .2 for NSS modules.

	* grp/fgetgrent_r.c (LINE_PARSER): Call parse_line with extra
	argument.
	* pwd/fgetpwent_r.c: Likewise.
	* spwd/fgetspent_r.c: Likewise.
	* spwd/sgetspent_r.c: Likewise.
	* hesiod/nss_hesiod/hesiod-grp.c (lookup): Add new argument.
	Store error number in *ERRNOP.  Little optimization.
	* hesiod/nss_hesiod/hesiod-pwd.c: Likewise.
	* hesiod/nss_hesiod/hesiod-service.c: Likewise.
	* inet/getnetgrent_r.c (__internal_setnetgrent_reuse): Likewise.
	(__internal_getnetgrent_r): New argument.
	Call __internal_setnetgrent_reuse with new argument.
	(__getnetgrent_r): Call __internal_getnetgrent_r with new argument.
	* inet/netgroup.h: Add argument to prototypes.
	* nis/nisplus-parser.h: Likewise.
	* nis/nss_compat/compat-grp.c: Change everything to store error
	code through provided pointer and not use errno.
	* nis/nss_compat/compat-pwd.c: Likewise.
	* nis/nss_compat/compat-spwd.c: Likewise.
	* nis/nss_nis/nis-alias.c: Likewise.
	* nis/nss_nis/nis-ethers.c: Likewise.
	* nis/nss_nis/nis-grp.c: Likewise.
	* nis/nss_nis/nis-hosts.c: Likewise.
	* nis/nss_nis/nis-netgrp.c: Likewise.
	* nis/nss_nis/nis-network.c: Likewise.
	* nis/nss_nis/nis-proto.c: Likewise.
	* nis/nss_nis/nis-publickey.c: Likewise.
	* nis/nss_nis/nis-pwd.c: Likewise.
	* nis/nss_nis/nis-rpc.c: Likewise.
	* nis/nss_nis/nis-service.c: Likewise.
	* nis/nss_nis/nis-spwd.c: Likewise.
	* nis/nss_nisplus/nisplus-alias.c: Likewise.
	* nis/nss_nisplus/nisplus-ethers.c: Likewise.
	* nis/nss_nisplus/nisplus-grp.c: Likewise.
	* nis/nss_nisplus/nisplus-hosts.c: Likewise.
	* nis/nss_nisplus/nisplus-netgrp.c: Likewise.
	* nis/nss_nisplus/nisplus-network.c: Likewise.
	* nis/nss_nisplus/nisplus-parser.c: Likewise.
	* nis/nss_nisplus/nisplus-proto.c: Likewise.
	* nis/nss_nisplus/nisplus-publickey.c: Likewise.
	* nis/nss_nisplus/nisplus-pwd.c: Likewise.
	* nis/nss_nisplus/nisplus-rpc.c: Likewise.
	* nis/nss_nisplus/nisplus-service.c: Likewise.
	* nis/nss_nisplus/nisplus-spwd.c: Likewise.
	* nss/nss_db/db-XXX.c: Likewise.
	* nss/nss_db/db-alias.c: Likewise.
	* nss/nss_db/db-netgrp.c: Likewise.
	* nss/nss_files/files-XXX.c: Likewise
	* nss/nss_files/files-alias.c: Likewise
	* nss/nss_files/files-netgrp.c: Likewise
	* nss/nss_files/files-parse.c: Likewise
	* nss/getXXbyYY_r.c: Call with __errno_location() as value for new
	parameter of get functions.
	* nss/getXXent_r.c: Likewise.

	* localedata/tst-fmon.c: Print debug info if test fails.

	* rt/Makefile (routines): Add aio_notify.
	* rt/aio.h: Remove non-public definitions.  Add aioinit stuff.
	* rt/aio_cancel.c: Rewrite to support lio_listio and aio_suspend.
	* rt/aio_fsync.c: Likewise.
	* rt/aio_misc.c: Likewise.
	* rt/aio_misc.h: Likewise.
	* rt/aio_read.c: Likewise.
	* rt/aio_read64.c: Likewise.
	* rt/aio_suspend.c: Likewise.
	* rt/aio_write.c: Likewise.
	* rt/aio_write64.c: Likewise.
	* rt/lio_listio.c: Likewise.
	* rt/lio_listio64.c: Likewise.
	* rt/aio_notify.c: New file.

	* sysdeps/generic/bits/sigset.h: Pretty print.

	* sysdeps/posix/pwrite.c: Define weak alias only if function is
	really defined as __pwrite.

	* sysdeps/unix/sysv/linux/pread.c: Rewrite to use syscall directly
	instead of pread64.
	* sysdeps/unix/sysv/linux/pwrite.c: Likewise.

	* sysdeps/unix/sysv/linux/Makefile [$(subdir)=signal]
	(sysdep_routines): Add rt_sigpending and rt_sigreturn.
	* sysdeps/unix/sysv/linux/sigaction.c: Use correct value for sigset_t
	size in syscall.
	* sysdeps/unix/sysv/linux/sigpending.c: Likewise.
	* sysdeps/unix/sysv/linux/sigprocmask.c: Likewise.
	* sysdeps/unix/sysv/linux/sigreturn.c: Likewise.
	* sysdeps/unix/sysv/linux/sigsuspend.c: Likewise.
	* sysdeps/unix/sysv/linux/sigtimedwait.c: Likewise.
	* sysdeps/unix/sysv/linux/sigwaitinfo.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/sigaction.c: Likewise.  Take care
	for ACT being NULL.
	* sysdeps/unix/sysv/linux/syscalls.list: Don't mention user for
	RT signals.
	* sysdeps/unix/sysv/linux/i386/s_pread64.s: Return ENOSYS if
	__NR_pread is not defined.
	* sysdeps/unix/sysv/linux/i386/s_pwrite64.s: Return ENOSYS if
	__NR_pwrite is not defined.

1997-12-07 11:15  Thorsten Kukuk  <kukuk@vt.uni-paderborn.de>

	* nis/nss_compat/compat-grp.c: If buffer is to small, set the file
	handle for /etc/group back in some more cases.
	* nis/nss_compat/compat-pwd.c: If buffer is to small, set the file
	handle for /etc/passwd back in some more cases.
	* nis/nss_compat/compat-spwd.c: If buffer is to small, set the file
	handle for /etc/shadow back in some more cases.

1997-12-06 17:00  H.J. Lu  <hjl@gnu.org>

	* sysdeps/posix/sigblock.c (__sigblock): Don't check int mask
	beyound its size.
	* sysdeps/posix/sigsetmask.c (__sigsetmask): Ditto.
	* sysdeps/posix/sigvec.c (convert_mask, __sigvec): Ditto.

1997-12-06 04:38  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/wordsize-32/inttypes.h: Rewrite {str,wcs}to{i,u}max
	handling.  Don't use macros, we need functions.  Use inline functions
	for optimization.
	* sysdeps/wordsize-64/inttypes.h: Likewise.
	* sysdeps/wordsize-32/Makefile: Add strtoimax, stroumax, wcstoimax,
	and wcstoumax.
	* sysdeps/wordsize-64/Makefile: Likewise.
	* sysdeps/wordsize-32/Dist: Likewise.
	* sysdeps/wordsize-64/Dist: Likewise.
	* sysdeps/wordsize-32/strtoimax.c: New file.
	* sysdeps/wordsize-32/strtoumax.c: New file.
	* sysdeps/wordsize-32/wcstoimax.c: New file.
	* sysdeps/wordsize-32/wcstoumax.c: New file.
	* sysdeps/wordsize-64/strtoimax.c: New file.
	* sysdeps/wordsize-64/strtoumax.c: New file.
	* sysdeps/wordsize-64/wcstoimax.c: New file.
	* sysdeps/wordsize-64/wcstoumax.c: New file.

1997-12-04 10:40  Philip Blundell  <pb@nexus.co.uk>

	* sysdeps/generic/wait3.c (__wait3): Use ANSI-style definition so
	that transparent union works.
	* sysdeps/generic/wait4.c (__wait4): Likewise.
	* sysdeps/generic/wait.c (__wait): Likewise.

	* sysdeps/generic/getpeername.c (getpeername): Use socklen_t not
	size_t.

	* sysdeps/generic/syscall.c (syscall): Return value and arg are
	long, to match prototype.

	* malloc/malloc.c (HAVE_MREMAP): Set to 0 for ARM, as we don't
	have mremap() yet.

	* sysdeps/generic/usleep.c (usleep): Returns void, to match prototype.

	* sysdeps/unix/sysv/linux/arm/syscalls.list: New file.

	* sysdeps/generic/bits/time.h: Use __time_t not time_t.

	* sysdeps/generic/bits/resource.h: Include <bits/types.h> for
	__rlim_t.

	* sysdeps/standalone/arm/bits/errno.h (ENOTTY): Added.

	* sysdeps/generic/bits/dirent.h (struct dirent64): Added.

	* io/sys/stat.h (S_ISLNK): Always false if we don't have
	__S_IFLNK.

	* sysdeps/standalone/close.c (_STDIO_H): Define before including
	<bits/stdio_lim.h>.
	* sysdeps/standalone/filedesc.h (_STDIO_H): Likewise.

1997-12-06 01:09  Ulrich Drepper  <drepper@cygnus.com>

	* posix/sys/wait.h: Don't use transparent unions in C++.

1997-12-05  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* time/time.h: Add strfxtime.

	* libc.map: Add tcgetsid, strcasestr, wmemrtombs, wmemrtowcs,
	sysv_signal, strfxtime, pread64, pwrite64.

1997-11-30 21:57  Richard Henderson  <rth@cygnus.com>

	Alpha changes for EGCS:
	* config.h.in (ASM_ALPHA_NG_SYMBOL_PREFIX): New entry.
	* configure.in (libc_cv_gcc_alpha_ng_prefix): New check.
	* sysdeps/alpha/dl-machine.h (_dl_runtime_resolve): Care for prefix.
	(_start): Likewise.
	* sysdeps/unix/sysv/linux/alpha/init-first.h: Likewise.
Diffstat (limited to 'nis/nss_nis')
-rw-r--r--nis/nss_nis/nis-alias.c36
-rw-r--r--nis/nss_nis/nis-ethers.c31
-rw-r--r--nis/nss_nis/nis-grp.c34
-rw-r--r--nis/nss_nis/nis-hosts.c46
-rw-r--r--nis/nss_nis/nis-netgrp.c7
-rw-r--r--nis/nss_nis/nis-network.c32
-rw-r--r--nis/nss_nis/nis-proto.c31
-rw-r--r--nis/nss_nis/nis-publickey.c11
-rw-r--r--nis/nss_nis/nis-pwd.c34
-rw-r--r--nis/nss_nis/nis-rpc.c24
-rw-r--r--nis/nss_nis/nis-service.c38
-rw-r--r--nis/nss_nis/nis-spwd.c27
12 files changed, 189 insertions, 162 deletions
diff --git a/nis/nss_nis/nis-alias.c b/nis/nss_nis/nis-alias.c
index e187716bb0..0d0294082d 100644
--- a/nis/nss_nis/nis-alias.c
+++ b/nis/nss_nis/nis-alias.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
 
@@ -36,7 +36,7 @@ static int oldkeylen = 0;
 
 static int
 _nss_nis_parse_aliasent (const char *key, char *alias, struct aliasent *result,
-			 char *buffer, size_t buflen)
+			 char *buffer, size_t buflen, int *errnop)
 {
   char *first_unused = buffer + strlen (alias) + 1;
   size_t room_left =
@@ -53,7 +53,7 @@ _nss_nis_parse_aliasent (const char *key, char *alias, struct aliasent *result,
     {
       /* The line is too long for our buffer.  */
     no_more_room:
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return -1;
     }
 
@@ -138,7 +138,7 @@ _nss_nis_endaliasent (void)
 
 static enum nss_status
 internal_nis_getaliasent_r (struct aliasent *alias, char *buffer,
-			    size_t buflen)
+			    size_t buflen, int *errnop)
 {
   char *domain;
   char *result;
@@ -168,14 +168,14 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer,
       if (retval != NSS_STATUS_SUCCESS)
 	{
 	  if (retval == NSS_STATUS_TRYAGAIN)
-            __set_errno (EAGAIN);
+            *errnop = errno;
           return retval;
         }
 
       if ((size_t) (len + 1) > buflen)
         {
 	  free (result);
-          __set_errno (ERANGE);
+          *errnop = ERANGE;
           return NSS_STATUS_TRYAGAIN;
         }
       p = strncpy (buffer, result, len);
@@ -184,11 +184,12 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer,
         ++p;
       free (result);
 
-      if ((parse_res = _nss_nis_parse_aliasent (outkey, p, alias, 
-						buffer, buflen)) == -1)
+      parse_res = _nss_nis_parse_aliasent (outkey, p, alias, buffer, buflen,
+					   errnop);
+      if (parse_res == -1)
 	{
 	  free (outkey);
-	  __set_errno (ERANGE);
+	  *errnop = ERANGE;
 	  return NSS_STATUS_TRYAGAIN;
 	}
 
@@ -203,13 +204,14 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer,
 }
 
 enum nss_status
-_nss_nis_getaliasent_r (struct aliasent *alias, char *buffer, size_t buflen)
+_nss_nis_getaliasent_r (struct aliasent *alias, char *buffer, size_t buflen,
+			int *errnop)
 {
   enum nss_status status;
 
   __libc_lock_lock (lock);
 
-  status = internal_nis_getaliasent_r (alias, buffer, buflen);
+  status = internal_nis_getaliasent_r (alias, buffer, buflen, errnop);
 
   __libc_lock_unlock (lock);
 
@@ -218,7 +220,7 @@ _nss_nis_getaliasent_r (struct aliasent *alias, char *buffer, size_t buflen)
 
 enum nss_status
 _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias,
-			   char *buffer, size_t buflen)
+			   char *buffer, size_t buflen, int *errnop)
 {
   enum nss_status retval;
   int parse_res;
@@ -241,14 +243,14 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-	__set_errno (EAGAIN);
+	*errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -259,10 +261,10 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias,
   free (result);
 
   alias->alias_local = 0;
-  if ((parse_res = _nss_nis_parse_aliasent (name, p, alias, buffer, 
-					    buflen)) == -1)
+  parse_res = _nss_nis_parse_aliasent (name, p, alias, buffer, buflen, errnop);
+  if (parse_res == -1)
     return NSS_STATUS_TRYAGAIN;
-  
+
   if (parse_res)
     return NSS_STATUS_SUCCESS;
   else
diff --git a/nis/nss_nis/nis-ethers.c b/nis/nss_nis/nis-ethers.c
index e54262409c..365f9c9c1d 100644
--- a/nis/nss_nis/nis-ethers.c
+++ b/nis/nss_nis/nis-ethers.c
@@ -143,7 +143,8 @@ _nss_nis_endetherent (void)
 }
 
 static enum nss_status
-internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen)
+internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen,
+			    int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   int parse_res;
@@ -163,23 +164,25 @@ internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen)
       while (isspace (*p))
         ++p;
 
-      if ((parse_res = _nss_files_parse_etherent (p, eth, data, buflen)) == -1)
+      parse_res = _nss_files_parse_etherent (p, eth, data, buflen, errnop);
+      if (parse_res == -1)
 	return NSS_STATUS_TRYAGAIN;
       next = next->next;
     }
   while (!parse_res);
-  
+
   return NSS_STATUS_SUCCESS;
 }
 
 enum nss_status
-_nss_nis_getetherent_r (struct ether *result, char *buffer, size_t buflen)
+_nss_nis_getetherent_r (struct ether *result, char *buffer, size_t buflen,
+			int *errnop)
 {
   int status;
 
   __libc_lock_lock (lock);
 
-  status = internal_nis_getetherent_r (result, buffer, buflen);
+  status = internal_nis_getetherent_r (result, buffer, buflen, errnop);
 
   __libc_lock_unlock (lock);
 
@@ -188,7 +191,7 @@ _nss_nis_getetherent_r (struct ether *result, char *buffer, size_t buflen)
 
 enum nss_status
 _nss_nis_gethostton_r (const char *name, struct ether *eth,
-		       char *buffer, size_t buflen)
+		       char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   enum nss_status retval;
@@ -210,14 +213,14 @@ _nss_nis_gethostton_r (const char *name, struct ether *eth,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-        __set_errno (EAGAIN);
+        *errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -227,7 +230,8 @@ _nss_nis_gethostton_r (const char *name, struct ether *eth,
     ++p;
   free (result);
 
-  if ((parse_res = _nss_files_parse_etherent (p, eth, data, buflen)) == -1)
+  parse_res = _nss_files_parse_etherent (p, eth, data, buflen, errnop);
+  if (parse_res == -1)
     return NSS_STATUS_TRYAGAIN;
 
   if (!parse_res)
@@ -238,7 +242,7 @@ _nss_nis_gethostton_r (const char *name, struct ether *eth,
 
 enum nss_status
 _nss_nis_getntohost_r (struct ether_addr *addr, struct ether *eth,
-		       char *buffer, size_t buflen)
+		       char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   enum nss_status retval;
@@ -269,14 +273,14 @@ _nss_nis_getntohost_r (struct ether_addr *addr, struct ether *eth,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-        __set_errno (EAGAIN);
+        *errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -286,7 +290,8 @@ _nss_nis_getntohost_r (struct ether_addr *addr, struct ether *eth,
     ++p;
   free (result);
 
-  if ((parse_res = _nss_files_parse_etherent (p, eth, data, buflen)) == -1)
+  parse_res = _nss_files_parse_etherent (p, eth, data, buflen, errnop);
+  if (parse_res == -1)
     return NSS_STATUS_TRYAGAIN;
 
   if (!parse_res)
diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c
index 7897e21881..98cc4fd878 100644
--- a/nis/nss_nis/nis-grp.c
+++ b/nis/nss_nis/nis-grp.c
@@ -78,7 +78,8 @@ _nss_nis_endgrent (void)
 }
 
 static enum nss_status
-internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen)
+internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen,
+			 int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   char *domain, *result, *outkey;
@@ -104,14 +105,14 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen)
       if (retval != NSS_STATUS_SUCCESS)
         {
           if (retval == NSS_STATUS_TRYAGAIN)
-            __set_errno (EAGAIN);
+            *errnop = errno;
           return retval;
         }
 
       if ((size_t) (len + 1) > buflen)
         {
           free (result);
-          __set_errno (ERANGE);
+          *errnop = ERANGE;
           return NSS_STATUS_TRYAGAIN;
         }
 
@@ -121,9 +122,11 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen)
         ++p;
       free (result);
 
-      if ((parse_res = _nss_files_parse_grent (p, grp, data, buflen)) == -1)
+      parse_res = _nss_files_parse_grent (p, grp, data, buflen, errnop);
+      if (parse_res == -1)
 	{
 	  free (outkey);
+	  *errnop = ERANGE;
 	  return NSS_STATUS_TRYAGAIN;
 	}
 
@@ -138,13 +141,14 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen)
 }
 
 enum nss_status
-_nss_nis_getgrent_r (struct group *result, char *buffer, size_t buflen)
+_nss_nis_getgrent_r (struct group *result, char *buffer, size_t buflen,
+		     int *errnop)
 {
   int status;
 
   __libc_lock_lock (lock);
 
-  status = internal_nis_getgrent_r (result, buffer, buflen);
+  status = internal_nis_getgrent_r (result, buffer, buflen, errnop);
 
   __libc_lock_unlock (lock);
 
@@ -153,7 +157,7 @@ _nss_nis_getgrent_r (struct group *result, char *buffer, size_t buflen)
 
 enum nss_status
 _nss_nis_getgrnam_r (const char *name, struct group *grp,
-		     char *buffer, size_t buflen)
+		     char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   enum nss_status retval;
@@ -175,14 +179,14 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-        __set_errno (EAGAIN);
+        *errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -192,7 +196,8 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp,
     ++p;
   free (result);
 
-  if ((parse_res = _nss_files_parse_grent (p, grp, data, buflen)) == -1)
+  parse_res = _nss_files_parse_grent (p, grp, data, buflen, errnop);
+  if (parse_res == -1)
     return NSS_STATUS_TRYAGAIN;
 
   if (parse_res)
@@ -203,7 +208,7 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp,
 
 enum nss_status
 _nss_nis_getgrgid_r (gid_t gid, struct group *grp,
-		     char *buffer, size_t buflen)
+		     char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   enum nss_status retval;
@@ -222,14 +227,14 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-        __set_errno (EAGAIN);
+        *errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -239,7 +244,8 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp,
     ++p;
   free (result);
 
-  if ((parse_res = _nss_files_parse_grent (p, grp, data, buflen)) == -1)
+  parse_res = _nss_files_parse_grent (p, grp, data, buflen, errnop);
+  if (parse_res == -1)
     return NSS_STATUS_TRYAGAIN;
 
   if (parse_res)
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index da7cef5ada..f08a624c37 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -133,7 +133,7 @@ _nss_nis_endhostent (void)
 
 static enum nss_status
 internal_nis_gethostent_r (struct hostent *host, char *buffer,
-			   size_t buflen, int *h_errnop)
+			   size_t buflen, int *errnop, int *h_errnop)
 {
   char *domain;
   char *result;
@@ -148,7 +148,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
 
   if (buflen < sizeof *data + 1)
     {
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       *h_errnop = NETDB_INTERNAL;
       return NSS_STATUS_TRYAGAIN;
     }
@@ -172,7 +172,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
 	  switch (retval)
 	    {
 	    case NSS_STATUS_TRYAGAIN:
-	      __set_errno (EAGAIN);
+	      *errnop = errno;
 	      *h_errnop = TRY_AGAIN;
 	      break;
 	    case NSS_STATUS_NOTFOUND:
@@ -189,7 +189,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
         {
           free (result);
 	  *h_errnop = NETDB_INTERNAL;
-          __set_errno (ERANGE);
+          *errnop = ERANGE;
           return NSS_STATUS_TRYAGAIN;
         }
 
@@ -199,10 +199,11 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
 	++p;
       free (result);
 
-      if ((parse_res = parse_line (p, host, data, buflen)) == -1)
+      if ((parse_res = parse_line (p, host, data, buflen, errnop)) == -1)
 	{
 	  free (outkey);
-	  *h_errnop = NETDB_INTERNAL;;
+	  *h_errnop = NETDB_INTERNAL;
+	  *errnop = ERANGE;
 	  return NSS_STATUS_TRYAGAIN;
 	}
       free (oldkey);
@@ -218,13 +219,13 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
 
 int
 _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen,
-		       int *h_errnop)
+		       int *errnop, int *h_errnop)
 {
   int status;
 
   __libc_lock_lock (lock);
 
-  status = internal_nis_gethostent_r (host, buffer, buflen, h_errnop);
+  status = internal_nis_gethostent_r (host, buffer, buflen, errnop, h_errnop);
 
   __libc_lock_unlock (lock);
 
@@ -233,7 +234,8 @@ _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen,
 
 enum nss_status
 _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
-			  char *buffer, size_t buflen, int *h_errnop)
+			   char *buffer, size_t buflen, int *errnop,
+			   int *h_errnop)
 {
   enum nss_status retval;
   char *domain, *result, *p;
@@ -253,7 +255,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
   if (buflen < sizeof *data + 1)
     {
       *h_errnop = NETDB_INTERNAL;
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
   retval = yperr2nss (yp_match (domain, "hosts.byname", name,
@@ -264,7 +266,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
       if (retval == NSS_STATUS_TRYAGAIN)
 	{
 	  *h_errnop = TRY_AGAIN;
-	  __set_errno (EAGAIN);
+	  *errnop = errno;
 	}
       if (retval == NSS_STATUS_NOTFOUND)
 	*h_errnop = HOST_NOT_FOUND;
@@ -275,7 +277,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
     {
       free (result);
       *h_errnop = NETDB_INTERNAL;
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -285,7 +287,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
     ++p;
   free (result);
 
-  parse_res = parse_line (p, host, data, buflen);
+  parse_res = parse_line (p, host, data, buflen, errnop);
 
   if (parse_res < 1 || host->h_addrtype != af)
     {
@@ -306,27 +308,27 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
 }
 
 enum nss_status
-_nss_nis_gethostbyname_r (const char *name, struct hostent *host,
-			  char *buffer, size_t buflen, int *h_errnop)
+_nss_nis_gethostbyname_r (const char *name, struct hostent *host, char *buffer,
+			  size_t buflen, int *errnop, int *h_errnop)
 {
   if (_res.options & RES_USE_INET6)
     {
       enum nss_status status;
 
       status = _nss_nis_gethostbyname2_r (name, AF_INET6, host, buffer, buflen,
-					  h_errnop);
+					  errnop, h_errnop);
       if (status == NSS_STATUS_SUCCESS)
 	return status;
     }
 
   return _nss_nis_gethostbyname2_r (name, AF_INET, host, buffer, buflen,
-				    h_errnop);
+				    errnop, h_errnop);
 }
 
 enum nss_status
 _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type,
 			  struct hostent *host, char *buffer, size_t buflen,
-			  int *h_errnop)
+			  int *errnop, int *h_errnop)
 {
   enum nss_status retval;
   char *domain, *result, *p;
@@ -340,7 +342,7 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type,
 
   if (buflen < sizeof *data + 1)
     {
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       *h_errnop = NETDB_INTERNAL;
       return NSS_STATUS_TRYAGAIN;
     }
@@ -355,7 +357,7 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type,
       if (retval == NSS_STATUS_TRYAGAIN)
 	{
 	  *h_errnop = TRY_AGAIN;
-	  __set_errno (EAGAIN);
+	  *errnop = errno;
 	}
       if (retval == NSS_STATUS_NOTFOUND)
 	*h_errnop = HOST_NOT_FOUND;
@@ -365,7 +367,7 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type,
   if ((size_t) (len + 1) > linebuflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       *h_errnop = NETDB_INTERNAL;
       return NSS_STATUS_TRYAGAIN;
     }
@@ -376,7 +378,7 @@ _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type,
     ++p;
   free (result);
 
-  parse_res = parse_line (p, host, data, buflen);
+  parse_res = parse_line (p, host, data, buflen, errnop);
   if (parse_res < 1)
     {
       if (parse_res == -1)
diff --git a/nis/nss_nis/nis-netgrp.c b/nis/nss_nis/nis-netgrp.c
index ce8762a1e5..d170b56f50 100644
--- a/nis/nss_nis/nis-netgrp.c
+++ b/nis/nss_nis/nis-netgrp.c
@@ -40,7 +40,7 @@ static char *cursor = NULL;;
 
 extern enum nss_status
 _nss_netgroup_parseline (char **cursor, struct __netgrent *result,
-			 char *buffer, size_t buflen);
+			 char *buffer, size_t buflen, int *errnop);
 
 enum nss_status
 _nss_nis_setnetgrent (char *group)
@@ -111,7 +111,8 @@ _nss_nis_endnetgrent (void)
 }
 
 enum nss_status
-_nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen)
+_nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen,
+			int *errnop)
 {
   enum nss_status status;
 
@@ -120,7 +121,7 @@ _nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen)
 
   __libc_lock_lock (lock);
 
-  status = _nss_netgroup_parseline (&cursor, result, buffer, buflen);
+  status = _nss_netgroup_parseline (&cursor, result, buffer, buflen, errnop);
 
   __libc_lock_unlock (lock);
 
diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
index c17ba81a62..4fcf729b34 100644
--- a/nis/nss_nis/nis-network.c
+++ b/nis/nss_nis/nis-network.c
@@ -79,7 +79,7 @@ _nss_nis_endnetent (void)
 
 static enum nss_status
 internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
-			  int *herrnop)
+			  int *errnop, int *herrnop)
 {
   struct parser_data *data = (void *) buffer;
   char *domain, *result, *outkey;
@@ -107,7 +107,7 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
           if (retval == NSS_STATUS_TRYAGAIN)
 	    {
 	      *herrnop = NETDB_INTERNAL;
-	      __set_errno (EAGAIN);
+	      *errnop = errno;
 	    }
           return retval;
         }
@@ -126,10 +126,12 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
         ++p;
       free (result);
 
-      if ((parse_res = _nss_files_parse_netent (p, net, data, buflen)) == -1)
+      parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop);
+      if (parse_res == -1)
 	{
 	  free (outkey);
 	  *herrnop = NETDB_INTERNAL;
+	  *errnop = ERANGE;
 	  return NSS_STATUS_TRYAGAIN;
 	}
 
@@ -145,13 +147,13 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
 
 enum nss_status
 _nss_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
-		      int *herrnop)
+		      int *errnop, int *herrnop)
 {
   enum nss_status status;
 
   __libc_lock_lock (lock);
 
-  status = internal_nis_getnetent_r (net, buffer, buflen, herrnop);
+  status = internal_nis_getnetent_r (net, buffer, buflen, errnop, herrnop);
 
   __libc_lock_unlock (lock);
 
@@ -159,8 +161,8 @@ _nss_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
 }
 
 enum nss_status
-_nss_nis_getnetbyname_r (const char *name, struct netent *net,
-			 char *buffer, size_t buflen, int *herrnop)
+_nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer,
+			 size_t buflen, int *errnop, int *herrnop)
 {
   enum nss_status retval;
   struct parser_data *data = (void *) buffer;
@@ -184,7 +186,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net,
     {
       if (retval == NSS_STATUS_TRYAGAIN)
 	{
-	  __set_errno (EAGAIN);
+	  *errnop = errno;
 	  *herrnop = NETDB_INTERNAL;
 	}
       return retval;
@@ -193,7 +195,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net,
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       *herrnop = NETDB_INTERNAL;
       return NSS_STATUS_TRYAGAIN;
     }
@@ -204,7 +206,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net,
     ++p;
   free (result);
 
-  parse_res = _nss_files_parse_netent (p, net, data, buflen);
+  parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop);
 
   if (parse_res < 1)
     {
@@ -220,7 +222,8 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net,
 
 enum nss_status
 _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net,
-			 char *buffer, size_t buflen, int *herrnop)
+			 char *buffer, size_t buflen, int *errnop,
+			 int *herrnop)
 {
   struct parser_data *data = (void *) buffer;
   char *domain;
@@ -264,7 +267,7 @@ _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net,
 	    else
 	      {
 		if (retval == NSS_STATUS_TRYAGAIN)
-		  __set_errno (EAGAIN);
+		  *errnop = errno;
 		return retval;
 	      }
 	  }
@@ -272,7 +275,7 @@ _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net,
       if ((size_t) (len + 1) > buflen)
 	{
 	  free (result);
-	  __set_errno (ERANGE);
+	  *errnop = ERANGE;
 	  *herrnop = NETDB_INTERNAL;
 	  return NSS_STATUS_TRYAGAIN;
 	}
@@ -283,8 +286,7 @@ _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net,
 	  ++p;
 	free (result);
 
-	parse_res = _nss_files_parse_netent (p, net, data, buflen);
-
+	parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop);
 
 	if (parse_res < 1)
 	  {
diff --git a/nis/nss_nis/nis-proto.c b/nis/nss_nis/nis-proto.c
index eb09bb4ec7..e0c976041d 100644
--- a/nis/nss_nis/nis-proto.c
+++ b/nis/nss_nis/nis-proto.c
@@ -136,7 +136,7 @@ _nss_nis_endprotoent (void)
 
 static enum nss_status
 internal_nis_getprotoent_r (struct protoent *proto,
-			    char *buffer, size_t buflen)
+			    char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   int parse_res;
@@ -156,24 +156,25 @@ internal_nis_getprotoent_r (struct protoent *proto,
       while (isspace (*p))
         ++p;
 
-      if ((parse_res = _nss_files_parse_protoent (p, proto, data, 
-						  buflen)) == -1)
+      parse_res = _nss_files_parse_protoent (p, proto, data, buflen, errnop);
+      if (parse_res == -1)
         return NSS_STATUS_TRYAGAIN;
       next = next->next;
     }
   while (!parse_res);
-  
+
   return NSS_STATUS_SUCCESS;
 }
 
 enum nss_status
-_nss_nis_getprotoent_r (struct protoent *proto, char *buffer, size_t buflen)
+_nss_nis_getprotoent_r (struct protoent *proto, char *buffer, size_t buflen,
+			int *errnop)
 {
   enum nss_status status;
 
   __libc_lock_lock (lock);
 
-  status = internal_nis_getprotoent_r (proto, buffer, buflen);
+  status = internal_nis_getprotoent_r (proto, buffer, buflen, errnop);
 
   __libc_lock_unlock (lock);
 
@@ -182,7 +183,7 @@ _nss_nis_getprotoent_r (struct protoent *proto, char *buffer, size_t buflen)
 
 enum nss_status
 _nss_nis_getprotobyname_r (const char *name, struct protoent *proto,
-			   char *buffer, size_t buflen)
+			   char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   enum nss_status retval;
@@ -204,14 +205,14 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-        __set_errno (EAGAIN);
+	*errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -221,7 +222,8 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto,
     ++p;
   free (result);
 
-  if ((parse_res = _nss_files_parse_protoent (p, proto, data, buflen)) == -1)
+  parse_res = _nss_files_parse_protoent (p, proto, data, buflen, errnop);
+  if (parse_res == -1)
     return NSS_STATUS_TRYAGAIN;
 
   if (parse_res)
@@ -232,7 +234,7 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto,
 
 enum nss_status
 _nss_nis_getprotobynumber_r (int number, struct protoent *proto,
-			     char *buffer, size_t buflen)
+			     char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   enum nss_status retval;
@@ -251,14 +253,14 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-        __set_errno (EAGAIN);
+	*errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -268,7 +270,8 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto,
     ++p;
   free (result);
 
-  if ((parse_res = _nss_files_parse_protoent (p, proto, data, buflen)) == -1)
+  parse_res = _nss_files_parse_protoent (p, proto, data, buflen, errnop);
+  if (parse_res == -1)
     return NSS_STATUS_TRYAGAIN;
 
   if (parse_res)
diff --git a/nis/nss_nis/nis-publickey.c b/nis/nss_nis/nis-publickey.c
index 4c921f4853..1c485d9d23 100644
--- a/nis/nss_nis/nis-publickey.c
+++ b/nis/nss_nis/nis-publickey.c
@@ -32,7 +32,7 @@ extern int xdecrypt (char *, char *);
 
 /* If we haven't found the entry, we give a SUCCESS and an empty key back. */
 enum nss_status
-_nss_nis_getpublickey (const char *netname, char *pkey)
+_nss_nis_getpublickey (const char *netname, char *pkey, int *errnop)
 {
   enum nss_status retval;
   char *domain, *result;
@@ -57,7 +57,7 @@ _nss_nis_getpublickey (const char *netname, char *pkey)
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-	__set_errno (EAGAIN);
+	*errnop = errno;
       return retval;
     }
 
@@ -72,7 +72,8 @@ _nss_nis_getpublickey (const char *netname, char *pkey)
 }
 
 enum nss_status
-_nss_nis_getsecretkey (const char *netname, char *skey, char *passwd)
+_nss_nis_getsecretkey (const char *netname, char *skey, char *passwd,
+		       int *errnop)
 {
   enum nss_status retval;
   char buf[1024];
@@ -98,7 +99,7 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd)
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-	__set_errno (EAGAIN);
+	*errnop = errno;
       return retval;
     }
 
@@ -178,7 +179,7 @@ parse_netid_str (const char *s, uid_t *uidp, gid_t *gidp, int *gidlenp,
 
 enum nss_status
 _nss_nis_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
-		       gid_t *gidp, int *gidlenp, gid_t *gidlist)
+		       gid_t *gidp, int *gidlenp, gid_t *gidlist, int *errnop)
 {
   char *domain;
   int yperr;
diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c
index f693db17ea..8924886e1e 100644
--- a/nis/nss_nis/nis-pwd.c
+++ b/nis/nss_nis/nis-pwd.c
@@ -78,7 +78,8 @@ _nss_nis_endpwent (void)
 }
 
 static enum nss_status
-internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen)
+internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen,
+			 int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   char *domain, *result, *outkey;
@@ -104,14 +105,14 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen)
       if (retval != NSS_STATUS_SUCCESS)
         {
           if (retval == NSS_STATUS_TRYAGAIN)
-            __set_errno (EAGAIN);
+            *errnop = errno;
           return retval;
         }
 
       if ((size_t) (len + 1) > buflen)
         {
           free (result);
-          __set_errno (ERANGE);
+	  *errnop = ERANGE;
           return NSS_STATUS_TRYAGAIN;
         }
 
@@ -121,9 +122,11 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen)
         ++p;
       free (result);
 
-      if ((parse_res = _nss_files_parse_pwent (p, pwd, data, buflen)) == -1)
+      parse_res = _nss_files_parse_pwent (p, pwd, data, buflen, errnop);
+      if (parse_res == -1)
 	{
 	  free (outkey);
+	  *errnop = ERANGE;
 	  return NSS_STATUS_TRYAGAIN;
 	}
 
@@ -138,13 +141,14 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen)
 }
 
 enum nss_status
-_nss_nis_getpwent_r (struct passwd *result, char *buffer, size_t buflen)
+_nss_nis_getpwent_r (struct passwd *result, char *buffer, size_t buflen,
+		     int *errnop)
 {
   int status;
 
   __libc_lock_lock (lock);
 
-  status = internal_nis_getpwent_r (result, buffer, buflen);
+  status = internal_nis_getpwent_r (result, buffer, buflen, errnop);
 
   __libc_lock_unlock (lock);
 
@@ -153,7 +157,7 @@ _nss_nis_getpwent_r (struct passwd *result, char *buffer, size_t buflen)
 
 enum nss_status
 _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
-		     char *buffer, size_t buflen)
+		     char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   enum nss_status retval;
@@ -175,14 +179,14 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-        __set_errno (EAGAIN);
+	*errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -192,8 +196,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
     ++p;
   free (result);
 
-  parse_res = _nss_files_parse_pwent (p, pwd, data, buflen);
-
+  parse_res = _nss_files_parse_pwent (p, pwd, data, buflen, errnop);
   if (parse_res < 1)
     {
       if (parse_res == -1)
@@ -207,7 +210,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
 
 enum nss_status
 _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
-		     char *buffer, size_t buflen)
+		     char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   enum nss_status retval;
@@ -226,14 +229,14 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-        __set_errno (EAGAIN);
+	*errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -243,8 +246,7 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
     ++p;
   free (result);
 
-  parse_res = _nss_files_parse_pwent (p, pwd, data, buflen);
-
+  parse_res = _nss_files_parse_pwent (p, pwd, data, buflen, errnop);
   if (parse_res < 1)
     {
       if (parse_res == -1)
diff --git a/nis/nss_nis/nis-rpc.c b/nis/nss_nis/nis-rpc.c
index cd1f0db9b5..274ef04b7a 100644
--- a/nis/nss_nis/nis-rpc.c
+++ b/nis/nss_nis/nis-rpc.c
@@ -154,7 +154,7 @@ _nss_nis_endrpcent (void)
 
 static enum nss_status
 internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen,
-			  intern_t *data)
+			  int *errnop, intern_t *data)
 {
   struct parser_data *pdata = (void *) buffer;
   int parse_res;
@@ -172,7 +172,8 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen,
       while (isspace (*p))
         ++p;
 
-      if ((parse_res = _nss_files_parse_rpcent (p, rpc, pdata, buflen)) == -1)
+      parse_res = _nss_files_parse_rpcent (p, rpc, pdata, buflen, errnop);
+      if (parse_res == -1)
 	return NSS_STATUS_TRYAGAIN;
       data->next = data->next->next;
     }
@@ -182,13 +183,14 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen,
 }
 
 enum nss_status
-_nss_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen)
+_nss_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen,
+		      int *errnop)
 {
   enum nss_status status;
 
   __libc_lock_lock (lock);
 
-  status = internal_nis_getrpcent_r (rpc, buffer, buflen, &intern);
+  status = internal_nis_getrpcent_r (rpc, buffer, buflen, errnop, &intern);
 
   __libc_lock_unlock (lock);
 
@@ -197,7 +199,7 @@ _nss_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen)
 
 enum nss_status
 _nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc,
-			 char *buffer, size_t buflen)
+			 char *buffer, size_t buflen, int *errnop)
 {
   intern_t data = {NULL, NULL};
   enum nss_status status;
@@ -215,8 +217,8 @@ _nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc,
 
   found = 0;
   while (!found &&
-         ((status = internal_nis_getrpcent_r (rpc, buffer, buflen, &data))
-          == NSS_STATUS_SUCCESS))
+         ((status = internal_nis_getrpcent_r (rpc, buffer, buflen, errnop,
+					      &data)) == NSS_STATUS_SUCCESS))
     {
       if (strcmp (rpc->r_name, name) == 0)
 	found = 1;
@@ -247,7 +249,7 @@ _nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc,
 
 enum nss_status
 _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc,
-			   char *buffer, size_t buflen)
+			   char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   enum nss_status retval;
@@ -266,14 +268,14 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-	__set_errno (EAGAIN);
+	*errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -283,7 +285,7 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc,
     ++p;
   free (result);
 
-  parse_res = _nss_files_parse_rpcent (p, rpc, data, buflen);
+  parse_res = _nss_files_parse_rpcent (p, rpc, data, buflen, errnop);
 
   if (parse_res < 1)
     {
diff --git a/nis/nss_nis/nis-service.c b/nis/nss_nis/nis-service.c
index 5ec89c8677..c55b3e0191 100644
--- a/nis/nss_nis/nis-service.c
+++ b/nis/nss_nis/nis-service.c
@@ -31,7 +31,7 @@
 
 /* The parser is defined in a different module.  */
 extern int _nss_files_parse_servent (char *line, struct servent *result,
-				     char *data, size_t datalen);
+				     char *data, size_t datalen, int *errnop);
 
 
 
@@ -155,7 +155,7 @@ _nss_nis_endservent (void)
 
 static enum nss_status
 internal_nis_getservent_r (struct servent *serv, char *buffer,
-			   size_t buflen, intern_t *data)
+			   size_t buflen, int *errnop, intern_t *data)
 {
   int parse_res;
   char *p;
@@ -172,8 +172,8 @@ internal_nis_getservent_r (struct servent *serv, char *buffer,
            while (isspace (*p))
         ++p;
 
-      if ((parse_res = _nss_files_parse_servent (p, serv, buffer, 
-						 buflen)) == -1)
+      parse_res = _nss_files_parse_servent (p, serv, buffer, buflen, errnop);
+      if (parse_res == -1)
         return NSS_STATUS_TRYAGAIN;
       data->next = data->next->next;
     }
@@ -183,13 +183,14 @@ internal_nis_getservent_r (struct servent *serv, char *buffer,
 }
 
 enum nss_status
-_nss_nis_getservent_r (struct servent *serv, char *buffer, size_t buflen)
+_nss_nis_getservent_r (struct servent *serv, char *buffer, size_t buflen,
+		       int *errnop)
 {
   enum nss_status status;
 
   __libc_lock_lock (lock);
 
-  status = internal_nis_getservent_r (serv, buffer, buflen, &intern);
+  status = internal_nis_getservent_r (serv, buffer, buflen, errnop, &intern);
 
   __libc_lock_unlock (lock);
 
@@ -198,7 +199,8 @@ _nss_nis_getservent_r (struct servent *serv, char *buffer, size_t buflen)
 
 enum nss_status
 _nss_nis_getservbyname_r (const char *name, char *protocol,
-			  struct servent *serv, char *buffer, size_t buflen)
+			  struct servent *serv, char *buffer, size_t buflen,
+			  int *errnop)
 {
   intern_t data = { NULL, NULL };
   enum nss_status status;
@@ -216,8 +218,8 @@ _nss_nis_getservbyname_r (const char *name, char *protocol,
 
   found = 0;
   while (!found &&
-         ((status = internal_nis_getservent_r (serv, buffer, buflen, &data))
-          == NSS_STATUS_SUCCESS))
+         ((status = internal_nis_getservent_r (serv, buffer, buflen, errnop,
+					       &data)) == NSS_STATUS_SUCCESS))
     {
       if (protocol == NULL || strcmp (serv->s_proto, protocol) == 0)
 	{
@@ -242,7 +244,7 @@ _nss_nis_getservbyname_r (const char *name, char *protocol,
 
 enum nss_status
 _nss_nis_getservbyport_r (int port, char *protocol, struct servent *serv,
-			  char *buffer, size_t buflen)
+			  char *buffer, size_t buflen, int *errnop)
 {
   intern_t data = { NULL, NULL };
   enum nss_status status;
@@ -260,17 +262,11 @@ _nss_nis_getservbyport_r (int port, char *protocol, struct servent *serv,
 
   found = 0;
   while (!found &&
-         ((status = internal_nis_getservent_r (serv, buffer, buflen, &data))
-          == NSS_STATUS_SUCCESS))
-    {
-      if (htons (serv->s_port) == port)
-        {
-          if  (strcmp (serv->s_proto, protocol) == 0)
-            {
-              found = 1;
-            }
-        }
-    }
+         ((status = internal_nis_getservent_r (serv, buffer, buflen, errnop,
+					       &data)) == NSS_STATUS_SUCCESS))
+    if (htons (serv->s_port) == port
+	&&  strcmp (serv->s_proto, protocol) == 0)
+      found = 1;
 
   internal_nis_endservent (&data);
 
diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c
index 0263f4e313..5be010d433 100644
--- a/nis/nss_nis/nis-spwd.c
+++ b/nis/nss_nis/nis-spwd.c
@@ -78,7 +78,8 @@ _nss_nis_endspent (void)
 }
 
 static enum nss_status
-internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen)
+internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen,
+			 int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   char *domain, *result, *outkey;
@@ -104,14 +105,14 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen)
       if (retval != NSS_STATUS_SUCCESS)
         {
           if (retval == NSS_STATUS_TRYAGAIN)
-            __set_errno (EAGAIN);
+	    *errnop = errno;
           return retval;
         }
 
       if ((size_t) (len + 1) > buflen)
         {
           free (result);
-          __set_errno (ERANGE);
+	  *errnop = ERANGE;
           return NSS_STATUS_TRYAGAIN;
         }
 
@@ -121,12 +122,14 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen)
         ++p;
       free (result);
 
-      if ((parse_res = _nss_files_parse_spent (p, sp, data, buflen)) == -1)
+      parse_res = _nss_files_parse_spent (p, sp, data, buflen, errnop);
+      if (parse_res == -1)
 	{
 	  free (outkey);
+	  *errnop = ERANGE;
 	  return NSS_STATUS_TRYAGAIN;
 	}
-      
+
       free (oldkey);
       oldkey = outkey;
       oldkeylen = keylen;
@@ -138,13 +141,14 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen)
 }
 
 enum nss_status
-_nss_nis_getspent_r (struct spwd *result, char *buffer, size_t buflen)
+_nss_nis_getspent_r (struct spwd *result, char *buffer, size_t buflen,
+		     int *errnop)
 {
   int status;
 
   __libc_lock_lock (lock);
 
-  status = internal_nis_getspent_r (result, buffer, buflen);
+  status = internal_nis_getspent_r (result, buffer, buflen, errnop);
 
   __libc_lock_unlock (lock);
 
@@ -153,7 +157,7 @@ _nss_nis_getspent_r (struct spwd *result, char *buffer, size_t buflen)
 
 enum nss_status
 _nss_nis_getspnam_r (const char *name, struct spwd *sp,
-		     char *buffer, size_t buflen)
+		     char *buffer, size_t buflen, int *errnop)
 {
   struct parser_data *data = (void *) buffer;
   enum nss_status retval;
@@ -175,14 +179,14 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp,
   if (retval != NSS_STATUS_SUCCESS)
     {
       if (retval == NSS_STATUS_TRYAGAIN)
-        __set_errno (EAGAIN);
+	*errnop = errno;
       return retval;
     }
 
   if ((size_t) (len + 1) > buflen)
     {
       free (result);
-      __set_errno (ERANGE);
+      *errnop = ERANGE;
       return NSS_STATUS_TRYAGAIN;
     }
 
@@ -192,7 +196,8 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp,
     ++p;
   free (result);
 
-  if ((parse_res = _nss_files_parse_spent (p, sp, data, buflen)) == -1)
+  parse_res = _nss_files_parse_spent (p, sp, data, buflen, errnop);
+  if (parse_res == -1)
     return NSS_STATUS_TRYAGAIN;
 
   if (parse_res)