You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

362 lines
11 KiB

Index: Makefile
===================================================================
RCS file: /cvs/opkg/vendor_stuff/tcpwrappers/Makefile,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 Makefile
--- Makefile 3 Jan 2003 18:52:40 -0000 1.1.1.1
+++ Makefile 11 Nov 2003 00:18:26 -0000
@@ -128,12 +128,12 @@
386bsd netbsd bsdos:
@make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ= NETGROUP= TLI= \
- EXTRA_CFLAGS=VSYSLOG= all
+ EXTRA_CFLAGS= VSYSLOG= all
freebsd:
@make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ= NETGROUP= TLI= \
- EXTRA_CFLAGS=VSYSLOG= all
+ EXTRA_CFLAGS=-I. VSYSLOG= all
linux:
@make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
@@ -183,11 +183,15 @@
# SunOS 5.x is another SYSV4 variant.
sunos5:
- @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
- LIBS="-lsocket -lnsl" RANLIB=echo ARFLAGS=rv VSYSLOG= \
+ @case `uname -r` in \
+ 5.6) RTLIB="-lposix4";; \
+ *) RTLIB="-lrt";; \
+ esac; \
+ make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
+ LIBS="-lsocket -lnsl $$RTLIB" RANLIB=echo ARFLAGS=rv VSYSLOG= \
NETGROUP=-DNETGROUP AUX_OBJ=setenv.o TLI=-DTLI \
BUGS="$(BUGS)" all \
- EXTRA_CFLAGS=-DNEED_SETENV
+ EXTRA_CFLAGS="-DNEED_SETENV -DNEED_GETOPT"
# Generic SYSV40
esix sysv4:
Index: fix_options.c
===================================================================
RCS file: /cvs/opkg/vendor_stuff/tcpwrappers/fix_options.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 fix_options.c
--- fix_options.c 5 Jan 2003 01:27:10 -0000 1.1.1.1
+++ fix_options.c 11 Nov 2003 00:18:26 -0000
@@ -47,7 +47,14 @@
clean_exit(request);
}
if (ADDR_FAM(&ss) == AF_INET) {
+#if defined(__FreeBSD__) || defined(__sun__)
+ unsigned char optbuf[BUFFER_SIZE / 3];
+ int optlen;
+ struct in_addr dummy;
+ unsigned char *ucp;
+#else
struct ip_opts optbuf;
+#endif
char lbuf[BUFFER_SIZE], *lp, *cp;
struct protoent *ip;
int optsize = sizeof(optbuf);
@@ -65,9 +72,15 @@
* here was wrong.
*/
+#if defined(__FreeBSD__) || defined(__sun__)
+#define ADDR_LEN sizeof(dummy.s_addr)
+ for (ucp = optbuf + ADDR_LEN; ucp < optbuf + optsize; ucp += optlen) {
+ u_char c = ucp[IPOPT_OPTVAL];
+#else
for (i = 0; (void *)&optbuf.ip_opts[i] - (void *)&optbuf <
optsize; ) {
u_char c = (u_char)optbuf.ip_opts[i];
+#endif
if (c == IPOPT_LSRR || c == IPOPT_SSRR) {
syslog(LOG_WARNING,
"refused connect from %s with IP source routing options",
@@ -77,7 +90,17 @@
}
if (c == IPOPT_EOL)
break;
+#if defined(__FreeBSD__) || defined(__sun__)
+ if (c == IPOPT_NOP)
+ optlen = 1;
+ else {
+ optlen = cp[IPOPT_OLEN];
+ if (optlen <= 0) /* Do not loop! */
+ break;
+ }
+#else
i += (c == IPOPT_NOP) ? 1 : (u_char)optbuf.ip_opts[i+1];
+#endif
}
lp = lbuf;
Index: tli.c
===================================================================
RCS file: /cvs/opkg/vendor_stuff/tcpwrappers/tli.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 tli.c
--- tli.c 2 Sep 2002 12:47:03 -0000 1.1.1.1
+++ tli.c 11 Nov 2003 00:18:26 -0000
@@ -77,13 +77,13 @@
tli_endpoints(request);
if ((request->config = tli_transport(request->fd)) != 0
&& STR_EQ(request->config->nc_protofmly, "inet")) {
- if (request->client->unit != 0) {
- client = *(struct sockaddr_in *) request->client->unit->addr.buf;
- request->client->sin = &client;
+ if (request->client.unit != 0) {
+ client = *(struct sockaddr_in *) request->client.unit->addr.buf;
+ request->client.au.sa_in = client;
}
- if (request->server->unit != 0) {
- server = *(struct sockaddr_in *) request->server->unit->addr.buf;
- request->server->sin = &server;
+ if (request->server.unit != 0) {
+ server = *(struct sockaddr_in *) request->server.unit->addr.buf;
+ request->server.au.sa_in = server;
}
tli_cleanup(request);
sock_methods(request);
@@ -100,10 +100,10 @@
{
if (request->config != 0)
freenetconfigent(request->config);
- if (request->client->unit != 0)
- t_free((char *) request->client->unit, T_UNITDATA);
- if (request->server->unit != 0)
- t_free((char *) request->server->unit, T_UNITDATA);
+ if (request->client.unit != 0)
+ t_free((char *) request->client.unit, T_UNITDATA);
+ if (request->server.unit != 0)
+ t_free((char *) request->server.unit, T_UNITDATA);
}
/* tli_endpoints - determine TLI client and server endpoint information */
@@ -140,7 +140,7 @@
return;
}
}
- request->client->unit = client;
+ request->client.unit = client;
/*
* Look up the server endpoint address. This can be used for filtering on
@@ -156,7 +156,7 @@
t_free((void *) server, T_UNITDATA);
return;
}
- request->server->unit = server;
+ request->server.unit = server;
}
/* tli_transport - find out TLI transport type */
--- socket.c.orig 2003-03-10 11:05:21.000000000 -0500
+++ socket.c 2004-03-19 13:57:56.518575000 -0500
@@ -39,9 +39,9 @@
static void sock_sink(int);
/*
- * tcpd_sock_host - look up endpoint addresses and install conversion methods
+ * sock_host - look up endpoint addresses and install conversion methods
*/
-void tcpd_sock_host(struct request_info *request)
+void sock_host(struct request_info *request)
{
int len;
char buf[BUFSIZ];
@@ -135,17 +135,31 @@
sizeof(host->name), 0, 0, NI_NAMEREQD | NI_NOFQDN) == 0)
{
struct addrinfo hints, *res, *ressave;
+ struct in_addr v4addr;
int ret_val;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_socktype = SOCK_STREAM;
- hints.ai_family = ADDR_FAM(tsa);
+ if (ADDR_FAM(tsa) == AF_INET)
+ {
+ hints.ai_family = AF_INET;
+ memcpy(&v4addr, &SAIN(tsa)->sin_addr, sizeof(struct in_addr));
+ }
+ else /* only AF_INET6 left, currently */
+ {
+ if (IN6_IS_ADDR_V4MAPPED(&tsa->sa_in6.sin6_addr)) {
+ IN6_V4MAPPED_TO_INADDR(&tsa->sa_in6.sin6_addr, &v4addr);
+ hints.ai_family = AF_INET;
+ }
+ else
+ hints.ai_family = AF_INET6;
+ }
/*
* And then a forward lookup on what was returned.
*/
- if( (ret_val = getaddrinfo(host->name, NULL, &hints, &res)) < 0 )
+ if( (ret_val = getaddrinfo(host->name, NULL, &hints, &res)) != 0 )
{
tcpd_warn("can't verify hostname: getaddrinfo(%s) failed - %s",
host->name, gai_strerror(ret_val));
@@ -185,11 +199,14 @@
*/
while (res)
{
- if (tsa->sa.sa_family != res->ai_family)
- continue;
+ if (res->ai_family != hints.ai_family) {
+ /* can this happen ??? */
+ res = res->ai_next;
+ continue;
+ }
if (res->ai_family == AF_INET)
{
- if (memcmp(&SAIN(tsa)->sin_addr,
+ if (memcmp(&v4addr,
&SAIN(res->ai_addr)->sin_addr,
sizeof(struct in_addr)) == 0)
{
--- fromhost.c.orig 2002-12-23 12:45:44.000000000 -0500
+++ fromhost.c 2004-03-19 14:21:18.786257000 -0500
@@ -44,7 +44,7 @@
if (ioctl(request->fd, I_FIND, "timod") > 0) {
tli_host(request);
} else {
- tcpd_sock_host(request);
+ sock_host(request);
}
}
--- namespace.h.orig 2002-12-23 12:55:57.000000000 -0500
+++ namespace.h 2004-03-29 15:03:24.885659000 -0500
@@ -39,6 +39,7 @@
#define percent_x tcpd_percent_x
#define rfc931 tcpd_rfc931
#define shell_cmd tcpd_shell_cmd
+#define sock_host tcpd_sock_host
#define sock_hostaddr tcpd_sock_hostaddr
#define sock_hostname tcpd_sock_hostname
#define tli_host tcpd_tli_host
@@ -47,4 +48,10 @@
#endif
+#ifdef NEED_SETENV
+
+#define setenv my_setenv
+
+#endif
+
#endif
--- internal.h.orig 2003-01-04 18:37:53.000000000 -0500
+++ internal.h 2004-03-23 12:46:22.000000000 -0500
@@ -7,6 +7,7 @@
#ifndef IMPL_HEADER
#define IMPL_HEADER
+#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <string.h>
@@ -20,6 +21,12 @@
#define SAIN6( p ) ( (struct sockaddr_in6 *) (p) )
#define ADDR_FAM( p ) ( (p)->sa.sa_family )
+/* Convert IPv4 address that was mapped to an IPv6 address back to IPv4 */
+#ifndef IN6_V4MAPPED_TO_INADDR
+#define IN6_V4MAPPED_TO_INADDR(v6, v4) \
+ memcpy(v4, ((char *)v6) + 12, sizeof(struct in_addr));
+#endif
+
/* Common string operations. Less clutter should be more readable. */
#define STRN_CPY(d,s,l) { strncpy((d),(s),(l)); (d)[(l)-1] = 0; }
@@ -106,7 +113,7 @@
/* Socket-specific methods, including DNS hostname lookups. */
#if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
-extern void tcpd_sock_host(struct request_info *);/* look up endpoint addr'es */
+extern void sock_host(struct request_info *);/* look up endpoint addr'es */
#endif
extern void sock_hostname(struct host_info *);/* xlate address to hostname */
extern void sock_hostaddr(struct host_info *);/* address to printable address */
--- ptx.c.orig 2002-12-23 12:46:22.000000000 -0500
+++ ptx.c 2004-03-23 12:50:51.000000000 -0500
@@ -70,7 +70,7 @@
if (SWAP_MODULE(request->fd, "timod", "sockmod") != 0)
tcpd_warn("replace timod by sockmod: %m");
- tcpd_sock_host(request);
+ sock_host(request);
if (SWAP_MODULE(request->fd, "sockmod", "timod") != 0)
tcpd_warn("replace sockmod by timod: %m");
if (request->sink != 0)
Index: tcpd.h
--- tcpd.h.orig 2003-01-05 02:15:59.000000000 +0100
+++ tcpd.h 2005-08-21 17:25:37.751541000 +0200
@@ -7,12 +7,14 @@
#ifndef TCP_WRAPPERS_HEADER
#define TCP_WRAPPERS_HEADER
+#include <sys/types.h>
+#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define TCPD_STRING_LENGTH 256 /* hosts, users, processes */
-#ifdef cplusplus
+#ifdef __cplusplus
extern "C" {
#endif
@@ -70,8 +72,8 @@
#if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
void fromhost(struct request_info *); /* get/validate client host info */
#else
-#define fromhost tcpd_sock_host /* no TLI support needed */
-extern void tcpd_sock_host(struct request_info *);/* look up endpoint addr'es */
+#define fromhost sock_host /* no TLI support needed */
+extern void sock_host(struct request_info *);/* look up endpoint addr'es */
#endif
/*
@@ -98,7 +100,7 @@
RQ_SERVER_ADDR /* server host address */
};
-#ifdef cplusplus
+#ifdef __cplusplus
}
#endif
Index: rfc931.c
--- rfc931.c.orig 2003-03-10 21:57:13 +0100
+++ rfc931.c 2005-10-14 20:04:35 +0200
@@ -36,6 +36,8 @@
#define RFC931_BUFSZ 512
#define SA_PORT(s) ADDR_FAM(s) == AF_INET ? \
(s)->sa_in.sin_port : (s)->sa_in6.sin6_port
+#define SA_PORT_SET(s,v) if (ADDR_FAM(s) == AF_INET) \
+ (s)->sa_in.sin_port = (v); else (s)->sa_in6.sin6_port = (v)
int rfc931_timeout = RFC931_TIMEOUT;
static int safe_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
@@ -98,10 +100,10 @@
* addresses from the query socket.
*/
memcpy(&our_query, our_sa, sizeof(our_query));
- SA_PORT(&our_query) = htons(ANY_PORT);
+ SA_PORT_SET(&our_query, htons(ANY_PORT));
memcpy(&rmt_query, rmt_sa, sizeof(rmt_query));
- SA_PORT(&rmt_query) = htons(RFC931_PORT);
+ SA_PORT_SET(&rmt_query, htons(RFC931_PORT));
do {
ret_val = bind(sock, &our_query.sa, sizeof(our_query.sa));