about summary refs log tree commit diff
path: root/nis/nss_nis
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-08-18 23:27:30 +0000
committerUlrich Drepper <drepper@redhat.com>1998-08-18 23:27:30 +0000
commit0c6cee5d656d933100b86b7d58803bdbd549e456 (patch)
tree9fe94f38351584e600d19b26893b957fabf37715 /nis/nss_nis
parenteedbbe588f893e8bd93e65617d3fd98e172a3569 (diff)
downloadglibc-0c6cee5d656d933100b86b7d58803bdbd549e456.tar.gz
glibc-0c6cee5d656d933100b86b7d58803bdbd549e456.tar.xz
glibc-0c6cee5d656d933100b86b7d58803bdbd549e456.zip
Update.
1998-08-18  Ulrich Drepper  <drepper@cygnus.com>

	* include/features.h: Define __USE_EXTERN_INLINES for recent
	enough gcc.
	* argp/argp.h: Define extern inline functions only if
	__USE_EXTERN_INLINES is defined.
	* libio/stdio.h: Likewise.
	* math/math.h: Likewise.
	* stdlib/stdlib.h: Likewise.
	* string/argz.h: Likewise.
	* sysdeps/generic/bits/sigset.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/sigset.h: Likewise.
	* sysdeps/unix/sysv/sysv4/bits/sigset.h: Likewise.
	* sysdeps/wordsize-32/inttypes.h: Likewise.
	* sysdeps/wordsize-64/inttypes.h: Likewise.
	* wcsmbs/wchar.h: Likewise.

	* sysdeps/generic/bits/glob.c [_LIBC]: Define __stat using __xstat
	to allow compilation without optimization.

1998-08-14  Thorsten Kukuk  <kukuk@vt.uni-paderborn.de> 
 
	* nis/nss_compat/compat-grp.c: Set errno to ENOENT if we have no 
	more entries. 
	* nis/nss_compat/compat-initgroups.c: Likewise. 
	* 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-initgroups.c: Likewise. 
	* nis/nss_nis/nis-network.c: Likewise. 
	* nis/nss_nis/nis-proto.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/rpcsvc/yp.h: Generate new without 1024 byte limits. 
 
	* nis/ypclnt.c: Try binding dir only first time, could be to old. 
 
	* nis/yp_xdr.c: Remove 1024 byte limit. 
	* nis/ypupdate_xdr.c: Likewise. 
 
	* nis/nss_nis/nis-publickey.c: Make sure, nobody could send 
	wrong data. 
 
Diffstat (limited to 'nis/nss_nis')
-rw-r--r--nis/nss_nis/nis-alias.c4
-rw-r--r--nis/nss_nis/nis-ethers.c16
-rw-r--r--nis/nss_nis/nis-grp.c24
-rw-r--r--nis/nss_nis/nis-hosts.c1
-rw-r--r--nis/nss_nis/nis-initgroups.c5
-rw-r--r--nis/nss_nis/nis-network.c23
-rw-r--r--nis/nss_nis/nis-proto.c25
-rw-r--r--nis/nss_nis/nis-publickey.c26
-rw-r--r--nis/nss_nis/nis-pwd.c24
-rw-r--r--nis/nss_nis/nis-rpc.c21
-rw-r--r--nis/nss_nis/nis-service.c17
-rw-r--r--nis/nss_nis/nis-spwd.c15
12 files changed, 150 insertions, 51 deletions
diff --git a/nis/nss_nis/nis-alias.c b/nis/nss_nis/nis-alias.c
index 50f08d2e0c..d1dc992c83 100644
--- a/nis/nss_nis/nis-alias.c
+++ b/nis/nss_nis/nis-alias.c
@@ -167,7 +167,9 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer,
 				      &result, &len));
       if (retval != NSS_STATUS_SUCCESS)
 	{
-	  if (retval == NSS_STATUS_TRYAGAIN)
+	  if (retval == NSS_STATUS_NOTFOUND)
+	    *errnop = ENOENT;
+	  else if (retval == NSS_STATUS_TRYAGAIN)
             *errnop = errno;
           return retval;
         }
diff --git a/nis/nss_nis/nis-ethers.c b/nis/nss_nis/nis-ethers.c
index a5723747fc..c95f766469 100644
--- a/nis/nss_nis/nis-ethers.c
+++ b/nis/nss_nis/nis-ethers.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
 
