/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* tli_host() determines the type of transport (connected, connectionless),
* the transport address of a client host, and the transport address of a
* server endpoint. In addition, it provides methods to map a transport
* address to a printable host name or address. Socket address results are
* in static memory; tli structures are allocated from the heap.
*
* 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.
*
* Diagnostics are reported through syslog(3).
*
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
#ifndef lint
#endif
#ifdef TLI
/* System libraries. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <errno.h>
#include <netconfig.h>
#include <netdir.h>
#include <string.h>
extern char *nc_sperror();
extern int errno;
extern char *sys_errlist[];
extern int sys_nerr;
extern int t_errno;
extern char *t_errlist[];
extern int t_nerr;
/* Local stuff. */
#include "tcpd.h"
/* Forward declarations. */
static void tli_endpoints();
static struct netconfig *tli_transport();
static void tli_hostname();
static void tli_hostaddr();
static void tli_cleanup();
static char *tli_error();
static void tli_sink();
/* tli_host - look up endpoint addresses and install conversion methods */
struct request_info *request;
{
/*
* If we discover that we are using an IP transport, pretend we never
* were here. Otherwise, use the transport-independent method and stick
* to generic network addresses. XXX hard-coded protocol family name.
*/
#ifdef HAVE_IPV6
#endif
)) {
SGSOCKADDRSZ((struct sockaddr_gen*)
}
SGSOCKADDRSZ((struct sockaddr_gen*)
}
} else {
}
}
/* tli_cleanup - cleanup some dynamically-allocated data structures */
struct request_info *request;
{
}
/* tli_endpoints - determine TLI client and server endpoint information */
struct request_info *request;
{
int flags;
/*
* Determine the client endpoint address. With unconnected services, peek
* at the sender address of the pending protocol data unit without
* popping it off the receive queue. This trick works because only the
* address member of the unitdata structure has been allocated.
*
* Beware of successful returns with zero-length netbufs (for example,
* Solaris 2.3 with ticlts transport). The netdir(3) routines can't
* handle that. Assume connection-less transport when TI_GETPEERNAME
* produces no usable result, even when t_rcvudata() is unable to figure
* out the peer address. Better to hang than to loop.
*/
return;
}
return;
}
}
/*
* Look up the server endpoint address. This can be used for filtering on
* server address or name, or to look up the client user.
*/
return;
}
tcpd_warn("TI_GETMYNAME: %m");
return;
}
}
/* tli_transport - find out TLI transport type */
int fd;
{
void *handlep;
/*
* Assuming that the network device is a clone device, we must compare
* the major device number of stdin to the minor device number of the
* devices listed in the netconfig table.
*/
return (0);
}
if ((handlep = setnetconfig()) == 0) {
tcpd_warn("setnetconfig: %m");
return (0);
}
/* XXX: Solaris 8 no longer has clone devices for IP */
break;
}
}
if (config == 0) {
tcpd_warn("unable to identify transport protocol");
return (0);
}
/*
* Something else may clobber our getnetconfig() result, so we'd better
* acquire our private copy.
*/
return (0);
}
return (config);
}
/* tli_hostaddr - map TLI transport address to printable address */
{
char *uaddr;
}
}
/* tli_hostname - map TLI transport address to hostname */
{
int found = 0;
/*
* Unable to verify that the name matches the address. This may
* be a transient problem or a botched name server setup. We
* decide to play safe.
*/
tcpd_warn("can't verify hostname: netdir_getbyname(%.*s) failed",
} else {
/*
* Look up the host address in the address list we just got. The
* comparison is done on the textual representation, because the
* transport address is an opaque structure that may have holes
* with uninitialized garbage. This approach obviously loses when
* the address does not have a textual representation.
*/
char *ua;
int i;
}
}
/*
* When the host name does not map to the initial address, assume
* someone has compromised a name server. More likely someone
* botched it, but that could be dangerous, too.
*/
if (found == 0)
}
}
}
/* tli_error - convert tli error number to text */
static char *tli_error()
{
return (buf);
} else {
}
} else {
return (buf);
} else {
return (sys_errlist[errno]);
}
}
}
/* tli_sink - absorb unreceived datagram */
int fd;
{
int flags;
/*
* Something went wrong. Absorb the datagram to keep inetd from looping.
* Allocate storage for address, control and data. If that fails, sleep
* for a couple of seconds in an attempt to keep inetd from looping too
* fast.
*/
sleep(5);
} else {
}
}
#endif /* TLI */