/*
*/
/*
* This module determines the type of socket (datagram, stream), the client
* socket address and port, the server socket address and port. In addition,
* it provides methods to map a transport address to a printable host name
* or address. Socket address information results are in static memory.
*
* The result from the hostname lookup method is STRING_PARANOID when a host
* pretends to have someone elses name, or when a host name is available but
* could not be verified.
*
* When lookup or conversion fails the result is set to STRING_UNKNOWN.
*
* Diagnostics are reported through syslog(3).
*
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
#ifndef lint
#endif
/* System libraries. */
#include <netdb.h>
#include <stdio.h>
#include <syslog.h>
#include <string.h>
extern char *inet_ntoa();
/* Local stuff. */
#include "tcpd.h"
/* Forward declarations. */
static void sock_sink();
#ifdef APPEND_DOT
/*
* Speed up DNS lookups by terminating the host name with a dot. Should be
* done with care. The speedup can give problems with lookups from sources
* that lack DNS-style trailing dot magic, such as local files or NIS maps.
*/
char *name;
int af;
{
/*
* Don't append dots to unqualified names. Such names are likely to come
* from local hosts files or from NIS.
*/
} else {
}
}
#endif
/* sock_host - look up endpoint addresses and install conversion methods */
struct request_info *request;
{
/*
* Look up the client host address. Hal R. Brand <BRAND@addvax.llnl.gov>
* suggested how to get the client host info in case of UDP connections:
* peek at the first message without actually looking at its contents. We
* really should verify that client.sin_family gets the value AF_INET,
* but this program has already caused too much grief on systems with
* broken library code.
*/
tcpd_warn("can't get client address: %m");
return; /* give up */
}
#ifdef really_paranoid
#endif
}
/*
* Determine the server binding. This is used for client username
* lookups, and for access control rules that trigger on the server
* address or name.
*/
tcpd_warn("getsockname: %m");
return;
}
}
/* sock_hostaddr - map endpoint address to printable form */
{
if (sin != 0)
#ifdef HAVE_IPV6
#else
#endif
}
/* sock_hostname - map endpoint address to host name */
{
int i;
int herr;
/*
* On some systems, for example Solaris 2.3, gethostbyaddr(0.0.0.0) does
* not fail. Instead it returns "INADDR_ANY". Unfortunately, this does
* not work the other way around: gethostbyname("INADDR_ANY") fails. We
* have to special-case 0.0.0.0, in order to avoid false alerts from the
*/
if (sin != 0
&& !SG_IS_UNSPECIFIED(sin)
/*
* Verify that the address is a member of the address list returned
* by gethostbyname(hostname).
*
* Verify also that gethostbyaddr() and gethostbyname() return the same
* hostname, or rshd and rlogind may still end up being spoofed.
*
* On some sites, gethostbyname("localhost") returns "localhost.domain".
* This is a DNS artefact. We treat it as a special case. When we
* can't believe the address list from gethostbyname("localhost")
* we're in big trouble anyway.
*/
/*
* Unable to verify that the host name matches the address. This
* may be a transient problem or a botched name server setup.
*/
tcpd_warn("can't verify hostname: gethostbyname(%s) failed",
/*
* The gethostbyaddr() and gethostbyname() calls did not return
* the same hostname. This could be a nameserver configuration
* problem. It could also be that someone is trying to spoof us.
*/
} else {
#ifdef HAVE_IPV6
#endif
/*
* The address should be a member of the address list returned by
* gethostbyname(). We should first verify that the h_addrtype
* field is AF_INET, but this program has already caused too much
* grief on systems with broken library code.
*/
for (i = 0; hp->h_addr_list[i]; i++) {
return; /* name is good, keep it */
}
}
/*
* The host name does not map to the initial address. Perhaps
* someone has messed up. Perhaps someone compromised a name
* server.
*/
#ifdef HAVE_IPV6
#else
#endif
}
}
}
/* sock_sink - absorb unreceived IP datagram */
int fd;
{
/*
* Eat up the not-yet received datagram. Some systems insist on a
* non-zero source address argument in the recvfrom() call below.
*/
}
/*
* If we receive a V4 connection on a V6 socket, we pretend we really
* got a V4 connection.
*/
{
#ifdef HAVE_IPV6
#ifdef IN6_V4MAPPED_TO_INADDR /* Solaris 8 */
#else /* Do it the hard way */
#endif
}
#else
return;
#endif /* HAVE_IPV6 */
}