@@ -158,7 +158,10 @@ internal_nis_getetherent_r (struct ether *eth, char *buffer, size_t buflen,
       char *p;
 
       if (next == NULL)
-	return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
       p = strncpy (buffer, next->val, buflen);
 
       while (isspace (*p))
@@ -212,7 +215,9 @@ _nss_nis_gethostton_r (const char *name, struct ether *eth,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
         *errnop = errno;
       return retval;
     }
@@ -297,7 +302,10 @@ _nss_nis_getntohost_r (struct ether_addr *addr, struct ether *eth,
       if (parse_res == -1)
 	return NSS_STATUS_TRYAGAIN;
       else
-	return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
     }
   return NSS_STATUS_SUCCESS;
 }
diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c
index 40d45825e4..6dca66e4df 100644
--- a/nis/nss_nis/nis-grp.c
+++ b/nis/nss_nis/nis-grp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
 
@@ -104,7 +104,9 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen,
 
       if (retval != NSS_STATUS_SUCCESS)
         {
-          if (retval == NSS_STATUS_TRYAGAIN)
+	  if (retval == NSS_STATUS_NOTFOUND)
+	    *errnop = ENOENT;
+          else if (retval == NSS_STATUS_TRYAGAIN)
             *errnop = errno;
           return retval;
         }
@@ -178,7 +180,9 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = EAGAIN;
+      else if (retval == NSS_STATUS_TRYAGAIN)
         *errnop = errno;
       return retval;
     }
@@ -202,7 +206,10 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp,
       if (parse_res == -1)
 	return NSS_STATUS_TRYAGAIN;
       else
-	return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = EAGAIN;
+	  return NSS_STATUS_NOTFOUND;
+	}
     }
   return NSS_STATUS_SUCCESS;
 }
@@ -227,7 +234,9 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
         *errnop = errno;
       return retval;
     }
@@ -251,7 +260,10 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp,
       if (parse_res == -1)
 	return NSS_STATUS_TRYAGAIN;
       else
-	return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
     }
   return NSS_STATUS_SUCCESS;
 }
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index 4abc613bbb..d791b98b3e 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -176,6 +176,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
 	      *h_errnop = TRY_AGAIN;
 	      break;
 	    case NSS_STATUS_NOTFOUND:
+	      *errnop = ENOENT;
 	      *h_errnop = HOST_NOT_FOUND;
 	      break;
 	    default:
diff --git a/nis/nss_nis/nis-initgroups.c b/nis/nss_nis/nis-initgroups.c
index 5960c80502..b69fea4e85 100644
--- a/nis/nss_nis/nis-initgroups.c
+++ b/nis/nss_nis/nis-initgroups.c
@@ -112,7 +112,10 @@ internal_getgrent_r (struct group *grp, char *buffer, size_t buflen,
   do
     {
       if (intern->next == NULL)
-        return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
       p = strncpy (buffer, intern->next->val, buflen);
       while (isspace (*p))
         ++p;
diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
index 802c03229e..7a1b65e584 100644
--- a/nis/nss_nis/nis-network.c
+++ b/nis/nss_nis/nis-network.c
@@ -104,7 +104,9 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
 
       if (retval != NSS_STATUS_SUCCESS)
         {
-          if (retval == NSS_STATUS_TRYAGAIN)
+	  if (retval == NSS_STATUS_NOTFOUND)
+	    *errnop = ENOENT;
+          else if (retval == NSS_STATUS_TRYAGAIN)
 	    {
 	      *herrnop = NETDB_INTERNAL;
 	      *errnop = errno;
@@ -203,7 +205,9 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
 	{
 	  *errnop = errno;
 	  *herrnop = NETDB_INTERNAL;
@@ -233,7 +237,10 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer,
       if (parse_res == -1)
 	return NSS_STATUS_TRYAGAIN;
       else
-        return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
     }
   else
     return NSS_STATUS_SUCCESS;
@@ -281,7 +288,10 @@ _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net,
 		    continue;
 		  }
 		else
-		  return NSS_STATUS_NOTFOUND;
+		  {
+		    *errnop = ENOENT;
+		    return NSS_STATUS_NOTFOUND;
+		  }
 	      }
 	    else
 	      {
@@ -313,7 +323,10 @@ _nss_nis_getnetbyaddr_r (unsigned long addr, int type, struct netent *net,
 	    if (parse_res == -1)
 	      return NSS_STATUS_TRYAGAIN;
 	    else
-	      return NSS_STATUS_NOTFOUND;
+	      {
+		*errnop = ENOENT;
+		return NSS_STATUS_NOTFOUND;
+	      }
 	  }
 	else
 	  return NSS_STATUS_SUCCESS;
diff --git a/nis/nss_nis/nis-proto.c b/nis/nss_nis/nis-proto.c
index 3af0f4e896..e65bfa7c8d 100644
--- a/nis/nss_nis/nis-proto.c
+++ b/nis/nss_nis/nis-proto.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
 
@@ -150,7 +150,10 @@ internal_nis_getprotoent_r (struct protoent *proto,
       char *p;
 
       if (next == NULL)
-        return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
       p = strncpy (buffer, next->val, buflen);
 
       while (isspace (*p))
@@ -204,7 +207,9 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
 	*errnop = errno;
       return retval;
     }
@@ -228,7 +233,10 @@ _nss_nis_getprotobyname_r (const char *name, struct protoent *proto,
       if (parse_res == -1)
 	return NSS_STATUS_TRYAGAIN;
       else
-	return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
     }
   return NSS_STATUS_SUCCESS;
 }
@@ -253,7 +261,9 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
 	*errnop = errno;
       return retval;
     }
@@ -277,7 +287,10 @@ _nss_nis_getprotobynumber_r (int number, struct protoent *proto,
       if (parse_res == -1)
 	return NSS_STATUS_TRYAGAIN;
       else
-	return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
     }
   return NSS_STATUS_SUCCESS;
 }
