]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
getaddrinfo: Properly set errno for NSS function lookup failure
authorFlorian Weimer <fweimer@redhat.com>
Fri, 1 Sep 2017 06:57:28 +0000 (08:57 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 4 Sep 2017 09:44:21 +0000 (11:44 +0200)
(cherry picked from commit ad816a5e00ce891a2cea8187638fa0e00f83aaf6)

ChangeLog
sysdeps/posix/getaddrinfo.c

index d53c8fe083bc52c66df077deaf9d7daebd385232..2f959d4c36e05f52d1d7e510cb9b763a8e6624fb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-01  Florian Weimer  <fweimer@redhat.com>
+
+       * sysdeps/posix/getaddrinfo.c (gaih_inet): Make reporting of NSS
+       function lookup failures more reliable.
+
 2017-09-01  Florian Weimer  <fweimer@redhat.com>
 
        * sysdeps/posix/getaddrinfo.c (gethosts): Use h_errno directly.
index 076e1fa62bd885487ce63044b1ab000097ae1561..eaf8bafcf4ede5fe30be316c07a97cf5e6ca0178 100644 (file)
@@ -923,13 +923,17 @@ gaih_inet (const char *name, const struct gaih_service *service,
                    }
                  else
                    {
+                     /* Could not locate any of the lookup functions.
+                        The NSS lookup code does not consistently set
+                        errno, so we need to supply our own error
+                        code here.  The root cause could either be a
+                        resource allocation failure, or a missing
+                        service function in the DSO (so it should not
+                        be listed in /etc/nsswitch.conf).  Assume the
+                        former, and return EBUSY.  */
                      status = NSS_STATUS_UNAVAIL;
-                     /* Could not load any of the lookup functions.  Indicate
-                        an internal error if the failure was due to a system
-                        error other than the file not being found.  We use the
-                        errno from the last failed callback.  */
-                     if (errno != 0 && errno != ENOENT)
-                       __set_h_errno (NETDB_INTERNAL);
+                    __set_h_errno (NETDB_INTERNAL);
+                    __set_errno (EBUSY);
                    }
                }