ce426f
commit 3d04f5db20c8f0d1ba3881b5f5373586a18cf188
ce426f
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
ce426f
Date:   Tue May 21 21:54:41 2013 +0530
ce426f
ce426f
    Set EAI_SYSTEM only when h_errno is NETDB_INTERNAL
ce426f
    
ce426f
    Fixes BZ #15339.
ce426f
    
ce426f
    NSS_STATUS_UNAVAIL may mean that a necessary input resource is not
ce426f
    available.  This could occur in a number of cases including when the
ce426f
    network is down, system runs out of file descriptors, etc.  The
ce426f
    correct differentiator in such a case is the h_errno, which gives the
ce426f
    nature of failure.  In case of failures other than a simple 'not
ce426f
    found', we set h_errno as NETDB_INTERNAL and let errno be the
ce426f
    identifier for the exact error.
ce426f
ce426f
diff --git glibc-2.17-c758a686/nss/getXXbyYY_r.c glibc-2.17-c758a686/nss/getXXbyYY_r.c
ce426f
index 44d00f4..33e63d4 100644
ce426f
--- glibc-2.17-c758a686/nss/getXXbyYY_r.c
ce426f
+++ glibc-2.17-c758a686/nss/getXXbyYY_r.c
ce426f
@@ -287,10 +287,10 @@ done:
ce426f
 #endif
ce426f
   *result = status == NSS_STATUS_SUCCESS ? resbuf : NULL;
ce426f
 #ifdef NEED_H_ERRNO
ce426f
-  if (status == NSS_STATUS_UNAVAIL)
ce426f
-    /* Either we failed to lookup the functions or the functions themselves
ce426f
-       had a system error.  Set NETDB_INTERNAL here to let the caller know
ce426f
-       that the errno may have the real reason for failure.  */
ce426f
+  if (status == NSS_STATUS_UNAVAIL && !any_service && errno != ENOENT)
ce426f
+    /* This happens when we weren't able to use a service for reasons other
ce426f
+       than the module not being found.  In such a case, we'd want to tell the
ce426f
+       caller that errno has the real reason for failure.  */
ce426f
       *h_errnop = NETDB_INTERNAL;
ce426f
   else if (status != NSS_STATUS_SUCCESS && !any_service)
ce426f
     /* We were not able to use any service.  */
ce426f
diff --git glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
ce426f
index ab135ad..7bb3ded 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
ce426f
+++ glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
ce426f
@@ -1036,7 +1036,15 @@ gaih_inet (const char *name, const struct gaih_service *service,
ce426f
 			}
ce426f
 		    }
ce426f
 		  else
ce426f
-		    status = NSS_STATUS_UNAVAIL;
ce426f
+		    {
ce426f
+		      status = NSS_STATUS_UNAVAIL;
ce426f
+		      /* Could not load any of the lookup functions.  Indicate
ce426f
+		         an internal error if the failure was due to a system
ce426f
+			 error other than the file not being found.  We use the
ce426f
+			 errno from the last failed callback.  */
ce426f
+		      if (errno != 0 && errno != ENOENT)
ce426f
+			__set_h_errno (NETDB_INTERNAL);
ce426f
+		    }
ce426f
 		}
ce426f
 
ce426f
 	      if (nss_next_action (nip, status) == NSS_ACTION_RETURN)
ce426f
@@ -1050,7 +1058,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
ce426f
 
ce426f
 	  _res.options |= old_res_options & RES_USE_INET6;
ce426f
 
ce426f
-	  if (status == NSS_STATUS_UNAVAIL)
ce426f
+	  if (h_errno == NETDB_INTERNAL)
ce426f
 	    {
ce426f
 	      result = GAIH_OKIFUNSPEC | -EAI_SYSTEM;
ce426f
 	      goto free_and_return;
ce426f
_______________________________________________
ce426f
glibc mailing list
ce426f
glibc@lists.fedoraproject.org
ce426f
https://admin.fedoraproject.org/mailman/listinfo/glibc