diff --git a/nis/nss_nis/nis-publickey.c b/nis/nss_nis/nis-publickey.c
index 1ab041f435..73afd442a9 100644
--- a/nis/nss_nis/nis-publickey.c
+++ b/nis/nss_nis/nis-publickey.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
 
@@ -30,7 +30,9 @@ extern int xdecrypt (char *, char *);
 
 #include "nss-nis.h"
 
-/* If we haven't found the entry, we give a SUCCESS and an empty key back. */
+/* If we haven't found the entry, we give a SUCCESS and an empty key back.
+   Solaris docu says: sizeof (pkey) == HEXKEYBYTES + 1.
+*/
 enum nss_status
 _nss_nis_getpublickey (const char *netname, char *pkey, int *errnop)
 {
@@ -56,7 +58,9 @@ _nss_nis_getpublickey (const char *netname, char *pkey, int *errnop)
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
 	*errnop = errno;
       return retval;
     }
@@ -66,7 +70,8 @@ _nss_nis_getpublickey (const char *netname, char *pkey, int *errnop)
       char *p = strchr (result, ':');
       if (p != NULL)
 	*p = 0;
-      strcpy (pkey, result);
+      strncpy (pkey, result, HEXKEYBYTES + 1);
+      pkey[HEXKEYBYTES] = '\0';
     }
   return NSS_STATUS_SUCCESS;
 }
@@ -76,7 +81,7 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd,
 		       int *errnop)
 {
   enum nss_status retval;
-  char buf[1024];
+  char buf[2 * (HEXKEYBYTES + 1)];
   char *domain, *result;
   int len;
 
@@ -98,7 +103,9 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
 	*errnop = errno;
       return retval;
     }
@@ -109,15 +116,16 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd,
       if (p == NULL)
 	return NSS_STATUS_SUCCESS;
 
-      p++;
-      strcpy (buf, p);
+      ++p;
+      strncpy (buf, p, 2 * (HEXKEYBYTES + 1));
+      buf[2 * (HEXKEYBYTES + 1)] = '\0';
       if (!xdecrypt (buf, passwd))
 	return NSS_STATUS_SUCCESS;
 
       if (memcmp (buf, &(buf[HEXKEYBYTES]), KEYCHECKSUMSIZE) != 0)
 	return NSS_STATUS_SUCCESS;
 
-      buf[HEXKEYBYTES] = 0;
+      buf[HEXKEYBYTES] = '\0';
       strcpy (skey, buf);
     }
   return NSS_STATUS_SUCCESS;
diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c
index b70091508c..614637a173 100644
--- a/nis/nss_nis/nis-pwd.c
+++ b/nis/nss_nis/nis-pwd.c
@@ -106,7 +106,9 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen,
 
       if (retval != NSS_STATUS_SUCCESS)
         {
-          if (retval == NSS_STATUS_TRYAGAIN)
+	  if (retval == NSS_STATUS_NOTFOUND)
+	    *errnop = ENOENT;
+          else if (retval == NSS_STATUS_TRYAGAIN)
             *errnop = errno;
           return retval;
         }
@@ -231,7 +233,9 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
 	*errnop = errno;
       return retval;
     }
