From 3d04f5db20c8f0d1ba3881b5f5373586a18cf188 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Tue, 21 May 2013 21:54:41 +0530 Subject: Set EAI_SYSTEM only when h_errno is NETDB_INTERNAL Fixes BZ #15339. NSS_STATUS_UNAVAIL may mean that a necessary input resource is not available. This could occur in a number of cases including when the network is down, system runs out of file descriptors, etc. The correct differentiator in such a case is the h_errno, which gives the nature of failure. In case of failures other than a simple 'not found', we set h_errno as NETDB_INTERNAL and let errno be the identifier for the exact error. --- nss/getXXbyYY_r.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nss/getXXbyYY_r.c') diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c index 44d00f4bcf..33e63d4318 100644 --- a/nss/getXXbyYY_r.c +++ b/nss/getXXbyYY_r.c @@ -287,10 +287,10 @@ done: #endif *result = status == NSS_STATUS_SUCCESS ? resbuf : NULL; #ifdef NEED_H_ERRNO - if (status == NSS_STATUS_UNAVAIL) - /* Either we failed to lookup the functions or the functions themselves - had a system error. Set NETDB_INTERNAL here to let the caller know - that the errno may have the real reason for failure. */ + if (status == NSS_STATUS_UNAVAIL && !any_service && errno != ENOENT) + /* This happens when we weren't able to use a service for reasons other + than the module not being found. In such a case, we'd want to tell the + caller that errno has the real reason for failure. */ *h_errnop = NETDB_INTERNAL; else if (status != NSS_STATUS_SUCCESS && !any_service) /* We were not able to use any service. */ -- cgit v1.2.3