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