Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 102

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

autofs-5.0.1 - fix incorrect host name lookup error message

From: Masatake YAMATO <yamato@redhat.com>

When an error occurs looking up a hostname autofs fails to use the
correct error number to error string translation function.
---
 lib/rpc_subs.c       |   14 ++++++++++----
 modules/replicated.c |    6 ++++--
 2 files changed, 14 insertions(+), 6 deletions(-)

--- autofs-5.0.1.orig/lib/rpc_subs.c
+++ autofs-5.0.1/lib/rpc_subs.c
@@ -93,8 +93,11 @@ static CLIENT *create_udp_client(struct 
 	ret = gethostbyname_r(info->host, php,
 			buf, HOST_ENT_BUF_SIZE, &result, &ghn_errno);
 	if (ret || !result) {
-		int err = ghn_errno == -1 ? errno : ghn_errno;
-		char *estr = strerror_r(err, buf, HOST_ENT_BUF_SIZE);
+		char *estr;
+		if (ghn_errno == -1)
+			estr = strerror_r(errno, buf, HOST_ENT_BUF_SIZE);
+		else
+			estr = (char *) hstrerror(ghn_errno);
 		logerr("hostname lookup failed: %s", estr);
 		info->client = NULL;
 		goto out_close;
@@ -323,8 +326,11 @@ static CLIENT *create_tcp_client(struct 
 	ret = gethostbyname_r(info->host, php,
 			buf, HOST_ENT_BUF_SIZE, &result, &ghn_errno);
 	if (ret || !result) {
-		int err = ghn_errno == -1 ? errno : ghn_errno;
-		char *estr =  strerror_r(err, buf, HOST_ENT_BUF_SIZE);
+		char *estr;
+		if (ghn_errno == -1)
+			estr =  strerror_r(errno, buf, HOST_ENT_BUF_SIZE);
+		else
+			estr = (char *) hstrerror(ghn_errno);
 		logerr("hostname lookup failed: %s", estr);
 		info->client = NULL;
 		goto out_close;
--- autofs-5.0.1.orig/modules/replicated.c
+++ autofs-5.0.1/modules/replicated.c
@@ -991,10 +991,12 @@ static int add_host_addrs(struct host **
 	ret = gethostbyname_r(host, phe,
 			buf, MAX_IFC_BUF, &result, &ghn_errno);
 	if (ret || !result) {
+		char *estr;
 		if (ghn_errno == -1)
-			logmsg("host %s: lookup failure %d", host, errno);
+			estr =  strerror_r(errno, buf, HOST_ENT_BUF_SIZE);
 		else
-			logmsg("host %s: lookup failure %d", host, ghn_errno);
+			estr = (char *) hstrerror(ghn_errno);
+		logerr("hostname lookup failed: %s", estr);
 		return 0;
 	}