@@ -302,7 +306,10 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
       if (parse_res == -1)
         return NSS_STATUS_TRYAGAIN;
       else
-        return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
     }
   else
     return NSS_STATUS_SUCCESS;
@@ -329,7 +336,9 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
 	*errnop = errno;
       return retval;
     }
@@ -400,8 +409,11 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
     {
       if (parse_res == -1)
         return NSS_STATUS_TRYAGAIN;
-      else
-        return NSS_STATUS_NOTFOUND;
+     else
+       {
+	 *errnop = ENOENT;
+	 return NSS_STATUS_NOTFOUND;
+       }
     }
   else
     return NSS_STATUS_SUCCESS;
diff --git a/nis/nss_nis/nis-rpc.c b/nis/nss_nis/nis-rpc.c
index 879e90af6d..a56ad037fe 100644
--- a/nis/nss_nis/nis-rpc.c
+++ b/nis/nss_nis/nis-rpc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
 
@@ -167,7 +167,10 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen,
   do
     {
       if (data->next == NULL)
-        return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
       p = strncpy (buffer, data->next->val, buflen);
       while (isspace (*p))
         ++p;
@@ -242,7 +245,10 @@ _nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc,
   internal_nis_endrpcent (&data);
 
   if (!found && status == NSS_STATUS_SUCCESS)
-    return NSS_STATUS_NOTFOUND;
+    {
+      *errnop = ENOENT;
+      return NSS_STATUS_NOTFOUND;
+    }
   else
     return status;
 }
@@ -267,7 +273,9 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
 	*errnop = errno;
       return retval;
     }
@@ -292,7 +300,10 @@ _nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc,
       if (parse_res == -1)
 	return NSS_STATUS_TRYAGAIN;
       else
-	return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
     }
   else
     return NSS_STATUS_SUCCESS;
diff --git a/nis/nss_nis/nis-service.c b/nis/nss_nis/nis-service.c
index dfae9f7be2..fac62a9679 100644
--- a/nis/nss_nis/nis-service.c
+++ b/nis/nss_nis/nis-service.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
 
@@ -166,7 +166,10 @@ internal_nis_getservent_r (struct servent *serv, char *buffer,
   do
     {
       if (data->next == NULL)
-	return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
       p = strncpy (buffer, data->next->val, buflen);
            while (isspace (*p))
         ++p;
@@ -236,7 +239,10 @@ _nss_nis_getservbyname_r (const char *name, char *protocol,
   internal_nis_endservent (&data);
 
   if (!found && status == NSS_STATUS_SUCCESS)
-    return NSS_STATUS_NOTFOUND;
+    {
+      *errnop = ENOENT;
+      return NSS_STATUS_NOTFOUND;
+    }
   else
     return status;
 }
@@ -270,7 +276,10 @@ _nss_nis_getservbyport_r (int port, char *protocol, struct servent *serv,
   internal_nis_endservent (&data);
 
   if (!found && status == NSS_STATUS_SUCCESS)
-    return NSS_STATUS_NOTFOUND;
+    {
+      *errnop = ENOENT;
+      return NSS_STATUS_NOTFOUND;
+    }
   else
     return status;
 }
diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c
index 452f91dc0b..37ea2f9dbf 100644
--- a/nis/nss_nis/nis-spwd.c
+++ b/nis/nss_nis/nis-spwd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
 
@@ -104,7 +104,9 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen,
 
       if (retval != NSS_STATUS_SUCCESS)
         {
-          if (retval == NSS_STATUS_TRYAGAIN)
+          if (retval == NSS_STATUS_NOTFOUND)
+	    *errnop = ENOENT;
+	  else if (retval == NSS_STATUS_TRYAGAIN)
 	    *errnop = errno;
           return retval;
         }
@@ -178,7 +180,9 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp,
 
   if (retval != NSS_STATUS_SUCCESS)
     {
-      if (retval == NSS_STATUS_TRYAGAIN)
+      if (retval == NSS_STATUS_NOTFOUND)
+	*errnop = ENOENT;
+      else if (retval == NSS_STATUS_TRYAGAIN)
 	*errnop = errno;
       return retval;
     }
@@ -202,7 +206,10 @@ _nss_nis_getspnam_r (const char *name, struct spwd *sp,
       if (parse_res == -1)
 	return NSS_STATUS_TRYAGAIN;
       else
-	return NSS_STATUS_NOTFOUND;
+	{
+	  *errnop = ENOENT;
+	  return NSS_STATUS_NOTFOUND;
+	}
     }
   return NSS_STATUS_SUCCESS;
 }