autofs-5.0.3 - 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 | 15 +++++++++++----
modules/replicated.c | 6 ++++--
2 files changed, 15 insertions(+), 6 deletions(-)
--- autofs-5.0.3.orig/lib/rpc_subs.c
+++ autofs-5.0.3/lib/rpc_subs.c
@@ -98,8 +98,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);
goto out_close;
}
@@ -306,9 +309,13 @@ static CLIENT *create_tcp_client(struct
ret = gethostbyname_r(info->host, php,
buf, HOST_ENT_BUF_SIZE, &result, &ghn_errno);
+ error(LOGOPT_ANY, "ret %d result %p", ret, result);
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);
goto out_close;
}
--- autofs-5.0.3.orig/modules/replicated.c
+++ autofs-5.0.3/modules/replicated.c
@@ -984,10 +984,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;
}