kopia lustrzana https://gitlab.com/sane-project/backends
Rework Ilia's changes in check_host().
rodzic
7a359270a2
commit
9cdf75633d
|
@ -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:
|
||||||
|
|
|
@ -867,12 +867,14 @@ 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));
|
||||||
return SANE_STATUS_INVAL;
|
|
||||||
|
/* Proceed even if the local hostname does not resolve */
|
||||||
|
if (err != EAI_NONAME)
|
||||||
|
return SANE_STATUS_INVAL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1168,41 +1170,45 @@ 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));
|
||||||
return SANE_STATUS_INVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (he)
|
/* Proceed even if the local hostname doesn't resolve */
|
||||||
DBG (DBG_DBG, "check_host: local hostname (from DNS): %s\n",
|
if (h_errno != HOST_NOT_FOUND)
|
||||||
he->h_name);
|
return SANE_STATUS_INVAL;
|
||||||
|
|
||||||
if (he && ((he->h_length == 4) || he->h_addrtype == AF_INET))
|
|
||||||
{
|
|
||||||
if (!inet_ntop (he->h_addrtype, he->h_addr_list[0], text_addr,
|
|
||||||
sizeof (text_addr)))
|
|
||||||
strcpy (text_addr, "[error]");
|
|
||||||
DBG (DBG_DBG, "check_host: local host address (from DNS): %s\n",
|
|
||||||
text_addr);
|
|
||||||
if (memcmp (he->h_addr_list[0], &remote_address.s_addr, 4) == 0)
|
|
||||||
{
|
|
||||||
DBG (DBG_MSG,
|
|
||||||
"check_host: remote host has same addr as local: "
|
|
||||||
"access accepted\n");
|
|
||||||
return SANE_STATUS_GOOD;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBG (DBG_ERR, "check_host: can't get local address "
|
DBG (DBG_DBG, "check_host: local hostname (from DNS): %s\n",
|
||||||
"(only IPv4 is supported)\n");
|
he->h_name);
|
||||||
}
|
|
||||||
|
|
||||||
DBG (DBG_DBG,
|
if ((he->h_length == 4) || (he->h_addrtype == AF_INET))
|
||||||
"check_host: remote host doesn't have same addr as local\n");
|
{
|
||||||
|
if (!inet_ntop (he->h_addrtype, he->h_addr_list[0], text_addr,
|
||||||
|
sizeof (text_addr)))
|
||||||
|
strcpy (text_addr, "[error]");
|
||||||
|
DBG (DBG_DBG, "check_host: local host address (from DNS): %s\n",
|
||||||
|
text_addr);
|
||||||
|
if (memcmp (he->h_addr_list[0], &remote_address.s_addr, 4) == 0)
|
||||||
|
{
|
||||||
|
DBG (DBG_MSG,
|
||||||
|
"check_host: remote host has same addr as local: "
|
||||||
|
"access accepted\n");
|
||||||
|
return SANE_STATUS_GOOD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG (DBG_ERR, "check_host: can't get local address "
|
||||||
|
"(only IPv4 is supported)\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG (DBG_DBG,
|
||||||
|
"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: */
|
||||||
|
|
Ładowanie…
Reference in New Issue