Rework Ilia's changes in check_host().

merge-requests/1/head
Julien BLACHE 2009-03-13 08:59:31 +00:00
rodzic 7a359270a2
commit 9cdf75633d
2 zmienionych plików z 40 dodań i 33 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
2009-03-13 Julien Blache <jb@jblache.org> 2009-03-13 Julien Blache <jb@jblache.org>
* doc/descriptions-external/epkowa.desc: update for iScan 2.18.0, * doc/descriptions-external/epkowa.desc: update for iScan 2.18.0,
from Olaf Meeuwissen. from Olaf Meeuwissen.
* frontend/saned.c: rework Ilia's changes in check_host().
2009-03-12 Ilia Sotnikov <hostcc@gmail.com> 2009-03-12 Ilia Sotnikov <hostcc@gmail.com>
* frontend/saned.c: * frontend/saned.c:

Wyświetl plik

@ -867,11 +867,13 @@ check_host (int fd)
res = NULL; res = NULL;
err = getaddrinfo (hostname, NULL, &hints, &res); err = getaddrinfo (hostname, NULL, &hints, &res);
/* Proceed if no local name was found */ if (err)
if (err && err != EAI_NONAME)
{ {
DBG (DBG_ERR, "check_host: getaddrinfo failed: %s\n", DBG (DBG_ERR, "check_host: getaddrinfo for local hostname failed: %s\n",
gai_strerror (err)); gai_strerror (err));
/* Proceed even if the local hostname does not resolve */
if (err != EAI_NONAME)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
else else
@ -1168,19 +1170,22 @@ check_host (int fd)
/* Get local address */ /* Get local address */
he = gethostbyname (hostname); he = gethostbyname (hostname);
/* Proceed if no local name was found */
if (!he && h_errno != HOST_NOT_FOUND) if (!he)
{ {
DBG (DBG_ERR, "check_host: gethostbyname failed: %s\n", DBG (DBG_ERR, "check_host: gethostbyname for local hostname failed: %s\n",
hstrerror (h_errno)); hstrerror (h_errno));
/* Proceed even if the local hostname doesn't resolve */
if (h_errno != HOST_NOT_FOUND)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
else
if (he) {
DBG (DBG_DBG, "check_host: local hostname (from DNS): %s\n", DBG (DBG_DBG, "check_host: local hostname (from DNS): %s\n",
he->h_name); he->h_name);
if (he && ((he->h_length == 4) || he->h_addrtype == AF_INET)) if ((he->h_length == 4) || (he->h_addrtype == AF_INET))
{ {
if (!inet_ntop (he->h_addrtype, he->h_addr_list[0], text_addr, if (!inet_ntop (he->h_addrtype, he->h_addr_list[0], text_addr,
sizeof (text_addr))) sizeof (text_addr)))
@ -1203,6 +1208,7 @@ check_host (int fd)
DBG (DBG_DBG, DBG (DBG_DBG,
"check_host: remote host doesn't have same addr as local\n"); "check_host: remote host doesn't have same addr as local\n");
}
/* must be a remote host: check contents of PATH_NET_CONFIG or /* must be a remote host: check contents of PATH_NET_CONFIG or
/etc/hosts.equiv if former doesn't exist: */ /etc/hosts.equiv if former doesn't exist: */