]> git.pld-linux.org Git - packages/tcp_wrappers.git/blame - tcp_wrappers-usagi-ipv6.patch
- rediffed
[packages/tcp_wrappers.git] / tcp_wrappers-usagi-ipv6.patch
CommitLineData
eff8c399
JR
1Index: Makefile
2===================================================================
3RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/Makefile,v
4retrieving revision 1.1.1.1
5retrieving revision 1.2
6diff -u -r1.1.1.1 -r1.2
7--- Makefile 2001/03/02 09:26:27 1.1.1.1
8+++ Makefile 2001/03/02 09:30:19 1.2
9@@ -21,7 +21,7 @@
10 @echo " dynix epix esix freebsd hpux irix4 irix5 irix6 isc iunix"
11 @echo " linux machten mips(untested) ncrsvr4 netbsd next osf power_unix_211"
12 @echo " ptx-2.x ptx-generic pyramid sco sco-nis sco-od2 sco-os5 sinix sunos4"
13- @echo " sunos40 sunos5 sysv4 tandem ultrix unicos7 unicos8 unixware1 unixware2"
14+ @echo " sunos40 sunos5 solaris8 sysv4 tandem ultrix unicos7 unicos8 unixware1 unixware2"
15 @echo " uts215 uxp"
16 @echo
17 @echo "If none of these match your environment, edit the system"
18@@ -131,20 +131,33 @@
19 NETGROUP=-DNETGROUP TLI= SYSTYPE="-systype bsd43" all
20
21 # Freebsd and linux by default have no NIS.
22-386bsd netbsd bsdos:
23+386bsd bsdos:
24 @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
25 LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ= NETGROUP= TLI= \
26 EXTRA_CFLAGS=-DSYS_ERRLIST_DEFINED VSYSLOG= all
27
28 freebsd:
29 @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
30+ LIBS="-L/usr/local/v6/lib -linet6" \
31 LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ= NETGROUP= TLI= \
32- EXTRA_CFLAGS=-DSYS_ERRLIST_DEFINED VSYSLOG= all
33+ EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DINET6 -Dss_family=__ss_family -Dss_len=__ss_len" \
34+ VSYSLOG= all
35+
36+netbsd:
37+ @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
38+ LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ= NETGROUP= TLI= \
39+ EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DINET6 -Dss_family=__ss_family -Dss_len=__ss_len" VSYSLOG= all
40
41 linux:
42 @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
43 LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ=setenv.o \
44- NETGROUP= TLI= EXTRA_CFLAGS="-DBROKEN_SO_LINGER" all
45+ NETGROUP= TLI= EXTRA_CFLAGS="-DBROKEN_SO_LINGER -DINET6=1 -Dss_family=__ss_family -Dss_len=__ss_len" all
46+
47+linux-old:
48+ @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
49+ LIBS="/usr/inet6/lib/libinet6.a -lresolv" \
50+ RANLIB=ranlib ARFLAGS=rv AUX_OBJ=setenv.o NETGROUP= TLI= \
51+ EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DBROKEN_SO_LINGER -DINET6=1 -Dss_family=sin6_family -Dsockaddr_storage=sockaddr_in6 -I/usr/inet6/include" all
52
53 # This is good for many SYSV+BSD hybrids with NIS, probably also for HP-UX 7.x.
54 hpux hpux8 hpux9 hpux10:
55@@ -196,6 +209,13 @@
56 NETGROUP=-DNETGROUP AUX_OBJ=setenv.o TLI=-DTLI \
57 BUGS="$(BUGS) -DSOLARIS_24_GETHOSTBYNAME_BUG" all
58
59+# SunOS 5.8 is another SYSV4 variant, but has IPv6 support
60+solaris8:
61+ @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
62+ LIBS="-lsocket -lnsl" RANLIB=echo ARFLAGS=rv VSYSLOG= \
63+ NETGROUP=-DNETGROUP AUX_OBJ=setenv.o TLI=-DTLI \
64+ EXTRA_CFLAGS="-DINET6 -DNO_CLONE_DEVICE -DINT32_T" all
65+
66 # Generic SYSV40
67 esix sysv4:
68 @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
69@@ -391,7 +411,7 @@
70 # the ones provided with this source distribution. The environ.c module
71 # implements setenv(), getenv(), and putenv().
72
73-AUX_OBJ= setenv.o
74+#AUX_OBJ= setenv.o
75 #AUX_OBJ= environ.o
76 #AUX_OBJ= environ.o strcasecmp.o
77
78@@ -454,7 +474,7 @@
79 # host name aliases. Compile with -DSOLARIS_24_GETHOSTBYNAME_BUG to work
80 # around this. The workaround does no harm on other Solaris versions.
81
82-BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DLIBC_CALLS_STRTOK
83+#BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DLIBC_CALLS_STRTOK
84 #BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DINET_ADDR_BUG
85 #BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DSOLARIS_24_GETHOSTBYNAME_BUG
86
87@@ -472,7 +492,7 @@
88 # If your system supports vsyslog(), comment out the following definition.
89 # If in doubt leave it in, it won't harm.
90
91-VSYSLOG = -Dvsyslog=myvsyslog
92+#VSYSLOG = -Dvsyslog=myvsyslog
93
94 # End of the system dependencies.
95 #################################
96Index: fix_options.c
97===================================================================
98RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/fix_options.c,v
99retrieving revision 1.1.1.1
100retrieving revision 1.2
101diff -u -r1.1.1.1 -r1.2
102--- fix_options.c 2001/03/02 09:26:27 1.1.1.1
103+++ fix_options.c 2001/03/02 09:30:19 1.2
104@@ -11,6 +11,9 @@
105
106 #include <sys/types.h>
107 #include <sys/param.h>
108+#ifdef INET6
109+#include <sys/socket.h>
110+#endif
111 #include <netinet/in.h>
112 #include <netinet/in_systm.h>
113 #include <netinet/ip.h>
114@@ -41,6 +44,22 @@
115 unsigned int opt;
116 int optlen;
117 struct in_addr dummy;
118+#ifdef INET6
119+ struct sockaddr_storage ss;
120+ int sslen;
121+
122+ /*
123+ * check if this is AF_INET socket
124+ * XXX IPv6 support?
125+ */
126+ sslen = sizeof(ss);
127+ if (getsockname(fd, (struct sockaddr *)&ss, &sslen) < 0) {
128+ syslog(LOG_ERR, "getpeername: %m");
129+ clean_exit(request);
130+ }
131+ if (ss.ss_family != AF_INET)
132+ return;
133+#endif
134
135 if ((ip = getprotobyname("ip")) != 0)
136 ipproto = ip->p_proto;
137Index: hosts_access.5
138===================================================================
139RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/hosts_access.5,v
140retrieving revision 1.1.1.1
141retrieving revision 1.2
142diff -u -r1.1.1.1 -r1.2
143--- hosts_access.5 2001/03/02 09:26:27 1.1.1.1
144+++ hosts_access.5 2001/03/02 09:30:19 1.2
145@@ -85,10 +85,17 @@
146 for daemon process names or for client user names.
147 .IP \(bu
148 An expression of the form `n.n.n.n/m.m.m.m\' is interpreted as a
149-`net/mask\' pair. A host address is matched if `net\' is equal to the
150+`net/mask\' pair. An IPv4 host address is matched if `net\' is equal to the
151 bitwise AND of the address and the `mask\'. For example, the net/mask
152 pattern `131.155.72.0/255.255.254.0\' matches every address in the
153 range `131.155.72.0\' through `131.155.73.255\'.
154+.IP \(bu
155+An expression of the form `[n:n:n:n:n:n:n:n]/m\' is interpreted as a
156+`[net]/prefixlen\' pair. An IPv6 host address is matched if
157+`prefixlen\' bits of `net\' is equal to the `prefixlen\' bits of the
158+address. For example, the [net]/prefixlen pattern
159+`[3ffe:505:2:1::]/64\' matches every address in the range
160+`3ffe:505:2:1::\' through `3ffe:505:2:1:ffff:ffff:ffff:ffff\'.
161 .SH WILDCARDS
162 The access control language supports explicit wildcards:
163 .IP ALL
164Index: hosts_access.c
165===================================================================
166RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/hosts_access.c,v
167retrieving revision 1.1.1.1
168retrieving revision 1.2
169diff -u -r1.1.1.1 -r1.2
170--- hosts_access.c 2001/03/02 09:26:27 1.1.1.1
171+++ hosts_access.c 2001/03/02 09:30:19 1.2
172@@ -24,7 +24,13 @@
173 /* System libraries. */
174
175 #include <sys/types.h>
176+#ifdef INT32_T
177+ typedef uint32_t u_int32_t;
178+#endif
179 #include <sys/param.h>
180+#ifdef INET6
181+#include <sys/socket.h>
182+#endif
183 #include <netinet/in.h>
184 #include <arpa/inet.h>
185 #include <stdio.h>
186@@ -33,6 +39,9 @@
187 #include <errno.h>
188 #include <setjmp.h>
189 #include <string.h>
190+#ifdef INET6
191+#include <netdb.h>
192+#endif
193
194 extern char *fgets();
195 extern int errno;
196@@ -82,6 +91,10 @@
197 static int host_match();
198 static int string_match();
199 static int masked_match();
200+#ifdef INET6
201+static int masked_match4();
202+static int masked_match6();
203+#endif
204
205 /* Size of logical line buffer. */
206
207@@ -289,6 +302,13 @@
208 {
209 int n;
210
211+#ifdef INET6
212+ /* convert IPv4 mapped IPv6 address to IPv4 address */
213+ if (STRN_EQ(string, "::ffff:", 7)
214+ && dot_quad_addr(string + 7) != INADDR_NONE) {
215+ string += 7;
216+ }
217+#endif
218 if (tok[0] == '.') { /* suffix */
219 n = strlen(string) - strlen(tok);
220 return (n > 0 && STR_EQ(tok, string + n));
221@@ -299,20 +319,72 @@
222 } else if (tok[(n = strlen(tok)) - 1] == '.') { /* prefix */
223 return (STRN_EQ(tok, string, n));
224 } else { /* exact match */
225+#ifdef INET6
226+ struct addrinfo hints, *res;
227+ struct sockaddr_in6 pat, addr;
228+ int len, ret;
229+ char ch;
230+
231+ len = strlen(tok);
232+ if (*tok == '[' && tok[len - 1] == ']') {
233+ ch = tok[len - 1];
234+ tok[len - 1] = '\0';
235+ memset(&hints, 0, sizeof(hints));
236+ hints.ai_family = AF_INET6;
237+ hints.ai_socktype = SOCK_STREAM;
238+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
239+ if ((ret = getaddrinfo(tok + 1, NULL, &hints, &res)) == 0) {
240+ memcpy(&pat, res->ai_addr, sizeof(pat));
241+ freeaddrinfo(res);
242+ }
243+ tok[len - 1] = ch;
244+ if (ret != 0 || getaddrinfo(string, NULL, &hints, &res) != 0)
245+ return NO;
246+ memcpy(&addr, res->ai_addr, sizeof(addr));
247+ freeaddrinfo(res);
248+#ifdef NI_WITHSCOPEID
249+ if (pat.sin6_scope_id != 0 &&
250+ addr.sin6_scope_id != pat.sin6_scope_id)
251+ return NO;
252+#endif
253+ return (!memcmp(&pat.sin6_addr, &addr.sin6_addr,
254+ sizeof(struct in6_addr)));
255+ return (ret);
256+ }
257+#endif
258 return (STR_EQ(tok, string));
259 }
260 }
261
262 /* masked_match - match address against netnumber/netmask */
263
264+#ifdef INET6
265 static int masked_match(net_tok, mask_tok, string)
266 char *net_tok;
267 char *mask_tok;
268 char *string;
269 {
270+ return (masked_match4(net_tok, mask_tok, string) ||
271+ masked_match6(net_tok, mask_tok, string));
272+}
273+
274+static int masked_match4(net_tok, mask_tok, string)
275+#else
276+static int masked_match(net_tok, mask_tok, string)
277+#endif
278+char *net_tok;
279+char *mask_tok;
280+char *string;
281+{
282+#ifdef INET6
283+ u_int32_t net;
284+ u_int32_t mask;
285+ u_int32_t addr;
286+#else
287 unsigned long net;
288 unsigned long mask;
289 unsigned long addr;
290+#endif
291
292 /*
293 * Disallow forms other than dotted quad: the treatment that inet_addr()
294@@ -416,8 +423,76 @@
295 return (NO);
296 if ((net = dot_quad_addr(net_tok)) == INADDR_NONE
297 || (mask = dot_quad_addr(mask_tok)) == INADDR_NONE) {
298+#ifndef INET6
299 tcpd_warn("bad net/mask expression: %s/%s", net_tok, mask_tok);
300+#endif
301 return (NO); /* not tcpd_jump() */
302 }
303 return ((addr & mask) == net);
304 }
305+
306+#ifdef INET6
307+static int masked_match6(net_tok, mask_tok, string)
308+char *net_tok;
309+char *mask_tok;
310+char *string;
311+{
312+ struct addrinfo hints, *res;
313+ struct sockaddr_in6 net, addr;
314+ u_int32_t mask;
315+ int len, mask_len, i = 0;
316+ char ch;
317+
318+ /*
319+ * Behavior of getaddrinfo() against IPv4-mapped IPv6 address is
320+ * different between KAME and Solaris8. While KAME returns
321+ * AF_INET6, Solaris8 returns AF_INET. So, we avoid this here.
322+ */
323+ if (STRN_EQ(string, "::ffff:", 7)
324+ && dot_quad_addr(string + 7) != INADDR_NONE)
325+ return (masked_match4(net_tok, mask_tok, string + 7));
326+
327+ memset(&hints, 0, sizeof(hints));
328+ hints.ai_family = AF_INET6;
329+ hints.ai_socktype = SOCK_STREAM;
330+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
331+ if (getaddrinfo(string, NULL, &hints, &res) != 0)
332+ return NO;
333+ memcpy(&addr, res->ai_addr, sizeof(addr));
334+ freeaddrinfo(res);
335+
336+ /* match IPv6 address against netnumber/prefixlen */
337+ len = strlen(net_tok);
338+ if (*net_tok != '[' || net_tok[len - 1] != ']')
339+ return NO;
340+ ch = net_tok[len - 1];
341+ net_tok[len - 1] = '\0';
342+ if (getaddrinfo(net_tok + 1, NULL, &hints, &res) != 0) {
343+ net_tok[len - 1] = ch;
344+ return NO;
345+ }
346+ memcpy(&net, res->ai_addr, sizeof(net));
347+ freeaddrinfo(res);
348+ net_tok[len - 1] = ch;
349+ if ((mask_len = atoi(mask_tok)) < 0 || mask_len > 128)
350+ return NO;
351+
352+#ifdef NI_WITHSCOPEID
353+ if (net.sin6_scope_id != 0 && addr.sin6_scope_id != net.sin6_scope_id)
354+ return NO;
355+#endif
356+ while (mask_len > 0) {
357+ if (mask_len < 32) {
358+ mask = htonl(~(0xffffffff >> mask_len));
359+ if ((*(u_int32_t *)&addr.sin6_addr.s6_addr[i] & mask) != (*(u_int32_t *)&net.sin6_addr.s6_addr[i] & mask))
360+ return NO;
361+ break;
362+ }
363+ if (*(u_int32_t *)&addr.sin6_addr.s6_addr[i] != *(u_int32_t *)&net.sin6_addr.s6_addr[i])
364+ return NO;
365+ i += 4;
366+ mask_len -= 32;
367+ }
368+ return YES;
369+}
370+#endif /* INET6 */
371Index: inetcf.c
372===================================================================
373RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/inetcf.c,v
374retrieving revision 1.1.1.1
375retrieving revision 1.2
376diff -u -r1.1.1.1 -r1.2
377--- inetcf.c 2001/03/02 09:26:27 1.1.1.1
378+++ inetcf.c 2001/03/02 09:30:19 1.2
379@@ -26,6 +26,9 @@
380 * guesses. Shorter names follow longer ones.
381 */
382 char *inet_files[] = {
383+#ifdef INET6
384+ "/usr/local/v6/etc/inet6d.conf", /* KAME */
385+#endif
386 "/private/etc/inetd.conf", /* NEXT */
387 "/etc/inet/inetd.conf", /* SYSV4 */
388 "/usr/etc/inetd.conf", /* IRIX?? */
389Index: misc.c
390===================================================================
391RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/misc.c,v
392retrieving revision 1.1.1.1
393retrieving revision 1.2
394diff -u -r1.1.1.1 -r1.2
395--- misc.c 2001/03/02 09:26:27 1.1.1.1
396+++ misc.c 2001/03/02 09:30:19 1.2
397@@ -58,9 +58,31 @@
398 {
399 char *cp;
400
401+#ifdef INET6
402+ int bracket = 0;
403+
404+ for (cp = string; cp && *cp; cp++) {
405+ switch (*cp) {
406+ case '[':
407+ bracket++;
408+ break;
409+ case ']':
410+ bracket--;
411+ break;
412+ default:
413+ if (bracket == 0 && *cp == delimiter) {
414+ *cp++ = 0;
415+ return cp;
416+ }
417+ break;
418+ }
419+ }
420+ return (NULL);
421+#else
422 if ((cp = strchr(string, delimiter)) != 0)
423 *cp++ = 0;
424 return (cp);
425+#endif
426 }
427
428 /* dot_quad_addr - convert dotted quad to internal form */
429Index: refuse.c
430===================================================================
431RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/refuse.c,v
432retrieving revision 1.1.1.1
433retrieving revision 1.2
434diff -u -r1.1.1.1 -r1.2
435--- refuse.c 2001/03/02 09:26:27 1.1.1.1
436+++ refuse.c 2001/03/02 09:30:19 1.2
437@@ -25,7 +25,12 @@
438 void refuse(request)
439 struct request_info *request;
440 {
441+#ifdef INET6
442+ syslog(deny_severity, "refused connect from %s (%s)",
443+ eval_client(request), eval_hostaddr(request->client));
444+#else
445 syslog(deny_severity, "refused connect from %s", eval_client(request));
446+#endif
447 clean_exit(request);
448 /* NOTREACHED */
449 }
450Index: rfc931.c
451===================================================================
452RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/rfc931.c,v
453retrieving revision 1.1.1.1
454retrieving revision 1.2
455diff -u -r1.1.1.1 -r1.2
456--- rfc931.c 2001/03/02 09:26:26 1.1.1.1
457+++ rfc931.c 2001/03/02 09:30:19 1.2
458@@ -68,20 +68,50 @@
459 /* rfc931 - return remote user name, given socket structures */
460
461 void rfc931(rmt_sin, our_sin, dest)
462+#ifdef INET6
463+struct sockaddr *rmt_sin;
464+struct sockaddr *our_sin;
465+#else
466 struct sockaddr_in *rmt_sin;
467 struct sockaddr_in *our_sin;
468+#endif
469 char *dest;
470 {
471 unsigned rmt_port;
472 unsigned our_port;
473+#ifdef INET6
474+ struct sockaddr_storage rmt_query_sin;
475+ struct sockaddr_storage our_query_sin;
476+ int alen;
477+#else
478 struct sockaddr_in rmt_query_sin;
479 struct sockaddr_in our_query_sin;
480+#endif
481 char user[256]; /* XXX */
482 char buffer[512]; /* XXX */
483 char *cp;
484 char *result = unknown;
485 FILE *fp;
486
487+#ifdef INET6
488+ /* address family must be the same */
489+ if (rmt_sin->sa_family != our_sin->sa_family) {
490+ STRN_CPY(dest, result, STRING_LENGTH);
491+ return;
492+ }
493+ switch (our_sin->sa_family) {
494+ case AF_INET:
495+ alen = sizeof(struct sockaddr_in);
496+ break;
497+ case AF_INET6:
498+ alen = sizeof(struct sockaddr_in6);
499+ break;
500+ default:
501+ STRN_CPY(dest, result, STRING_LENGTH);
502+ return;
503+ }
504+#endif
505+
506 /*
507 * Use one unbuffered stdio stream for writing to and for reading from
508 * the RFC931 etc. server. This is done because of a bug in the SunOS
509@@ -92,7 +122,11 @@
510 * sockets.
511 */
512
513+#ifdef INET6
514+ if ((fp = fsocket(our_sin->sa_family, SOCK_STREAM, 0)) != 0) {
515+#else
516 if ((fp = fsocket(AF_INET, SOCK_STREAM, 0)) != 0) {
517+#endif
518 setbuf(fp, (char *) 0);
519
520 /*
521@@ -112,6 +146,25 @@
522 * addresses from the query socket.
523 */
524
525+#ifdef INET6
526+ memcpy(&our_query_sin, our_sin, alen);
527+ memcpy(&rmt_query_sin, rmt_sin, alen);
528+ switch (our_sin->sa_family) {
529+ case AF_INET:
530+ ((struct sockaddr_in *)&our_query_sin)->sin_port = htons(ANY_PORT);
531+ ((struct sockaddr_in *)&rmt_query_sin)->sin_port = htons(RFC931_PORT);
532+ break;
533+ case AF_INET6:
534+ ((struct sockaddr_in6 *)&our_query_sin)->sin6_port = htons(ANY_PORT);
535+ ((struct sockaddr_in6 *)&rmt_query_sin)->sin6_port = htons(RFC931_PORT);
536+ break;
537+ }
538+
539+ if (bind(fileno(fp), (struct sockaddr *) & our_query_sin,
540+ alen) >= 0 &&
541+ connect(fileno(fp), (struct sockaddr *) & rmt_query_sin,
542+ alen) >= 0) {
543+#else
544 our_query_sin = *our_sin;
545 our_query_sin.sin_port = htons(ANY_PORT);
546 rmt_query_sin = *rmt_sin;
547@@ -121,6 +174,7 @@
548 sizeof(our_query_sin)) >= 0 &&
549 connect(fileno(fp), (struct sockaddr *) & rmt_query_sin,
550 sizeof(rmt_query_sin)) >= 0) {
551+#endif
552
553 /*
554 * Send query to server. Neglect the risk that a 13-byte
555@@ -129,8 +183,13 @@
556 */
557
558 fprintf(fp, "%u,%u\r\n",
559+#ifdef INET6
560+ ntohs(((struct sockaddr_in *)rmt_sin)->sin_port),
561+ ntohs(((struct sockaddr_in *)our_sin)->sin_port));
562+#else
563 ntohs(rmt_sin->sin_port),
564 ntohs(our_sin->sin_port));
565+#endif
566 fflush(fp);
567
568 /*
569@@ -144,8 +203,13 @@
570 && ferror(fp) == 0 && feof(fp) == 0
571 && sscanf(buffer, "%u , %u : USERID :%*[^:]:%255s",
572 &rmt_port, &our_port, user) == 3
573+#ifdef INET6
574+ && ntohs(((struct sockaddr_in *)rmt_sin)->sin_port) == rmt_port
575+ && ntohs(((struct sockaddr_in *)our_sin)->sin_port) == our_port) {
576+#else
577 && ntohs(rmt_sin->sin_port) == rmt_port
578 && ntohs(our_sin->sin_port) == our_port) {
579+#endif
580
581 /*
582 * Strip trailing carriage return. It is part of the
583Index: scaffold.c
584===================================================================
585RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/scaffold.c,v
586retrieving revision 1.1.1.1
587retrieving revision 1.2
588diff -u -r1.1.1.1 -r1.2
589--- scaffold.c 2001/03/02 09:26:27 1.1.1.1
590+++ scaffold.c 2001/03/02 09:30:19 1.2
591@@ -25,7 +25,9 @@
592 #define INADDR_NONE (-1) /* XXX should be 0xffffffff */
593 #endif
594
595+#ifndef INET6
596 extern char *malloc();
597+#endif
598
599 /* Application-specific. */
600
601@@ -39,6 +41,7 @@
602 int deny_severity = LOG_WARNING;
603 int rfc931_timeout = RFC931_TIMEOUT;
604
605+#ifndef INET6
606 /* dup_hostent - create hostent in one memory block */
607
608 static struct hostent *dup_hostent(hp)
609@@ -73,9 +76,46 @@
610 }
611 return (&hb->host);
612 }
613+#endif
614
615 /* find_inet_addr - find all addresses for this host, result to free() */
616
617+#ifdef INET6
618+struct addrinfo *find_inet_addr(host)
619+char *host;
620+{
621+ struct addrinfo hints, *res;
622+
623+ memset(&hints, 0, sizeof(hints));
624+ hints.ai_family = PF_UNSPEC;
625+ hints.ai_socktype = SOCK_STREAM;
626+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
627+ if (getaddrinfo(host, NULL, &hints, &res) == 0)
628+ return (res);
629+
630+ memset(&hints, 0, sizeof(hints));
631+ hints.ai_family = PF_UNSPEC;
632+ hints.ai_socktype = SOCK_STREAM;
633+ hints.ai_flags = AI_PASSIVE | AI_CANONNAME;
634+ if (getaddrinfo(host, NULL, &hints, &res) != 0) {
635+ tcpd_warn("%s: host not found", host);
636+ return (0);
637+ }
638+ if (res->ai_family != AF_INET6 && res->ai_family != AF_INET) {
639+ tcpd_warn("%d: not an internet host", res->ai_family);
640+ freeaddrinfo(res);
641+ return (0);
642+ }
643+ if (!res->ai_canonname) {
644+ tcpd_warn("%s: hostname alias", host);
645+ tcpd_warn("(cannot obtain official name)", res->ai_canonname);
646+ } else if (STR_NE(host, res->ai_canonname)) {
647+ tcpd_warn("%s: hostname alias", host);
648+ tcpd_warn("(official name: %.*s)", STRING_LENGTH, res->ai_canonname);
649+ }
650+ return (res);
651+}
652+#else
653 struct hostent *find_inet_addr(host)
654 char *host;
655 {
656@@ -118,6 +158,7 @@
657 }
658 return (dup_hostent(hp));
659 }
660+#endif
661
662 /* check_dns - give each address thorough workout, return address count */
663
664@@ -125,8 +166,13 @@
665 char *host;
666 {
667 struct request_info request;
668+#ifdef INET6
669+ struct sockaddr_storage sin;
670+ struct addrinfo *hp, *res;
671+#else
672 struct sockaddr_in sin;
673 struct hostent *hp;
674+#endif
675 int count;
676 char *addr;
677
678@@ -134,11 +180,18 @@
679 return (0);
680 request_init(&request, RQ_CLIENT_SIN, &sin, 0);
681 sock_methods(&request);
682+#ifndef INET6
683 memset((char *) &sin, 0, sizeof(sin));
684 sin.sin_family = AF_INET;
685+#endif
686
687+#ifdef INET6
688+ for (res = hp, count = 0; res; res = res->ai_next, count++) {
689+ memcpy(&sin, res->ai_addr, res->ai_addrlen);
690+#else
691 for (count = 0; (addr = hp->h_addr_list[count]) != 0; count++) {
692 memcpy((char *) &sin.sin_addr, addr, sizeof(sin.sin_addr));
693+#endif
694
695 /*
696 * Force host name and address conversions. Use the request structure
697@@ -151,7 +204,11 @@
698 tcpd_warn("host address %s->name lookup failed",
699 eval_hostaddr(request.client));
700 }
701+#ifdef INET6
702+ freeaddrinfo(hp);
703+#else
704 free((char *) hp);
705+#endif
706 return (count);
707 }
708
709Index: scaffold.h
710===================================================================
711RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/scaffold.h,v
712retrieving revision 1.1.1.1
713retrieving revision 1.2
714diff -u -r1.1.1.1 -r1.2
715--- scaffold.h 2001/03/02 09:26:27 1.1.1.1
716+++ scaffold.h 2001/03/02 09:30:19 1.2
717@@ -4,6 +4,10 @@
718 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
719 */
720
721+#ifdef INET6
722+extern struct addrinfo *find_inet_addr();
723+#else
724 extern struct hostent *find_inet_addr();
725+#endif
726 extern int check_dns();
727 extern int check_path();
728Index: socket.c
729===================================================================
730RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/socket.c,v
731retrieving revision 1.1.1.1
732retrieving revision 1.2
733diff -u -r1.1.1.1 -r1.2
734--- socket.c 2001/03/02 09:26:27 1.1.1.1
735+++ socket.c 2001/03/02 09:30:19 1.2
736@@ -24,13 +24,22 @@
737 #include <sys/types.h>
738 #include <sys/param.h>
739 #include <sys/socket.h>
740+#ifdef INT32_T
741+typedef uint32_t u_int32_t;
742+#endif
743 #include <netinet/in.h>
744 #include <netdb.h>
745 #include <stdio.h>
746 #include <syslog.h>
747 #include <string.h>
748
749+#ifdef INET6
750+#ifndef NI_WITHSCOPEID
751+#define NI_WITHSCOPEID 0
752+#endif
753+#else
754 extern char *inet_ntoa();
755+#endif
756
757 /* Local stuff. */
758
759@@ -74,8 +83,13 @@
760 void sock_host(request)
761 struct request_info *request;
762 {
763+#ifdef INET6
764+ static struct sockaddr_storage client;
765+ static struct sockaddr_storage server;
766+#else
767 static struct sockaddr_in client;
768 static struct sockaddr_in server;
769+#endif
770 int len;
771 char buf[BUFSIZ];
772 int fd = request->fd;
773@@ -104,7 +118,11 @@
774 memset(buf, 0 sizeof(buf));
775 #endif
776 }
777+#ifdef INET6
778+ request->client->sin = (struct sockaddr *)&client;
779+#else
780 request->client->sin = &client;
781+#endif
782
783 /*
784 * Determine the server binding. This is used for client username
785@@ -117,7 +135,11 @@
786 tcpd_warn("getsockname: %m");
787 return;
788 }
789+#ifdef INET6
790+ request->server->sin = (struct sockaddr *)&server;
791+#else
792 request->server->sin = &server;
793+#endif
794 }
795
796 /* sock_hostaddr - map endpoint address to printable form */
797@@ -125,10 +147,26 @@
798 void sock_hostaddr(host)
799 struct host_info *host;
800 {
801+#ifdef INET6
802+ struct sockaddr *sin = host->sin;
803+ int salen;
804+
805+ if (!sin)
806+ return;
807+#ifdef SIN6_LEN
808+ salen = sin->sa_len;
809+#else
810+ salen = (sin->sa_family == AF_INET) ? sizeof(struct sockaddr_in)
811+ : sizeof(struct sockaddr_in6);
812+#endif
813+ getnameinfo(sin, salen, host->addr, sizeof(host->addr),
814+ NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID);
815+#else
816 struct sockaddr_in *sin = host->sin;
817
818 if (sin != 0)
819 STRN_CPY(host->addr, inet_ntoa(sin->sin_addr), sizeof(host->addr));
820+#endif
821 }
822
823 /* sock_hostname - map endpoint address to host name */
824@@ -136,6 +174,160 @@
825 void sock_hostname(host)
826 struct host_info *host;
827 {
828+#ifdef INET6
829+ struct sockaddr *sin = host->sin;
830+ struct sockaddr_in sin4;
831+ struct addrinfo hints, *res, *res0 = NULL;
832+ int salen, alen, err = 1;
833+ char *ap = NULL, *rap, hname[NI_MAXHOST];
834+
835+ if (sin != NULL) {
836+ if (sin->sa_family == AF_INET6) {
837+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sin;
838+
839+ if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
840+ memset(&sin4, 0, sizeof(sin4));
841+#ifdef SIN6_LEN
842+ sin4.sin_len = sizeof(sin4);
843+#endif
844+ sin4.sin_family = AF_INET;
845+ sin4.sin_port = sin6->sin6_port;
846+ sin4.sin_addr.s_addr = *(u_int32_t *)&sin6->sin6_addr.s6_addr[12];
847+ sin = (struct sockaddr *)&sin4;
848+ }
849+ }
850+ switch (sin->sa_family) {
851+ case AF_INET:
852+ ap = (char *)&((struct sockaddr_in *)sin)->sin_addr;
853+ alen = sizeof(struct in_addr);
854+ salen = sizeof(struct sockaddr_in);
855+ break;
856+ case AF_INET6:
857+ ap = (char *)&((struct sockaddr_in6 *)sin)->sin6_addr;
858+ alen = sizeof(struct in6_addr);
859+ salen = sizeof(struct sockaddr_in6);
860+ break;
861+ default:
862+ break;
863+ }
864+ if (ap)
865+ err = getnameinfo(sin, salen, hname, sizeof(hname),
866+ NULL, 0, NI_WITHSCOPEID | NI_NAMEREQD);
867+ }
868+ if (!err) {
869+
870+ STRN_CPY(host->name, hname, sizeof(host->name));
871+
872+ /* reject numeric addresses */
873+ memset(&hints, 0, sizeof(hints));
874+ hints.ai_family = sin->sa_family;
875+ hints.ai_socktype = SOCK_STREAM;
876+ hints.ai_flags = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST;
877+ if ((err = getaddrinfo(host->name, NULL, &hints, &res0)) == 0) {
878+ freeaddrinfo(res0);
879+ res0 = NULL;
880+ tcpd_warn("host name/name mismatch: "
881+ "reverse lookup results in non-FQDN %s",
882+ host->name);
883+ strcpy(host->name, paranoid); /* name is bad, clobber it */
884+ }
885+ err = !err;
886+ }
887+ if (!err) {
888+ /* we are now sure that this is non-numeric */
889+
890+ /*
891+ * Verify that the address is a member of the address list returned
892+ * by gethostbyname(hostname).
893+ *
894+ * Verify also that gethostbyaddr() and gethostbyname() return the same
895+ * hostname, or rshd and rlogind may still end up being spoofed.
896+ *
897+ * On some sites, gethostbyname("localhost") returns "localhost.domain".
898+ * This is a DNS artefact. We treat it as a special case. When we
899+ * can't believe the address list from gethostbyname("localhost")
900+ * we're in big trouble anyway.
901+ */
902+
903+ memset(&hints, 0, sizeof(hints));
904+ hints.ai_family = sin->sa_family;
905+ hints.ai_socktype = SOCK_STREAM;
906+ hints.ai_flags = AI_PASSIVE | AI_CANONNAME;
907+ if (getaddrinfo(host->name, NULL, &hints, &res0) != 0) {
908+
909+ /*
910+ * Unable to verify that the host name matches the address. This
911+ * may be a transient problem or a botched name server setup.
912+ */
913+
914+ tcpd_warn("can't verify hostname: getaddrinfo(%s, %s) failed",
915+ host->name,
916+ (sin->sa_family == AF_INET) ? "AF_INET" : "AF_INET6");
917+
918+ } else if ((res0->ai_canonname == NULL
919+ || STR_NE(host->name, res0->ai_canonname))
920+ && STR_NE(host->name, "localhost")) {
921+
922+ /*
923+ * The gethostbyaddr() and gethostbyname() calls did not return
924+ * the same hostname. This could be a nameserver configuration
925+ * problem. It could also be that someone is trying to spoof us.
926+ */
927+
928+ tcpd_warn("host name/name mismatch: %s != %.*s",
929+ host->name, STRING_LENGTH,
930+ (res0->ai_canonname == NULL) ? "" : res0->ai_canonname);
931+
932+ } else {
933+
934+ /*
935+ * The address should be a member of the address list returned by
936+ * gethostbyname(). We should first verify that the h_addrtype
937+ * field is AF_INET, but this program has already caused too much
938+ * grief on systems with broken library code.
939+ */
940+
941+ for (res = res0; res; res = res->ai_next) {
942+ if (res->ai_family != sin->sa_family)
943+ continue;
944+ switch (res->ai_family) {
945+ case AF_INET:
946+ rap = (char *)&((struct sockaddr_in *)res->ai_addr)->sin_addr;
947+ break;
948+ case AF_INET6:
949+ /* need to check scope_id */
950+ if (((struct sockaddr_in6 *)sin)->sin6_scope_id !=
951+ ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id) {
952+ continue;
953+ }
954+ rap = (char *)&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
955+ break;
956+ default:
957+ continue;
958+ }
959+ if (memcmp(rap, ap, alen) == 0) {
960+ freeaddrinfo(res0);
961+ return; /* name is good, keep it */
962+ }
963+ }
964+
965+ /*
966+ * The host name does not map to the initial address. Perhaps
967+ * someone has messed up. Perhaps someone compromised a name
968+ * server.
969+ */
970+
971+ getnameinfo(sin, salen, hname, sizeof(hname),
972+ NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID);
973+ tcpd_warn("host name/address mismatch: %s != %.*s",
974+ hname, STRING_LENGTH,
975+ (res0->ai_canonname == NULL) ? "" : res0->ai_canonname);
976+ }
977+ strcpy(host->name, paranoid); /* name is bad, clobber it */
978+ if (res0)
979+ freeaddrinfo(res0);
980+ }
981+#else /* INET6 */
982 struct sockaddr_in *sin = host->sin;
983 struct hostent *hp;
984 int i;
985@@ -215,6 +407,7 @@
986 }
987 strcpy(host->name, paranoid); /* name is bad, clobber it */
988 }
989+#endif /* INET6 */
990 }
991
992 /* sock_sink - absorb unreceived IP datagram */
993@@ -223,7 +416,11 @@
994 int fd;
995 {
996 char buf[BUFSIZ];
997+#ifdef INET6
998+ struct sockaddr_storage sin;
999+#else
1000 struct sockaddr_in sin;
1001+#endif
1002 int size = sizeof(sin);
1003
1004 /*
1005Index: tcpd.c
1006===================================================================
1007RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/tcpd.c,v
1008retrieving revision 1.1.1.1
1009retrieving revision 1.2
1010diff -u -r1.1.1.1 -r1.2
1011--- tcpd.c 2001/03/02 09:26:27 1.1.1.1
1012+++ tcpd.c 2001/03/02 09:30:19 1.2
1013@@ -120,7 +120,12 @@
1014
1015 /* Report request and invoke the real daemon program. */
1016
1017+#ifdef INET6
1018+ syslog(allow_severity, "connect from %s (%s)",
1019+ eval_client(&request), eval_hostaddr(request.client));
1020+#else
1021 syslog(allow_severity, "connect from %s", eval_client(&request));
1022+#endif
1023 closelog();
1024 (void) execv(path, argv);
1025 syslog(LOG_ERR, "error: cannot execute %s: %m", path);
1026Index: tcpd.h
1027===================================================================
1028RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/tcpd.h,v
1029retrieving revision 1.1.1.1
1030retrieving revision 1.2
1031diff -u -r1.1.1.1 -r1.2
1032--- tcpd.h 2001/03/02 09:26:27 1.1.1.1
1033+++ tcpd.h 2001/03/02 09:30:19 1.2
1034@@ -11,7 +11,11 @@
1035 struct host_info {
1036 char name[STRING_LENGTH]; /* access via eval_hostname(host) */
1037 char addr[STRING_LENGTH]; /* access via eval_hostaddr(host) */
1038+#ifdef INET6
1039+ struct sockaddr *sin; /* socket address or 0 */
1040+#else
1041 struct sockaddr_in *sin; /* socket address or 0 */
1042+#endif
1043 struct t_unitdata *unit; /* TLI transport address or 0 */
1044 struct request_info *request; /* for shared information */
1045 };
1046Index: tcpdchk.c
1047===================================================================
1048RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/tcpdchk.c,v
1049retrieving revision 1.1.1.1
1050retrieving revision 1.2
1051diff -u -r1.1.1.1 -r1.2
1052--- tcpdchk.c 2001/03/02 09:26:27 1.1.1.1
1053+++ tcpdchk.c 2001/03/02 09:30:19 1.2
1054@@ -22,6 +22,9 @@
1055
1056 #include <sys/types.h>
1057 #include <sys/stat.h>
1058+#ifdef INET6
1059+#include <sys/socket.h>
1060+#endif
1061 #include <netinet/in.h>
1062 #include <arpa/inet.h>
1063 #include <stdio.h>
1064@@ -397,6 +400,31 @@
1065 }
1066 }
1067
1068+#ifdef INET6
1069+static int is_inet6_addr(pat)
1070+ char *pat;
1071+{
1072+ struct addrinfo hints, *res;
1073+ int len, ret;
1074+ char ch;
1075+
1076+ if (*pat != '[')
1077+ return (0);
1078+ len = strlen(pat);
1079+ if ((ch = pat[len - 1]) != ']')
1080+ return (0);
1081+ pat[len - 1] = '\0';
1082+ memset(&hints, 0, sizeof(hints));
1083+ hints.ai_family = AF_INET6;
1084+ hints.ai_socktype = SOCK_STREAM;
1085+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
1086+ if ((ret = getaddrinfo(pat + 1, NULL, &hints, &res)) == 0)
1087+ freeaddrinfo(res);
1088+ pat[len - 1] = ch;
1089+ return (ret == 0);
1090+}
1091+#endif
1092+
1093 /* check_host - criticize host pattern */
1094
1095 static int check_host(pat)
1096@@ -423,14 +451,27 @@
1097 #endif
1098 #endif
1099 } else if (mask = split_at(pat, '/')) { /* network/netmask */
1100+#ifdef INET6
1101+ int mask_len;
1102+
1103+ if ((dot_quad_addr(pat) == INADDR_NONE
1104+ || dot_quad_addr(mask) == INADDR_NONE)
1105+ && (!is_inet6_addr(pat)
1106+ || ((mask_len = atoi(mask)) < 0 || mask_len > 128)))
1107+#else
1108 if (dot_quad_addr(pat) == INADDR_NONE
1109 || dot_quad_addr(mask) == INADDR_NONE)
1110+#endif
1111 tcpd_warn("%s/%s: bad net/mask pattern", pat, mask);
1112 } else if (STR_EQ(pat, "FAIL")) { /* obsolete */
1113 tcpd_warn("FAIL is no longer recognized");
1114 tcpd_warn("(use EXCEPT or DENY instead)");
1115 } else if (reserved_name(pat)) { /* other reserved */
1116 /* void */ ;
1117+#ifdef INET6
1118+ } else if (is_inet6_addr(pat)) { /* IPv6 address */
1119+ addr_count = 1;
1120+#endif
1121 } else if (NOT_INADDR(pat)) { /* internet name */
1122 if (pat[strlen(pat) - 1] == '.') {
1123 tcpd_warn("%s: domain or host name ends in dot", pat);
1124Index: tcpdmatch.c
1125===================================================================
1126RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/tcpdmatch.c,v
1127retrieving revision 1.1.1.1
1128retrieving revision 1.2
1129diff -u -r1.1.1.1 -r1.2
1130--- tcpdmatch.c 2001/03/02 09:26:27 1.1.1.1
1131+++ tcpdmatch.c 2001/03/02 09:30:19 1.2
1132@@ -57,7 +57,11 @@
1133 int argc;
1134 char **argv;
1135 {
1136+#ifdef INET6
1137+ struct addrinfo hints, *hp, *res;
1138+#else
1139 struct hostent *hp;
1140+#endif
1141 char *myname = argv[0];
1142 char *client;
1143 char *server;
1144@@ -68,8 +72,13 @@
1145 int ch;
1146 char *inetcf = 0;
1147 int count;
1148+#ifdef INET6
1149+ struct sockaddr_storage server_sin;
1150+ struct sockaddr_storage client_sin;
1151+#else
1152 struct sockaddr_in server_sin;
1153 struct sockaddr_in client_sin;
1154+#endif
1155 struct stat st;
1156
1157 /*
1158@@ -172,13 +181,20 @@
1159 if (NOT_INADDR(server) == 0 || HOSTNAME_KNOWN(server)) {
1160 if ((hp = find_inet_addr(server)) == 0)
1161 exit(1);
1162+#ifndef INET6
1163 memset((char *) &server_sin, 0, sizeof(server_sin));
1164 server_sin.sin_family = AF_INET;
1165+#endif
1166 request_set(&request, RQ_SERVER_SIN, &server_sin, 0);
1167
1168+#ifdef INET6
1169+ for (res = hp, count = 0; res; res = res->ai_next, count++) {
1170+ memcpy(&server_sin, res->ai_addr, res->ai_addrlen);
1171+#else
1172 for (count = 0; (addr = hp->h_addr_list[count]) != 0; count++) {
1173 memcpy((char *) &server_sin.sin_addr, addr,
1174 sizeof(server_sin.sin_addr));
1175+#endif
1176
1177 /*
1178 * Force evaluation of server host name and address. Host name
1179@@ -194,7 +210,11 @@
1180 fprintf(stderr, "Please specify an address instead\n");
1181 exit(1);
1182 }
1183+#ifdef INET6
1184+ freeaddrinfo(hp);
1185+#else
1186 free((char *) hp);
1187+#endif
1188 } else {
1189 request_set(&request, RQ_SERVER_NAME, server, 0);
1190 }
1191@@ -208,6 +228,18 @@
1192 tcpdmatch(&request);
1193 exit(0);
1194 }
1195+#ifdef INET6
1196+ memset(&hints, 0, sizeof(hints));
1197+ hints.ai_family = AF_INET6;
1198+ hints.ai_socktype = SOCK_STREAM;
1199+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
1200+ if (getaddrinfo(client, NULL, &hints, &res) == 0) {
1201+ freeaddrinfo(res);
1202+ request_set(&request, RQ_CLIENT_ADDR, client, 0);
1203+ tcpdmatch(&request);
1204+ exit(0);
1205+ }
1206+#endif
1207
1208 /*
1209 * Perhaps they are testing special client hostname patterns that aren't
1210@@ -229,6 +261,34 @@
1211 */
1212 if ((hp = find_inet_addr(client)) == 0)
1213 exit(1);
1214+#ifdef INET6
1215+ request_set(&request, RQ_CLIENT_SIN, &client_sin, 0);
1216+
1217+ for (res = hp, count = 0; res; res = res->ai_next, count++) {
1218+ memcpy(&client_sin, res->ai_addr, res->ai_addrlen);
1219+
1220+ /*
1221+ * getnameinfo() doesn't do reverse lookup against link-local
1222+ * address. So, we pass through host name evaluation against
1223+ * such addresses.
1224+ */
1225+ if (res->ai_family != AF_INET6 ||
1226+ !IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr)) {
1227+ /*
1228+ * Force evaluation of client host name and address. Host name
1229+ * conflicts will be reported while eval_hostname() does its job.
1230+ */
1231+ request_set(&request, RQ_CLIENT_NAME, "", RQ_CLIENT_ADDR, "", 0);
1232+ if (STR_EQ(eval_hostname(request.client), unknown))
1233+ tcpd_warn("host address %s->name lookup failed",
1234+ eval_hostaddr(request.client));
1235+ }
1236+ tcpdmatch(&request);
1237+ if (res->ai_next)
1238+ printf("\n");
1239+ }
1240+ freeaddrinfo(hp);
1241+#else
1242 memset((char *) &client_sin, 0, sizeof(client_sin));
1243 client_sin.sin_family = AF_INET;
1244 request_set(&request, RQ_CLIENT_SIN, &client_sin, 0);
1245@@ -250,6 +310,7 @@
1246 printf("\n");
1247 }
1248 free((char *) hp);
1249+#endif
1250 exit(0);
1251 }
1252
1253Index: tli.c
1254===================================================================
1255RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/tli.c,v
1256retrieving revision 1.1.1.1
1257retrieving revision 1.2
1258diff -u -r1.1.1.1 -r1.2
1259--- tli.c 2001/03/02 09:26:27 1.1.1.1
1260+++ tli.c 2001/03/02 09:30:19 1.2
1261@@ -65,8 +65,13 @@
1262 void tli_host(request)
1263 struct request_info *request;
1264 {
1265+#ifdef INET6
1266+ static struct sockaddr_storage client;
1267+ static struct sockaddr_storage server;
1268+#else
1269 static struct sockaddr_in client;
1270 static struct sockaddr_in server;
1271+#endif
1272
1273 /*
1274 * If we discover that we are using an IP transport, pretend we never
1275@@ -76,14 +81,29 @@
1276
1277 tli_endpoints(request);
1278 if ((request->config = tli_transport(request->fd)) != 0
1279+#ifdef INET6
1280+ && (STR_EQ(request->config->nc_protofmly, "inet") ||
1281+ STR_EQ(request->config->nc_protofmly, "inet6"))) {
1282+#else
1283 && STR_EQ(request->config->nc_protofmly, "inet")) {
1284+#endif
1285 if (request->client->unit != 0) {
1286+#ifdef INET6
1287+ client = *(struct sockaddr_storage *) request->client->unit->addr.buf;
1288+ request->client->sin = (struct sockaddr *) &client;
1289+#else
1290 client = *(struct sockaddr_in *) request->client->unit->addr.buf;
1291 request->client->sin = &client;
1292+#endif
1293 }
1294 if (request->server->unit != 0) {
1295+#ifdef INET6
1296+ server = *(struct sockaddr_storage *) request->server->unit->addr.buf;
1297+ request->server->sin = (struct sockaddr *) &server;
1298+#else
1299 server = *(struct sockaddr_in *) request->server->unit->addr.buf;
1300 request->server->sin = &server;
1301+#endif
1302 }
1303 tli_cleanup(request);
1304 sock_methods(request);
1305@@ -187,7 +207,15 @@
1306 }
1307 while (config = getnetconfig(handlep)) {
1308 if (stat(config->nc_device, &from_config) == 0) {
1309+#ifdef NO_CLONE_DEVICE
1310+ /*
1311+ * If the network devices are not cloned (as is the case for
1312+ * Solaris 8 Beta), we must compare the major device numbers.
1313+ */
1314+ if (major(from_config.st_rdev) == major(from_client.st_rdev))
1315+#else
1316 if (minor(from_config.st_rdev) == major(from_client.st_rdev))
1317+#endif
1318 break;
1319 }
1320 }
1321Index: update.c
1322===================================================================
1323RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/update.c,v
1324retrieving revision 1.1.1.1
1325retrieving revision 1.2
1326diff -u -r1.1.1.1 -r1.2
1327--- update.c 2001/03/02 09:26:27 1.1.1.1
1328+++ update.c 2001/03/02 09:30:19 1.2
1329@@ -46,10 +46,18 @@
1330 request->fd = va_arg(ap, int);
1331 continue;
1332 case RQ_CLIENT_SIN:
1333+#ifdef INET6
1334+ request->client->sin = va_arg(ap, struct sockaddr *);
1335+#else
1336 request->client->sin = va_arg(ap, struct sockaddr_in *);
1337+#endif
1338 continue;
1339 case RQ_SERVER_SIN:
1340+#ifdef INET6
1341+ request->server->sin = va_arg(ap, struct sockaddr *);
1342+#else
1343 request->server->sin = va_arg(ap, struct sockaddr_in *);
1344+#endif
1345 continue;
1346
1347 /*
1348Index: workarounds.c
1349===================================================================
1350RCS file: /cvsroot/usagi/usagi/src/tcp_wrappers/workarounds.c,v
1351retrieving revision 1.1.1.1
1352retrieving revision 1.2
1353diff -u -r1.1.1.1 -r1.2
1354--- workarounds.c 2001/03/02 09:26:27 1.1.1.1
1355+++ workarounds.c 2001/03/02 09:30:19 1.2
1356@@ -166,11 +166,22 @@
1357 int *len;
1358 {
1359 int ret;
1360+#ifdef INET6
1361+ struct sockaddr *sin = sa;
1362+#else
1363 struct sockaddr_in *sin = (struct sockaddr_in *) sa;
1364+#endif
1365
1366 if ((ret = getpeername(sock, sa, len)) >= 0
1367+#ifdef INET6
1368+ && ((sin->su_si.si_family == AF_INET6
1369+ && IN6_IS_ADDR_UNSPECIFIED(&sin->su_sin6.sin6_addr))
1370+ || (sin->su_si.si_family == AF_INET
1371+ && sin->su_sin.sin_addr.s_addr == 0))) {
1372+#else
1373 && sa->sa_family == AF_INET
1374 && sin->sin_addr.s_addr == 0) {
1375+#endif
1376 errno = ENOTCONN;
1377 return (-1);
1378 } else {
This page took 0.386673 seconds and 4 git commands to generate.