On 19.04.2006, at 16:31, Vlad Seryakov wrote:
So, it is logically that reverse DNS is used to get the name.
OK. This makes sense only if there is no hostname assigned
to the nsssock. Because if it is, the reverse-lookup has
absolutely no meaning, and is shooting ourselves in the
foot.
Therefore I'd do that reverse lookup only if no hostname
is defined to nssock, like this below.
Is this OK for everybody?
------------------ driver.c:Ns_DriverInit()
host = Ns_ConfigGetValue(path, "hostname");
bindaddr = address = Ns_ConfigGetValue(path, "address");
defserver = Ns_ConfigGetValue(path, "defaultserver");
/*
* If the listen address was not specified, attempt to determine it
* through a DNS lookup of the specified hostname or the server's
* primary hostname.
*/
if (address == NULL) {
he = gethostbyname(host ? host : Ns_InfoHostname());
/*
* If the lookup suceeded but the resulting hostname does not
* appear to be fully qualified, attempt a reverse lookup on
the
* address which often returns the fully qualified name.
*
* NB: This is a common but sloppy configuration for a Unix
* network.
*/
/*-------- ^^^^^^^^^^^^^^^^ -------*/
if (host == NULL && he != NULL && he->h_name != NULL &&
strchr(he->h_name, '.') == NULL) {
he = gethostbyaddr(he->h_addr_list[0],he->h_length,he-
>h_addrtype);
}
/*
* If the lookup suceeded, use the first address in host
entry list.
*/
if (he == NULL || he->h_name == NULL) {
Ns_Log(Error, "%s: could not resolve %s: %s", module,
host ? host : Ns_InfoHostname(), strerror(errno));
return NS_ERROR;
}
if (*(he->h_addr_list) == NULL) {
Ns_Log(Error, "%s: no addresses for %s", module,
he->h_name);
return NS_ERROR;
}
memcpy(&ia.s_addr, he->h_addr_list[0], sizeof(ia.s_addr));
address = ns_inet_ntoa(ia);
/*
* Finally, if no hostname was specified, set it to the
hostname
* derived from the lookup(s) above.
*/
if (host == NULL) {
host = he->h_name;
}
}