diff options
author | Parabola <dev@list.parabolagnulinux.org> | 2011-04-05 14:26:38 +0000 |
---|---|---|
committer | Parabola <dev@list.parabolagnulinux.org> | 2011-04-05 14:26:38 +0000 |
commit | 415856bdd4f48ab4f2732996f0bae58595092bbe (patch) | |
tree | ede2018b591f6dfb477fe9341ba17b9bc000fab9 /core/tcp_wrappers |
Tue Apr 5 14:26:38 UTC 2011
Diffstat (limited to 'core/tcp_wrappers')
-rw-r--r-- | core/tcp_wrappers/01_all_redhat-bug11881.patch | 35 | ||||
-rw-r--r-- | core/tcp_wrappers/02_all_redhat-bug17795.patch | 49 | ||||
-rw-r--r-- | core/tcp_wrappers/03_all_wildcard.patch | 93 | ||||
-rw-r--r-- | core/tcp_wrappers/04_all_fixgethostbyname.patch | 27 | ||||
-rw-r--r-- | core/tcp_wrappers/07_all_sig.patch | 39 | ||||
-rw-r--r-- | core/tcp_wrappers/08_all_strerror.patch | 27 | ||||
-rw-r--r-- | core/tcp_wrappers/09_all_gcc-3.4.patch | 12 | ||||
-rw-r--r-- | core/tcp_wrappers/10_all_more-headers.patch | 209 | ||||
-rw-r--r-- | core/tcp_wrappers/11_inet6_fixes.patch | 41 | ||||
-rw-r--r-- | core/tcp_wrappers/PKGBUILD | 74 | ||||
-rw-r--r-- | core/tcp_wrappers/hosts.allow | 5 | ||||
-rw-r--r-- | core/tcp_wrappers/hosts.deny | 7 | ||||
-rw-r--r-- | core/tcp_wrappers/safe_finger.8 | 34 | ||||
-rw-r--r-- | core/tcp_wrappers/shared_lib_plus_plus-1.patch | 784 | ||||
-rw-r--r-- | core/tcp_wrappers/tcp-wrappers-7.6-ipv6-1.14.patch | 1233 | ||||
-rw-r--r-- | core/tcp_wrappers/try-from.8 | 28 |
16 files changed, 2697 insertions, 0 deletions
diff --git a/core/tcp_wrappers/01_all_redhat-bug11881.patch b/core/tcp_wrappers/01_all_redhat-bug11881.patch new file mode 100644 index 000000000..0c869b4a4 --- /dev/null +++ b/core/tcp_wrappers/01_all_redhat-bug11881.patch @@ -0,0 +1,35 @@ +--- tcp_wrappers_7.6/tcpd.c.bug11881 Thu Jul 27 15:39:27 2000 ++++ tcp_wrappers_7.6/tcpd.c Thu Jul 27 15:41:54 2000 +@@ -60,10 +60,10 @@ + */ + + if (argv[0][0] == '/') { +- strcpy(path, argv[0]); ++ strncpy(path, argv[0], sizeof(path)); + argv[0] = strrchr(argv[0], '/') + 1; + } else { +- sprintf(path, "%s/%s", REAL_DAEMON_DIR, argv[0]); ++ snprintf(path, sizeof(path), "%s/%s", REAL_DAEMON_DIR, argv[0]); + } + + /* +--- tcp_wrappers_7.6/eval.c.bug11881 Thu Jul 27 15:39:53 2000 ++++ tcp_wrappers_7.6/eval.c Thu Jul 27 15:40:51 2000 +@@ -111,7 +111,7 @@ + return (hostinfo); + #endif + if (STR_NE(eval_user(request), unknown)) { +- sprintf(both, "%s@%s", request->user, hostinfo); ++ snprintf(both, sizeof(both), "%s@%s", request->user, hostinfo); + return (both); + } else { + return (hostinfo); +@@ -128,7 +128,7 @@ + char *daemon = eval_daemon(request); + + if (STR_NE(host, unknown)) { +- sprintf(both, "%s@%s", daemon, host); ++ snprintf(both, sizeof(both), "%s@%s", daemon, host); + return (both); + } else { + return (daemon); diff --git a/core/tcp_wrappers/02_all_redhat-bug17795.patch b/core/tcp_wrappers/02_all_redhat-bug17795.patch new file mode 100644 index 000000000..ff0ec455b --- /dev/null +++ b/core/tcp_wrappers/02_all_redhat-bug17795.patch @@ -0,0 +1,49 @@ +--- hosts_access.c Wed Feb 12 03:13:23 1997 ++++ hosts_access.c Wed Jul 19 08:37:02 2000 +@@ -240,6 +255,26 @@ + } + } + ++/* hostfile_match - look up host patterns from file */ ++ ++static int hostfile_match(path, host) ++char *path; ++struct hosts_info *host; ++{ ++ char tok[BUFSIZ]; ++ int match = NO; ++ FILE *fp; ++ ++ if ((fp = fopen(path, "r")) != 0) { ++ while (fscanf(fp, "%s", tok) == 1 && !(match = host_match(tok, host))) ++ /* void */ ; ++ fclose(fp); ++ } else if (errno != ENOENT) { ++ tcpd_warn("open %s: %m", path); ++ } ++ return (match); ++} ++ + /* host_match - match host name and/or address against pattern */ + + static int host_match(tok, host) +@@ -267,6 +302,8 @@ + tcpd_warn("netgroup support is disabled"); /* not tcpd_jump() */ + return (NO); + #endif ++ } else if (tok[0] == '/') { /* /file hack */ ++ return (hostfile_match(tok, host)); + } else if (STR_EQ(tok, "KNOWN")) { /* check address and name */ + char *name = eval_hostname(host); + return (STR_NE(eval_hostaddr(host), unknown) && HOSTNAME_KNOWN(name)); +--- hosts_access.5 2003-08-03 19:09:56.000000000 +0000 ++++ hosts_access.5 2003-08-03 19:13:32.000000000 +0000 +@@ -91,0 +92,7 @@ ++.IP \(bu ++A string that begins with a `/\' character is treated as a file ++name. A host name or address is matched if it matches any host name ++or address pattern listed in the named file. The file format is ++zero or more lines with zero or more host name or address patterns ++separated by whitespace. A file name pattern can be used anywhere ++a host name or address pattern can be used. + diff --git a/core/tcp_wrappers/03_all_wildcard.patch b/core/tcp_wrappers/03_all_wildcard.patch new file mode 100644 index 000000000..44eec476e --- /dev/null +++ b/core/tcp_wrappers/03_all_wildcard.patch @@ -0,0 +1,93 @@ +--- /tmp/hosts_access.c 2003-08-03 22:18:00.000000000 +0000 ++++ hosts_access.c 2003-08-03 22:39:44.000000000 +0000 +@@ -289,6 +289,17 @@ + { + int n; + ++#ifndef DISABLE_WILDCARD_MATCHING ++ if (strchr(tok, '*') || strchr(tok,'?')) { /* contains '*' or '?' */ ++ /* we must convert the both to lowercase as match_pattern_ylo is case-sensitive */ ++ for (n = 0; n < strlen(tok); n++) ++ tok[n] = isupper(tok[n]) ? tolower(tok[n]) : tok[n]; ++ for (n = 0; n < strlen(string); n++) ++ string[n] = isupper(string[n]) ? tolower(string[n]) : string[n]; ++ return (match_pattern_ylo(string,tok)); ++ } else ++#endif ++ + if (tok[0] == '.') { /* suffix */ + n = strlen(string) - strlen(tok); + return (n > 0 && STR_EQ(tok, string + n)); +@@ -329,3 +340,72 @@ + } + return ((addr & mask) == net); + } ++ ++#ifndef DISABLE_WILDCARD_MATCHING ++/* Note: this feature has been adapted in a pretty straightforward way ++ from Tatu Ylonen's last SSH version under free license by ++ Pekka Savola <pekkas@netcore.fi>. ++ ++ Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland ++*/ ++ ++/* Returns true if the given string matches the pattern (which may contain ++ ? and * as wildcards), and zero if it does not match. */ ++ ++int match_pattern_ylo(const char *s, const char *pattern) ++{ ++ while (1) ++ { ++ /* If at end of pattern, accept if also at end of string. */ ++ if (!*pattern) ++ return !*s; ++ ++ /* Process '*'. */ ++ if (*pattern == '*') ++ { ++ /* Skip the asterisk. */ ++ pattern++; ++ ++ /* If at end of pattern, accept immediately. */ ++ if (!*pattern) ++ return 1; ++ ++ /* If next character in pattern is known, optimize. */ ++ if (*pattern != '?' && *pattern != '*') ++ { ++ /* Look instances of the next character in pattern, and try ++ to match starting from those. */ ++ for (; *s; s++) ++ if (*s == *pattern && ++ match_pattern_ylo(s + 1, pattern + 1)) ++ return 1; ++ /* Failed. */ ++ return 0; ++ } ++ ++ /* Move ahead one character at a time and try to match at each ++ position. */ ++ for (; *s; s++) ++ if (match_pattern_ylo(s, pattern)) ++ return 1; ++ /* Failed. */ ++ return 0; ++ } ++ ++ /* There must be at least one more character in the string. If we are ++ at the end, fail. */ ++ if (!*s) ++ return 0; ++ ++ /* Check if the next character of the string is acceptable. */ ++ if (*pattern != '?' && *pattern != *s) ++ return 0; ++ ++ /* Move to the next character, both in string and in pattern. */ ++ s++; ++ pattern++; ++ } ++ /*NOTREACHED*/ ++} ++#endif /* DISABLE_WILDCARD_MATCHING */ ++ diff --git a/core/tcp_wrappers/04_all_fixgethostbyname.patch b/core/tcp_wrappers/04_all_fixgethostbyname.patch new file mode 100644 index 000000000..57c7acf78 --- /dev/null +++ b/core/tcp_wrappers/04_all_fixgethostbyname.patch @@ -0,0 +1,27 @@ +--- tcp_wrappers_7.6/socket.c.fixgethostbyname Fri Mar 21 13:27:25 1997 ++++ tcp_wrappers_7.6/socket.c Mon Feb 5 14:09:40 2001 +@@ -52,7 +52,8 @@ + char *name; + { + char dot_name[MAXHOSTNAMELEN + 1]; +- ++ struct hostent *hp; ++ + /* + * Don't append dots to unqualified names. Such names are likely to come + * from local hosts files or from NIS. +@@ -61,8 +62,12 @@ + if (strchr(name, '.') == 0 || strlen(name) >= MAXHOSTNAMELEN - 1) { + return (gethostbyname(name)); + } else { +- sprintf(dot_name, "%s.", name); +- return (gethostbyname(dot_name)); ++ sprintf(dot_name, "%s.", name); ++ hp = gethostbyname(dot_name); ++ if (hp) ++ return hp; ++ else ++ return (gethostbyname(name)); + } + } + diff --git a/core/tcp_wrappers/07_all_sig.patch b/core/tcp_wrappers/07_all_sig.patch new file mode 100644 index 000000000..e7341a0bc --- /dev/null +++ b/core/tcp_wrappers/07_all_sig.patch @@ -0,0 +1,39 @@ +--- tcp_wrappers_7.6/hosts_access.c.sig 2003-02-10 16:18:31.000000000 +0100 ++++ tcp_wrappers_7.6/hosts_access.c 2003-02-10 16:50:38.000000000 +0100 +@@ -66,6 +66,7 @@ + + #define YES 1 + #define NO 0 ++#define ERR -1 + + /* + * These variables are globally visible so that they can be redirected in +@@ -106,7 +107,6 @@ + struct request_info *request; + { + int verdict; +- + /* + * If the (daemon, client) pair is matched by an entry in the file + * /etc/hosts.allow, access is granted. Otherwise, if the (daemon, +@@ -129,9 +129,9 @@ + return (verdict == AC_PERMIT); + if (table_match(hosts_allow_table, request)) + return (YES); +- if (table_match(hosts_deny_table, request)) +- return (NO); +- return (YES); ++ if (table_match(hosts_deny_table, request) == NO) ++ return (YES); ++ return (NO); + } + + /* table_match - match table entries with (daemon, client) pair */ +@@ -175,6 +175,7 @@ + (void) fclose(fp); + } else if (errno != ENOENT) { + tcpd_warn("cannot open %s: %m", table); ++ match = ERR; + } + if (match) { + if (hosts_access_verbose > 1) diff --git a/core/tcp_wrappers/08_all_strerror.patch b/core/tcp_wrappers/08_all_strerror.patch new file mode 100644 index 000000000..426791a8f --- /dev/null +++ b/core/tcp_wrappers/08_all_strerror.patch @@ -0,0 +1,27 @@ +--- tcp-wrappers-7.6/percent_m.c ++++ tcp-wrappers-7.6/percent_m.c +@@ -13,7 +13,7 @@ + #include <string.h> + + extern int errno; +-#ifndef SYS_ERRLIST_DEFINED ++#if !defined(SYS_ERRLIST_DEFINED) && !defined(HAVE_STRERROR) + extern char *sys_errlist[]; + extern int sys_nerr; + #endif +@@ -29,11 +29,15 @@ + + while (*bp = *cp) + if (*cp == '%' && cp[1] == 'm') { ++#ifdef HAVE_STRERROR ++ strcpy(bp, strerror(errno)); ++#else + if (errno < sys_nerr && errno > 0) { + strcpy(bp, sys_errlist[errno]); + } else { + sprintf(bp, "Unknown error %d", errno); + } ++#endif + bp += strlen(bp); + cp += 2; + } else { diff --git a/core/tcp_wrappers/09_all_gcc-3.4.patch b/core/tcp_wrappers/09_all_gcc-3.4.patch new file mode 100644 index 000000000..30d105915 --- /dev/null +++ b/core/tcp_wrappers/09_all_gcc-3.4.patch @@ -0,0 +1,12 @@ +diff -udrN tcp_wrappers_7.6/scaffold.c tcp_wrappers_7.6_modified/scaffold.c +--- tcp_wrappers_7.6/scaffold.c 2004-04-20 23:35:41.971925008 +0000 ++++ tcp_wrappers_7.6_modified/scaffold.c 2004-04-20 23:44:28.553872384 +0000 +@@ -25,7 +25,7 @@ + #define INADDR_NONE (-1) /* XXX should be 0xffffffff */ + #endif + +-extern char *malloc(); ++ + + /* Application-specific. */ + diff --git a/core/tcp_wrappers/10_all_more-headers.patch b/core/tcp_wrappers/10_all_more-headers.patch new file mode 100644 index 000000000..7a43c6ceb --- /dev/null +++ b/core/tcp_wrappers/10_all_more-headers.patch @@ -0,0 +1,209 @@ +--- tcp_wrappers_7.6/options.c ++++ tcp_wrappers_7.6/options.c +@@ -34,6 +34,8 @@ + + /* System libraries. */ + ++#include <unistd.h> ++#include <stdlib.h> + #include <sys/types.h> + #include <sys/param.h> + #include <sys/socket.h> +--- tcp_wrappers_7.6/safe_finger.c ++++ tcp_wrappers_7.6/safe_finger.c +@@ -20,6 +20,10 @@ + + /* System libraries */ + ++#include <unistd.h> ++#include <fcntl.h> ++#include <stdlib.h> ++#include <sys/wait.h> + #include <sys/types.h> + #include <sys/stat.h> + #include <signal.h> +@@ -27,7 +31,7 @@ + #include <ctype.h> + #include <pwd.h> + +-extern void exit(); ++int pipe_stdin(char **argv); + + /* Local stuff */ + +--- tcp_wrappers_7.6/scaffold.c ++++ tcp_wrappers_7.6/scaffold.c +@@ -10,6 +10,7 @@ + + /* System libraries. */ + ++#include <stdlib.h> + #include <sys/types.h> + #include <sys/stat.h> + #include <sys/socket.h> +--- tcp_wrappers_7.6/shell_cmd.c ++++ tcp_wrappers_7.6/shell_cmd.c +@@ -14,6 +14,10 @@ + + /* System libraries. */ + ++#include <unistd.h> ++#include <stdlib.h> ++#include <fcntl.h> ++#include <sys/wait.h> + #include <sys/types.h> + #include <sys/param.h> + #include <signal.h> +@@ -25,8 +25,6 @@ + #include <syslog.h> + #include <string.h> + +-extern void exit(); +- + /* Local stuff. */ + + #include "tcpd.h" +--- tcp_wrappers_7.6/tcpdchk.c ++++ tcp_wrappers_7.6/tcpdchk.c +@@ -20,6 +20,8 @@ + + /* System libraries. */ + ++#include <unistd.h> ++#include <stdlib.h> + #include <sys/types.h> + #include <sys/stat.h> + #ifdef INET6 +@@ -35,11 +36,6 @@ + #include <netdb.h> + #include <string.h> + +-extern int errno; +-extern void exit(); +-extern int optind; +-extern char *optarg; +- + #ifndef INADDR_NONE + #define INADDR_NONE (-1) /* XXX should be 0xffffffff */ + #endif +--- tcp_wrappers_7.6/clean_exit.c ++++ tcp_wrappers_7.6/clean_exit.c +@@ -13,8 +13,8 @@ + #endif + + #include <stdio.h> +- +-extern void exit(); ++#include <unistd.h> ++#include <stdlib.h> + + #include "tcpd.h" + +--- tcp_wrappers_7.6/hosts_access.c ++++ tcp_wrappers_7.6/hosts_access.c +@@ -23,6 +23,7 @@ + + /* System libraries. */ + ++#include <stdlib.h> + #include <sys/types.h> + #ifdef INT32_T + typedef uint32_t u_int32_t; +@@ -43,8 +44,7 @@ + #include <netdb.h> + #endif + +-extern char *fgets(); +-extern int errno; ++int match_pattern_ylo(const char *s, const char *pattern); + + #ifndef INADDR_NONE + #define INADDR_NONE (-1) /* XXX should be 0xffffffff */ +--- tcp_wrappers_7.6/inetcf.c ++++ tcp_wrappers_7.6/inetcf.c +@@ -9,15 +9,14 @@ + static char sccsid[] = "@(#) inetcf.c 1.7 97/02/12 02:13:23"; + #endif + ++#include <stdlib.h> + #include <sys/types.h> + #include <sys/stat.h> + #include <stdio.h> + #include <errno.h> + #include <string.h> + +-extern int errno; +-extern void exit(); +- ++#include "scaffold.h" + #include "tcpd.h" + #include "inetcf.h" + +--- tcp_wrappers_7.6/percent_x.c ++++ tcp_wrappers_7.6/percent_x.c +@@ -16,12 +16,12 @@ + + /* System libraries. */ + ++#include <unistd.h> ++#include <stdlib.h> + #include <stdio.h> + #include <syslog.h> + #include <string.h> + +-extern void exit(); +- + /* Local stuff. */ + + #include "tcpd.h" +--- tcp_wrappers_7.6/rfc931.c ++++ tcp_wrappers_7.6/rfc931.c +@@ -15,6 +15,7 @@ + + /* System libraries. */ + ++#include <unistd.h> + #include <stdio.h> + #include <syslog.h> + #include <sys/types.h> +--- tcp_wrappers_7.6/tcpd.c ++++ tcp_wrappers_7.6/tcpd.c +@@ -16,6 +16,7 @@ + + /* System libraries. */ + ++#include <unistd.h> + #include <sys/types.h> + #include <sys/param.h> + #include <sys/stat.h> +--- tcp_wrappers_7.6/tcpdmatch.c ++++ tcp_wrappers_7.6/tcpdmatch.c +@@ -19,6 +19,8 @@ + + /* System libraries. */ + ++#include <unistd.h> ++#include <stdlib.h> + #include <sys/types.h> + #include <sys/stat.h> + #include <sys/socket.h> +@@ -30,9 +32,6 @@ + #include <setjmp.h> + #include <string.h> + +-extern void exit(); +-extern int optind; +-extern char *optarg; + + #ifndef INADDR_NONE + #define INADDR_NONE (-1) /* XXX should be 0xffffffff */ +--- tcp_wrappers_7.6/update.c ++++ tcp_wrappers_7.6/update.c +@@ -19,6 +19,7 @@ + + /* System libraries */ + ++#include <unistd.h> + #include <stdio.h> + #include <syslog.h> + #include <string.h> diff --git a/core/tcp_wrappers/11_inet6_fixes.patch b/core/tcp_wrappers/11_inet6_fixes.patch new file mode 100644 index 000000000..a2c7d99a5 --- /dev/null +++ b/core/tcp_wrappers/11_inet6_fixes.patch @@ -0,0 +1,41 @@ +--- Makefile.old 2009-10-28 10:37:40.138328073 +0100 ++++ Makefile 2009-10-28 10:37:57.014326831 +0100 +@@ -154,7 +154,7 @@ + @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \ + LIBS=$(MYLIB) RANLIB=ranlib ARFLAGS=rv AUX_OBJ=weak_symbols.o \ + NETGROUP=-DNETGROUP TLI= VSYSLOG= BUGS= all \ +- EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DHAVE_WEAKSYMS -D_REENTRANT" ++ EXTRA_CFLAGS="-DINET6 -DSYS_ERRLIST_DEFINED -DHAVE_WEAKSYMS -D_REENTRANT" + + gnu: + @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \ +--- tcpd.h.old 2009-10-28 10:48:19.285326834 +0100 ++++ tcpd.h 2009-10-28 10:47:32.951325793 +0100 +@@ -91,7 +91,11 @@ + + extern void shell_cmd __P((char *)); /* execute shell command */ + extern char *percent_x __P((char *, int, char *, struct request_info *)); /* do %<char> expansion */ ++#ifdef INET6 ++extern void rfc931 __P((struct sockaddr *, struct sockaddr *, char *)); /* client name from RFC 931 daemon */ ++#else + extern void rfc931 __P((struct sockaddr_in *, struct sockaddr_in *, char *)); /* client name from RFC 931 daemon */ ++#endif + extern void clean_exit __P((struct request_info *)); /* clean up and exit */ + extern void refuse __P((struct request_info *)); /* clean up and exit */ + extern char *xgets __P((char *, int, FILE *)); /* fgets() on steroids */ +--- scaffold.c.old 2009-10-28 10:50:13.584449353 +0100 ++++ scaffold.c 2009-10-28 10:52:53.765443023 +0100 +@@ -182,8 +237,13 @@ + /* ARGSUSED */ + + void rfc931(rmt_sin, our_sin, dest) ++#ifdef INET6 ++struct sockaddr *rmt_sin; ++struct sockaddr *our_sin; ++#else + struct sockaddr_in *rmt_sin; + struct sockaddr_in *our_sin; ++#endif + char *dest; + { + strcpy(dest, unknown); diff --git a/core/tcp_wrappers/PKGBUILD b/core/tcp_wrappers/PKGBUILD new file mode 100644 index 000000000..9373e9239 --- /dev/null +++ b/core/tcp_wrappers/PKGBUILD @@ -0,0 +1,74 @@ +# $Id: PKGBUILD 89099 2010-08-29 11:15:05Z tpowa $ +# Maintainer: judd <jvinet@zeroflux.org> +pkgname=tcp_wrappers +pkgver=7.6 +pkgrel=12 +pkgdesc="Monitors and Controls incoming TCP connections" +arch=(i686 x86_64) +url="ftp://ftp.porcupine.org/pub/security/index.html" +license=('custom') +groups=('base') +backup=(etc/hosts.allow etc/hosts.deny) +depends=('bash' 'glibc') +source=(ftp://ftp.porcupine.org/pub/security/${pkgname}_$pkgver.tar.gz + hosts.allow + hosts.deny + try-from.8 + safe_finger.8 + shared_lib_plus_plus-1.patch + 01_all_redhat-bug11881.patch + 02_all_redhat-bug17795.patch + 03_all_wildcard.patch + 04_all_fixgethostbyname.patch + 07_all_sig.patch + 08_all_strerror.patch + 09_all_gcc-3.4.patch + 10_all_more-headers.patch + 11_inet6_fixes.patch + tcp-wrappers-7.6-ipv6-1.14.patch) +md5sums=('e6fa25f71226d090f34de3f6b122fb5a' + '32cfeeed797161034f62bb45f3167baa' + 'e4743ca604a1749c7312f9283b4bb0d1' + '4a8f40f9a69f0848df92b232072e8561' + '1a6d7b11abb1fd69ace775d02a1c72cf' + '99345104130b91cb151af9d87eee1449' + 'e7ac7ae271703eacf175d597d329e11a' + '2790301fbf1b4711e75d5b799b6d4ac8' + 'd286da9fca993f8afa89631133312151' + '97d4d81faaecf0958eeb52c45df71e34' + '374b8179b8d5c71979008c6a775d658e' + '801292cacf14a92e2784b925e72a1db1' + '0978932f49aae33834a46e189ace7d77' + '68b1c7f82fed60b446b00f6de27c3b9f' + 'bd0af9dedcacd594e0715de800fc1b57' + '9154c38e3fb69d12b5bfb2fc5284314f') + +build() { + cd $srcdir/${pkgname}_$pkgver + # add gentoo / fedora / redhat patches + patch -Np1 -i ../shared_lib_plus_plus-1.patch + patch -Np1 -i ../01_all_redhat-bug11881.patch + patch -Np0 -i ../02_all_redhat-bug17795.patch + patch -Np0 -i ../03_all_wildcard.patch + patch -Np1 -i ../04_all_fixgethostbyname.patch + patch -Np1 -i ../07_all_sig.patch + patch -Np1 -i ../09_all_gcc-3.4.patch + patch -Np1 -i ../10_all_more-headers.patch + patch -Np0 -i ../11_inet6_fixes.patch + patch -Np2 -i ../tcp-wrappers-7.6-ipv6-1.14.patch + + make REAL_DAEMON_DIR=/usr/sbin STYLE=-DPROCESS_OPTIONS linux + # dumb makefile + mkdir -p $pkgdir/usr/{include,lib,sbin} + mkdir -p $pkgdir/usr/share/man/man{3,5,8} + make DESTDIR=$pkgdir install + install -D -m644 ../hosts.allow $pkgdir/etc/hosts.allow + install -D -m644 ../hosts.deny $pkgdir/etc/hosts.deny + # add manpage symlinks for hosts.deny and hosts.allow + cd $pkgdir/usr/share/man/man5 + ln -s hosts_access.5.gz hosts.allow.5.gz + ln -s hosts_access.5.gz hosts.deny.5.gz + # install license + mkdir -p $pkgdir/usr/share/licenses/$pkgname + install -m644 $srcdir/${pkgname}_$pkgver/DISCLAIMER $pkgdir/usr/share/licenses/$pkgname/license.txt +} diff --git a/core/tcp_wrappers/hosts.allow b/core/tcp_wrappers/hosts.allow new file mode 100644 index 000000000..e5c035d65 --- /dev/null +++ b/core/tcp_wrappers/hosts.allow @@ -0,0 +1,5 @@ +# +# /etc/hosts.allow +# + +# End of file diff --git a/core/tcp_wrappers/hosts.deny b/core/tcp_wrappers/hosts.deny new file mode 100644 index 000000000..cbb00b29d --- /dev/null +++ b/core/tcp_wrappers/hosts.deny @@ -0,0 +1,7 @@ +# +# /etc/hosts.deny +# + +ALL: ALL + +# End of file diff --git a/core/tcp_wrappers/safe_finger.8 b/core/tcp_wrappers/safe_finger.8 new file mode 100644 index 000000000..875616b9e --- /dev/null +++ b/core/tcp_wrappers/safe_finger.8 @@ -0,0 +1,34 @@ +.TH SAFE_FINGER 8 "21th June 1997" Linux "Linux Programmer's Manual" +.SH NAME +safe_finger \- finger client wrapper that protects against nasty stuff +from finger servers +.SH SYNOPSIS +.B safe_finger [finger_options] +.SH DESCRIPTION +The +.B safe_finger +command protects against nasty stuff from finger servers. Use this +program for automatic reverse finger probes from the +.B tcp_wrapper +.B (tcpd) +, not the raw finger command. The +.B safe_finger +command makes sure that the finger client is not run with root +privileges. It also runs the finger client with a defined PATH +environment. +.B safe_finger +will also protect you from problems caused by the output of some +finger servers. The problem: some programs may react to stuff in +the first column. Other programs may get upset by thrash anywhere +on a line. File systems may fill up as the finger server keeps +sending data. Text editors may bomb out on extremely long lines. +The finger server may take forever because it is somehow wedged. +.B safe_finger +takes care of all this badness. +.SH SEE ALSO +.BR hosts_access (5), +.BR hosts_options (5), +.BR tcpd (8) +.SH AUTHOR +Wietse Venema, Eindhoven University of Technology, The Netherlands. + diff --git a/core/tcp_wrappers/shared_lib_plus_plus-1.patch b/core/tcp_wrappers/shared_lib_plus_plus-1.patch new file mode 100644 index 000000000..b714899a0 --- /dev/null +++ b/core/tcp_wrappers/shared_lib_plus_plus-1.patch @@ -0,0 +1,784 @@ +diff -Naur tcp_wrappers_7.6/Makefile tcp_wrappers_7.6.gimli/Makefile +--- tcp_wrappers_7.6/Makefile 1997-03-21 12:27:21.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/Makefile 2002-07-15 16:07:21.000000000 -0500 +@@ -1,5 +1,10 @@ ++GLIBC=$(shell grep -s -c __GLIBC__ /usr/include/features.h) ++ + # @(#) Makefile 1.23 97/03/21 19:27:20 + ++# unset the HOSTNAME environment variable ++HOSTNAME = ++ + what: + @echo + @echo "Usage: edit the REAL_DAEMON_DIR definition in the Makefile then:" +@@ -19,7 +24,7 @@ + @echo " generic (most bsd-ish systems with sys5 compatibility)" + @echo " 386bsd aix alpha apollo bsdos convex-ultranet dell-gcc dgux dgux543" + @echo " dynix epix esix freebsd hpux irix4 irix5 irix6 isc iunix" +- @echo " linux machten mips(untested) ncrsvr4 netbsd next osf power_unix_211" ++ @echo " linux gnu machten mips(untested) ncrsvr4 netbsd next osf power_unix_211" + @echo " ptx-2.x ptx-generic pyramid sco sco-nis sco-od2 sco-os5 sinix sunos4" + @echo " sunos40 sunos5 sysv4 tandem ultrix unicos7 unicos8 unixware1 unixware2" + @echo " uts215 uxp" +@@ -43,8 +48,8 @@ + # Ultrix 4.x SunOS 4.x ConvexOS 10.x Dynix/ptx + #REAL_DAEMON_DIR=/usr/etc + # +-# SysV.4 Solaris 2.x OSF AIX +-#REAL_DAEMON_DIR=/usr/sbin ++# SysV.4 Solaris 2.x OSF AIX Linux ++REAL_DAEMON_DIR=/usr/sbin + # + # BSD 4.4 + #REAL_DAEMON_DIR=/usr/libexec +@@ -141,10 +146,21 @@ + LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ= NETGROUP= TLI= \ + EXTRA_CFLAGS=-DSYS_ERRLIST_DEFINED VSYSLOG= all + ++ifneq ($(GLIBC),0) ++MYLIB=-lnsl ++endif ++ + linux: + @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \ +- LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ=setenv.o \ +- NETGROUP= TLI= EXTRA_CFLAGS="-DBROKEN_SO_LINGER" all ++ LIBS=$(MYLIB) RANLIB=ranlib ARFLAGS=rv AUX_OBJ=weak_symbols.o \ ++ NETGROUP=-DNETGROUP TLI= VSYSLOG= BUGS= all \ ++ EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DHAVE_WEAKSYMS -D_REENTRANT" ++ ++gnu: ++ @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \ ++ LIBS=$(MYLIB) RANLIB=ranlib ARFLAGS=rv AUX_OBJ=weak_symbols.o \ ++ NETGROUP=-DNETGROUP TLI= VSYSLOG= BUGS= all \ ++ EXTRA_CFLAGS="-DHAVE_STRERROR -DHAVE_WEAKSYMS -D_REENTRANT" + + # This is good for many SYSV+BSD hybrids with NIS, probably also for HP-UX 7.x. + hpux hpux8 hpux9 hpux10: +@@ -391,7 +407,7 @@ + # the ones provided with this source distribution. The environ.c module + # implements setenv(), getenv(), and putenv(). + +-AUX_OBJ= setenv.o ++#AUX_OBJ= setenv.o + #AUX_OBJ= environ.o + #AUX_OBJ= environ.o strcasecmp.o + +@@ -454,7 +470,8 @@ + # host name aliases. Compile with -DSOLARIS_24_GETHOSTBYNAME_BUG to work + # around this. The workaround does no harm on other Solaris versions. + +-BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DLIBC_CALLS_STRTOK ++BUGS = ++#BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DLIBC_CALLS_STRTOK + #BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DINET_ADDR_BUG + #BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DSOLARIS_24_GETHOSTBYNAME_BUG + +@@ -464,7 +481,7 @@ + # If your system supports NIS or YP-style netgroups, enable the following + # macro definition. Netgroups are used only for host access control. + # +-#NETGROUP= -DNETGROUP ++NETGROUP= -DNETGROUP + + ############################################################### + # System dependencies: whether or not your system has vsyslog() +@@ -491,7 +508,7 @@ + # Uncomment the next definition to turn on the language extensions + # (examples: allow, deny, banners, twist and spawn). + # +-#STYLE = -DPROCESS_OPTIONS # Enable language extensions. ++STYLE = -DPROCESS_OPTIONS # Enable language extensions. + + ################################################################ + # Optional: Changing the default disposition of logfile records +@@ -514,7 +531,7 @@ + # + # The LOG_XXX names below are taken from the /usr/include/syslog.h file. + +-FACILITY= LOG_MAIL # LOG_MAIL is what most sendmail daemons use ++FACILITY= LOG_DAEMON # LOG_MAIL is what most sendmail daemons use + + # The syslog priority at which successful connections are logged. + +@@ -610,7 +627,7 @@ + # Paranoid mode implies hostname lookup. In order to disable hostname + # lookups altogether, see the next section. + +-PARANOID= -DPARANOID ++#PARANOID= -DPARANOID + + ######################################## + # Optional: turning off hostname lookups +@@ -623,7 +640,7 @@ + # In order to perform selective hostname lookups, disable paranoid + # mode (see previous section) and comment out the following definition. + +-HOSTNAME= -DALWAYS_HOSTNAME ++#HOSTNAME= -DALWAYS_HOSTNAME + + ############################################# + # Optional: Turning on host ADDRESS checking +@@ -649,28 +666,46 @@ + # source-routed traffic in the kernel. Examples: 4.4BSD derivatives, + # Solaris 2.x, and Linux. See your system documentation for details. + # +-# KILL_OPT= -DKILL_IP_OPTIONS ++KILL_OPT= -DKILL_IP_OPTIONS + + ## End configuration options + ############################ + + # Protection against weird shells or weird make programs. + ++CC = gcc + SHELL = /bin/sh +-.c.o:; $(CC) $(CFLAGS) -c $*.c ++.c.o:; $(CC) $(CFLAGS) -o $*.o -c $*.c ++ ++SOMAJOR = 0 ++SOMINOR = 7.6 ++ ++LIB = libwrap.a ++SHLIB = shared/libwrap.so.$(SOMAJOR).$(SOMINOR) ++SHLIBSOMAJ= shared/libwrap.so.$(SOMAJOR) ++SHLIBSO = shared/libwrap.so ++SHLIBFLAGS = -Lshared -lwrap + +-CFLAGS = -O -DFACILITY=$(FACILITY) $(ACCESS) $(PARANOID) $(NETGROUP) \ ++shared/%.o: %.c ++ $(CC) $(CFLAGS) $(SHCFLAGS) -c $< -o $@ ++ ++CFLAGS = -O2 -DFACILITY=$(FACILITY) $(ACCESS) $(PARANOID) $(NETGROUP) \ + $(BUGS) $(SYSTYPE) $(AUTH) $(UMASK) \ + -DREAL_DAEMON_DIR=\"$(REAL_DAEMON_DIR)\" $(STYLE) $(KILL_OPT) \ + -DSEVERITY=$(SEVERITY) -DRFC931_TIMEOUT=$(RFC931_TIMEOUT) \ + $(UCHAR) $(TABLES) $(STRINGS) $(TLI) $(EXTRA_CFLAGS) $(DOT) \ + $(VSYSLOG) $(HOSTNAME) + ++SHLINKFLAGS = -shared -Xlinker -soname -Xlinker libwrap.so.$(SOMAJOR) -lc $(LIBS) ++SHCFLAGS = -fPIC -shared -D_REENTRANT ++ + LIB_OBJ= hosts_access.o options.o shell_cmd.o rfc931.o eval.o \ + hosts_ctl.o refuse.o percent_x.o clean_exit.o $(AUX_OBJ) \ + $(FROM_OBJ) fix_options.o socket.o tli.o workarounds.o \ + update.o misc.o diag.o percent_m.o myvsyslog.o + ++SHLIB_OBJ= $(addprefix shared/, $(LIB_OBJ)); ++ + FROM_OBJ= fromhost.o + + KIT = README miscd.c tcpd.c fromhost.c hosts_access.c shell_cmd.c \ +@@ -684,46 +719,80 @@ + refuse.c tcpdchk.8 setenv.c inetcf.c inetcf.h scaffold.c \ + scaffold.h tcpdmatch.8 README.NIS + +-LIB = libwrap.a +- +-all other: config-check tcpd tcpdmatch try-from safe_finger tcpdchk ++all other: config-check tcpd tcpdmatch try-from safe_finger tcpdchk $(LIB) + + # Invalidate all object files when the compiler options (CFLAGS) have changed. + + config-check: + @set +e; test -n "$(REAL_DAEMON_DIR)" || { make; exit 1; } +- @set +e; echo $(CFLAGS) >/tmp/cflags.$$$$ ; \ +- if cmp cflags /tmp/cflags.$$$$ ; \ +- then rm /tmp/cflags.$$$$ ; \ +- else mv /tmp/cflags.$$$$ cflags ; \ ++ @set +e; echo $(CFLAGS) >cflags.new ; \ ++ if cmp cflags cflags.new ; \ ++ then rm cflags.new ; \ ++ else mv cflags.new cflags ; \ + fi >/dev/null 2>/dev/null ++ @if [ ! -d shared ]; then mkdir shared; fi + + $(LIB): $(LIB_OBJ) + rm -f $(LIB) + $(AR) $(ARFLAGS) $(LIB) $(LIB_OBJ) + -$(RANLIB) $(LIB) + +-tcpd: tcpd.o $(LIB) +- $(CC) $(CFLAGS) -o $@ tcpd.o $(LIB) $(LIBS) ++$(SHLIB): $(SHLIB_OBJ) ++ rm -f $(SHLIB) ++ $(CC) -o $(SHLIB) $(SHLINKFLAGS) $(SHLIB_OBJ) ++ ln -s $(notdir $(SHLIB)) $(SHLIBSOMAJ) ++ ln -s $(notdir $(SHLIBSOMAJ)) $(SHLIBSO) ++ ++tcpd: tcpd.o $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ tcpd.o $(SHLIBFLAGS) + +-miscd: miscd.o $(LIB) +- $(CC) $(CFLAGS) -o $@ miscd.o $(LIB) $(LIBS) ++miscd: miscd.o $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ miscd.o $(SHLIBFLAGS) + +-safe_finger: safe_finger.o $(LIB) +- $(CC) $(CFLAGS) -o $@ safe_finger.o $(LIB) $(LIBS) ++safe_finger: safe_finger.o $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ safe_finger.o $(SHLIBFLAGS) + + TCPDMATCH_OBJ = tcpdmatch.o fakelog.o inetcf.o scaffold.o + +-tcpdmatch: $(TCPDMATCH_OBJ) $(LIB) +- $(CC) $(CFLAGS) -o $@ $(TCPDMATCH_OBJ) $(LIB) $(LIBS) ++tcpdmatch: $(TCPDMATCH_OBJ) $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ $(TCPDMATCH_OBJ) $(SHLIBFLAGS) + +-try-from: try-from.o fakelog.o $(LIB) +- $(CC) $(CFLAGS) -o $@ try-from.o fakelog.o $(LIB) $(LIBS) ++try-from: try-from.o fakelog.o $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ try-from.o fakelog.o $(SHLIBFLAGS) + + TCPDCHK_OBJ = tcpdchk.o fakelog.o inetcf.o scaffold.o + +-tcpdchk: $(TCPDCHK_OBJ) $(LIB) +- $(CC) $(CFLAGS) -o $@ $(TCPDCHK_OBJ) $(LIB) $(LIBS) ++tcpdchk: $(TCPDCHK_OBJ) $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ $(TCPDCHK_OBJ) $(SHLIBFLAGS) ++ ++install: install-lib install-bin install-dev ++ ++install-lib: ++ install -o root -g root -m 0755 $(SHLIB) ${DESTDIR}/usr/lib/ ++ ln -sf $(notdir $(SHLIB)) ${DESTDIR}/usr/lib/$(notdir $(SHLIBSOMAJ)) ++ ln -sf $(notdir $(SHLIBSOMAJ)) ${DESTDIR}/usr/lib/$(notdir $(SHLIBSO)) ++ ++install-bin: ++ install -o root -g root -m 0755 tcpd ${DESTDIR}/usr/sbin/ ++ install -o root -g root -m 0755 tcpdchk ${DESTDIR}/usr/sbin/ ++ install -o root -g root -m 0755 tcpdmatch ${DESTDIR}/usr/sbin/ ++ install -o root -g root -m 0755 try-from ${DESTDIR}/usr/sbin/ ++ install -o root -g root -m 0755 safe_finger ${DESTDIR}/usr/sbin/ ++ install -o root -g root -m 0644 tcpd.8 ${DESTDIR}/usr/share/man/man8/ ++ install -o root -g root -m 0644 tcpdchk.8 ${DESTDIR}/usr/share/man/man8/ ++ install -o root -g root -m 0644 try-from.8 ${DESTDIR}/usr/share/man/man8/ ++ install -o root -g root -m 0644 tcpdmatch.8 ${DESTDIR}/usr/share/man/man8/ ++ install -o root -g root -m 0644 safe_finger.8 ${DESTDIR}/usr/share/man/man8/ ++ install -o root -g root -m 0644 hosts_access.5 ${DESTDIR}/usr/share/man/man5/ ++ install -o root -g root -m 0644 hosts_options.5 ${DESTDIR}/usr/share/man/man5/ ++ ++install-dev: ++ install -o root -g root -m 0644 hosts_access.3 ${DESTDIR}/usr/share/man/man3/ ++ install -o root -g root -m 0644 tcpd.h ${DESTDIR}/usr/include/ ++ install -o root -g root -m 0644 $(LIB) ${DESTDIR}/usr/lib/ ++ ln -sf hosts_access.3 ${DESTDIR}/usr/share/man/man3/hosts_ctl.3 ++ ln -sf hosts_access.3 ${DESTDIR}/usr/share/man/man3/request_init.3 ++ ln -sf hosts_access.3 ${DESTDIR}/usr/share/man/man3/request_set.3 + + shar: $(KIT) + @shar $(KIT) +@@ -739,7 +808,8 @@ + + clean: + rm -f tcpd miscd safe_finger tcpdmatch tcpdchk try-from *.[oa] core \ +- cflags ++ cflags libwrap*.so* ++ rm -rf shared + + tidy: clean + chmod -R a+r . +@@ -885,5 +955,6 @@ + update.o: mystdarg.h + update.o: tcpd.h + vfprintf.o: cflags ++weak_symbols.o: tcpd.h + workarounds.o: cflags + workarounds.o: tcpd.h +diff -Naur tcp_wrappers_7.6/hosts_access.3 tcp_wrappers_7.6.gimli/hosts_access.3 +--- tcp_wrappers_7.6/hosts_access.3 1996-02-11 10:01:27.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/hosts_access.3 2002-01-07 08:50:19.000000000 -0600 +@@ -3,7 +3,7 @@ + hosts_access, hosts_ctl, request_init, request_set \- access control library + .SH SYNOPSIS + .nf +-#include "tcpd.h" ++#include <tcpd.h> + + extern int allow_severity; + extern int deny_severity; +diff -Naur tcp_wrappers_7.6/hosts_options.5 tcp_wrappers_7.6.gimli/hosts_options.5 +--- tcp_wrappers_7.6/hosts_options.5 1994-12-28 10:42:29.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/hosts_options.5 2002-01-07 08:50:19.000000000 -0600 +@@ -58,12 +58,12 @@ + Execute, in a child process, the specified shell command, after + performing the %<letter> expansions described in the hosts_access(5) + manual page. The command is executed with stdin, stdout and stderr +-connected to the null device, so that it won\'t mess up the ++connected to the null device, so that it won't mess up the + conversation with the client host. Example: + .sp + .nf + .ti +3 +-spawn (/some/where/safe_finger -l @%h | /usr/ucb/mail root) & ++spawn (/usr/sbin/safe_finger -l @%h | /usr/bin/mail root) & + .fi + .sp + executes, in a background child process, the shell command "safe_finger +diff -Naur tcp_wrappers_7.6/options.c tcp_wrappers_7.6.gimli/options.c +--- tcp_wrappers_7.6/options.c 1996-02-11 10:01:32.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/options.c 2002-01-07 08:50:19.000000000 -0600 +@@ -473,6 +473,9 @@ + #ifdef LOG_CRON + "cron", LOG_CRON, + #endif ++#ifdef LOG_FTP ++ "ftp", LOG_FTP, ++#endif + #ifdef LOG_LOCAL0 + "local0", LOG_LOCAL0, + #endif +diff -Naur tcp_wrappers_7.6/percent_m.c tcp_wrappers_7.6.gimli/percent_m.c +--- tcp_wrappers_7.6/percent_m.c 1994-12-28 10:42:37.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/percent_m.c 2002-01-07 08:50:19.000000000 -0600 +@@ -13,7 +13,7 @@ + #include <string.h> + + extern int errno; +-#ifndef SYS_ERRLIST_DEFINED ++#if !defined(SYS_ERRLIST_DEFINED) && !defined(HAVE_STRERROR) + extern char *sys_errlist[]; + extern int sys_nerr; + #endif +@@ -29,11 +29,15 @@ + + while (*bp = *cp) + if (*cp == '%' && cp[1] == 'm') { ++#ifdef HAVE_STRERROR ++ strcpy(bp, strerror(errno)); ++#else + if (errno < sys_nerr && errno > 0) { + strcpy(bp, sys_errlist[errno]); + } else { + sprintf(bp, "Unknown error %d", errno); + } ++#endif + bp += strlen(bp); + cp += 2; + } else { +diff -Naur tcp_wrappers_7.6/rfc931.c tcp_wrappers_7.6.gimli/rfc931.c +--- tcp_wrappers_7.6/rfc931.c 1995-01-02 09:11:34.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/rfc931.c 2002-01-07 08:50:19.000000000 -0600 +@@ -33,7 +33,7 @@ + + int rfc931_timeout = RFC931_TIMEOUT;/* Global so it can be changed */ + +-static jmp_buf timebuf; ++static sigjmp_buf timebuf; + + /* fsocket - open stdio stream on top of socket */ + +@@ -62,7 +62,7 @@ + static void timeout(sig) + int sig; + { +- longjmp(timebuf, sig); ++ siglongjmp(timebuf, sig); + } + + /* rfc931 - return remote user name, given socket structures */ +@@ -99,7 +99,7 @@ + * Set up a timer so we won't get stuck while waiting for the server. + */ + +- if (setjmp(timebuf) == 0) { ++ if (sigsetjmp(timebuf,1) == 0) { + signal(SIGALRM, timeout); + alarm(rfc931_timeout); + +diff -Naur tcp_wrappers_7.6/safe_finger.8 tcp_wrappers_7.6.gimli/safe_finger.8 +--- tcp_wrappers_7.6/safe_finger.8 1969-12-31 18:00:00.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/safe_finger.8 2002-01-07 08:50:19.000000000 -0600 +@@ -0,0 +1,34 @@ ++.TH SAFE_FINGER 8 "21th June 1997" Linux "Linux Programmer's Manual" ++.SH NAME ++safe_finger \- finger client wrapper that protects against nasty stuff ++from finger servers ++.SH SYNOPSIS ++.B safe_finger [finger_options] ++.SH DESCRIPTION ++The ++.B safe_finger ++command protects against nasty stuff from finger servers. Use this ++program for automatic reverse finger probes from the ++.B tcp_wrapper ++.B (tcpd) ++, not the raw finger command. The ++.B safe_finger ++command makes sure that the finger client is not run with root ++privileges. It also runs the finger client with a defined PATH ++environment. ++.B safe_finger ++will also protect you from problems caused by the output of some ++finger servers. The problem: some programs may react to stuff in ++the first column. Other programs may get upset by thrash anywhere ++on a line. File systems may fill up as the finger server keeps ++sending data. Text editors may bomb out on extremely long lines. ++The finger server may take forever because it is somehow wedged. ++.B safe_finger ++takes care of all this badness. ++.SH SEE ALSO ++.BR hosts_access (5), ++.BR hosts_options (5), ++.BR tcpd (8) ++.SH AUTHOR ++Wietse Venema, Eindhoven University of Technology, The Netherlands. ++ +diff -Naur tcp_wrappers_7.6/safe_finger.c tcp_wrappers_7.6.gimli/safe_finger.c +--- tcp_wrappers_7.6/safe_finger.c 1994-12-28 10:42:42.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/safe_finger.c 2002-01-07 08:50:19.000000000 -0600 +@@ -26,21 +26,24 @@ + #include <stdio.h> + #include <ctype.h> + #include <pwd.h> ++#include <syslog.h> + + extern void exit(); + + /* Local stuff */ + +-char path[] = "PATH=/bin:/usr/bin:/usr/ucb:/usr/bsd:/etc:/usr/etc:/usr/sbin"; ++char path[] = "PATH=/bin:/usr/bin:/sbin:/usr/sbin"; + + #define TIME_LIMIT 60 /* Do not keep listinging forever */ + #define INPUT_LENGTH 100000 /* Do not keep listinging forever */ + #define LINE_LENGTH 128 /* Editors can choke on long lines */ + #define FINGER_PROGRAM "finger" /* Most, if not all, UNIX systems */ + #define UNPRIV_NAME "nobody" /* Preferred privilege level */ +-#define UNPRIV_UGID 32767 /* Default uid and gid */ ++#define UNPRIV_UGID 65534 /* Default uid and gid */ + + int finger_pid; ++int allow_severity = SEVERITY; ++int deny_severity = LOG_WARNING; + + void cleanup(sig) + int sig; +diff -Naur tcp_wrappers_7.6/scaffold.c tcp_wrappers_7.6.gimli/scaffold.c +--- tcp_wrappers_7.6/scaffold.c 1997-03-21 12:27:24.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/scaffold.c 2002-01-07 08:50:19.000000000 -0600 +@@ -180,10 +180,12 @@ + + /* ARGSUSED */ + +-void rfc931(request) +-struct request_info *request; ++void rfc931(rmt_sin, our_sin, dest) ++struct sockaddr_in *rmt_sin; ++struct sockaddr_in *our_sin; ++char *dest; + { +- strcpy(request->user, unknown); ++ strcpy(dest, unknown); + } + + /* check_path - examine accessibility */ +diff -Naur tcp_wrappers_7.6/tcpd.8 tcp_wrappers_7.6.gimli/tcpd.8 +--- tcp_wrappers_7.6/tcpd.8 1996-02-21 09:39:16.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/tcpd.8 2002-01-07 08:50:19.000000000 -0600 +@@ -94,7 +94,7 @@ + .PP + The example assumes that the network daemons live in /usr/etc. On some + systems, network daemons live in /usr/sbin or in /usr/libexec, or have +-no `in.\' prefix to their name. ++no `in.' prefix to their name. + .SH EXAMPLE 2 + This example applies when \fItcpd\fR expects that the network daemons + are left in their original place. +@@ -110,26 +110,26 @@ + becomes: + .sp + .ti +5 +-finger stream tcp nowait nobody /some/where/tcpd in.fingerd ++finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd + .sp + .fi + .PP + The example assumes that the network daemons live in /usr/etc. On some + systems, network daemons live in /usr/sbin or in /usr/libexec, the +-daemons have no `in.\' prefix to their name, or there is no userid ++daemons have no `in.' prefix to their name, or there is no userid + field in the inetd configuration file. + .PP + Similar changes will be needed for the other services that are to be +-covered by \fItcpd\fR. Send a `kill -HUP\' to the \fIinetd\fR(8) ++covered by \fItcpd\fR. Send a `kill -HUP' to the \fIinetd\fR(8) + process to make the changes effective. AIX users may also have to +-execute the `inetimp\' command. ++execute the `inetimp' command. + .SH EXAMPLE 3 + In the case of daemons that do not live in a common directory ("secret" + or otherwise), edit the \fIinetd\fR configuration file so that it + specifies an absolute path name for the process name field. For example: + .nf + .sp +- ntalk dgram udp wait root /some/where/tcpd /usr/local/lib/ntalkd ++ ntalk dgram udp wait root /usr/sbin/tcpd /usr/sbin/in.ntalkd + .sp + .fi + .PP +diff -Naur tcp_wrappers_7.6/tcpd.h tcp_wrappers_7.6.gimli/tcpd.h +--- tcp_wrappers_7.6/tcpd.h 1996-03-19 09:22:25.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/tcpd.h 2002-01-07 08:50:19.000000000 -0600 +@@ -4,6 +4,25 @@ + * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. + */ + ++#ifndef _TCPWRAPPERS_TCPD_H ++#define _TCPWRAPPERS_TCPD_H ++ ++/* someone else may have defined this */ ++#undef __P ++ ++/* use prototypes if we have an ANSI C compiler or are using C++ */ ++#if defined(__STDC__) || defined(__cplusplus) ++#define __P(args) args ++#else ++#define __P(args) () ++#endif ++ ++/* Need definitions of struct sockaddr_in and FILE. */ ++#include <netinet/in.h> ++#include <stdio.h> ++ ++__BEGIN_DECLS ++ + /* Structure to describe one communications endpoint. */ + + #define STRING_LENGTH 128 /* hosts, users, processes */ +@@ -25,10 +44,10 @@ + char pid[10]; /* access via eval_pid(request) */ + struct host_info client[1]; /* client endpoint info */ + struct host_info server[1]; /* server endpoint info */ +- void (*sink) (); /* datagram sink function or 0 */ +- void (*hostname) (); /* address to printable hostname */ +- void (*hostaddr) (); /* address to printable address */ +- void (*cleanup) (); /* cleanup function or 0 */ ++ void (*sink) __P((int)); /* datagram sink function or 0 */ ++ void (*hostname) __P((struct host_info *)); /* address to printable hostname */ ++ void (*hostaddr) __P((struct host_info *)); /* address to printable address */ ++ void (*cleanup) __P((struct request_info *)); /* cleanup function or 0 */ + struct netconfig *config; /* netdir handle */ + }; + +@@ -61,25 +80,30 @@ + /* Global functions. */ + + #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT) +-extern void fromhost(); /* get/validate client host info */ ++extern void fromhost __P((struct request_info *)); /* get/validate client host info */ + #else + #define fromhost sock_host /* no TLI support needed */ + #endif + +-extern int hosts_access(); /* access control */ +-extern void shell_cmd(); /* execute shell command */ +-extern char *percent_x(); /* do %<char> expansion */ +-extern void rfc931(); /* client name from RFC 931 daemon */ +-extern void clean_exit(); /* clean up and exit */ +-extern void refuse(); /* clean up and exit */ +-extern char *xgets(); /* fgets() on steroids */ +-extern char *split_at(); /* strchr() and split */ +-extern unsigned long dot_quad_addr(); /* restricted inet_addr() */ ++extern void shell_cmd __P((char *)); /* execute shell command */ ++extern char *percent_x __P((char *, int, char *, struct request_info *)); /* do %<char> expansion */ ++extern void rfc931 __P((struct sockaddr_in *, struct sockaddr_in *, char *)); /* client name from RFC 931 daemon */ ++extern void clean_exit __P((struct request_info *)); /* clean up and exit */ ++extern void refuse __P((struct request_info *)); /* clean up and exit */ ++extern char *xgets __P((char *, int, FILE *)); /* fgets() on steroids */ ++extern char *split_at __P((char *, int)); /* strchr() and split */ ++extern unsigned long dot_quad_addr __P((char *)); /* restricted inet_addr() */ + + /* Global variables. */ + ++#ifdef HAVE_WEAKSYMS ++extern int allow_severity __attribute__ ((weak)); /* for connection logging */ ++extern int deny_severity __attribute__ ((weak)); /* for connection logging */ ++#else + extern int allow_severity; /* for connection logging */ + extern int deny_severity; /* for connection logging */ ++#endif ++ + extern char *hosts_allow_table; /* for verification mode redirection */ + extern char *hosts_deny_table; /* for verification mode redirection */ + extern int hosts_access_verbose; /* for verbose matching mode */ +@@ -92,9 +116,14 @@ + */ + + #ifdef __STDC__ ++extern int hosts_access(struct request_info *request); ++extern int hosts_ctl(char *daemon, char *client_name, char *client_addr, ++ char *client_user); + extern struct request_info *request_init(struct request_info *,...); + extern struct request_info *request_set(struct request_info *,...); + #else ++extern int hosts_access(); ++extern int hosts_ctl(); + extern struct request_info *request_init(); /* initialize request */ + extern struct request_info *request_set(); /* update request structure */ + #endif +@@ -117,27 +146,31 @@ + * host_info structures serve as caches for the lookup results. + */ + +-extern char *eval_user(); /* client user */ +-extern char *eval_hostname(); /* printable hostname */ +-extern char *eval_hostaddr(); /* printable host address */ +-extern char *eval_hostinfo(); /* host name or address */ +-extern char *eval_client(); /* whatever is available */ +-extern char *eval_server(); /* whatever is available */ ++extern char *eval_user __P((struct request_info *)); /* client user */ ++extern char *eval_hostname __P((struct host_info *)); /* printable hostname */ ++extern char *eval_hostaddr __P((struct host_info *)); /* printable host address */ ++extern char *eval_hostinfo __P((struct host_info *)); /* host name or address */ ++extern char *eval_client __P((struct request_info *)); /* whatever is available */ ++extern char *eval_server __P((struct request_info *)); /* whatever is available */ + #define eval_daemon(r) ((r)->daemon) /* daemon process name */ + #define eval_pid(r) ((r)->pid) /* process id */ + + /* Socket-specific methods, including DNS hostname lookups. */ + +-extern void sock_host(); /* look up endpoint addresses */ +-extern void sock_hostname(); /* translate address to hostname */ +-extern void sock_hostaddr(); /* address to printable address */ ++/* look up endpoint addresses */ ++extern void sock_host __P((struct request_info *)); ++/* translate address to hostname */ ++extern void sock_hostname __P((struct host_info *)); ++/* address to printable address */ ++extern void sock_hostaddr __P((struct host_info *)); ++ + #define sock_methods(r) \ + { (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; } + + /* The System V Transport-Level Interface (TLI) interface. */ + + #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT) +-extern void tli_host(); /* look up endpoint addresses etc. */ ++extern void tli_host __P((struct request_info *)); /* look up endpoint addresses etc. */ + #endif + + /* +@@ -178,7 +211,7 @@ + * behavior. + */ + +-extern void process_options(); /* execute options */ ++extern void process_options __P((char *, struct request_info *)); /* execute options */ + extern int dry_run; /* verification flag */ + + /* Bug workarounds. */ +@@ -217,3 +250,7 @@ + #define strtok my_strtok + extern char *my_strtok(); + #endif ++ ++__END_DECLS ++ ++#endif /* tcpd.h */ +diff -Naur tcp_wrappers_7.6/tcpdchk.c tcp_wrappers_7.6.gimli/tcpdchk.c +--- tcp_wrappers_7.6/tcpdchk.c 1997-02-11 19:13:25.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/tcpdchk.c 2002-01-07 08:50:19.000000000 -0600 +@@ -350,6 +350,8 @@ + { + if (pat[0] == '@') { + tcpd_warn("%s: daemon name begins with \"@\"", pat); ++ } else if (pat[0] == '/') { ++ tcpd_warn("%s: daemon name begins with \"/\"", pat); + } else if (pat[0] == '.') { + tcpd_warn("%s: daemon name begins with dot", pat); + } else if (pat[strlen(pat) - 1] == '.') { +@@ -382,6 +384,8 @@ + { + if (pat[0] == '@') { /* @netgroup */ + tcpd_warn("%s: user name begins with \"@\"", pat); ++ } else if (pat[0] == '/') { ++ tcpd_warn("%s: user name begins with \"/\"", pat); + } else if (pat[0] == '.') { + tcpd_warn("%s: user name begins with dot", pat); + } else if (pat[strlen(pat) - 1] == '.') { +@@ -402,8 +406,13 @@ + static int check_host(pat) + char *pat; + { ++ char buf[BUFSIZ]; + char *mask; + int addr_count = 1; ++ FILE *fp; ++ struct tcpd_context saved_context; ++ char *cp; ++ char *wsp = " \t\r\n"; + + if (pat[0] == '@') { /* @netgroup */ + #ifdef NO_NETGRENT +@@ -422,6 +431,21 @@ + tcpd_warn("netgroup support disabled"); + #endif + #endif ++ } else if (pat[0] == '/') { /* /path/name */ ++ if ((fp = fopen(pat, "r")) != 0) { ++ saved_context = tcpd_context; ++ tcpd_context.file = pat; ++ tcpd_context.line = 0; ++ while (fgets(buf, sizeof(buf), fp)) { ++ tcpd_context.line++; ++ for (cp = strtok(buf, wsp); cp; cp = strtok((char *) 0, wsp)) ++ check_host(cp); ++ } ++ tcpd_context = saved_context; ++ fclose(fp); ++ } else if (errno != ENOENT) { ++ tcpd_warn("open %s: %m", pat); ++ } + } else if (mask = split_at(pat, '/')) { /* network/netmask */ + if (dot_quad_addr(pat) == INADDR_NONE + || dot_quad_addr(mask) == INADDR_NONE) +diff -Naur tcp_wrappers_7.6/try-from.8 tcp_wrappers_7.6.gimli/try-from.8 +--- tcp_wrappers_7.6/try-from.8 1969-12-31 18:00:00.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/try-from.8 2002-01-07 08:50:19.000000000 -0600 +@@ -0,0 +1,28 @@ ++.TH TRY-FROM 8 "21th June 1997" Linux "Linux Programmer's Manual" ++.SH NAME ++try-from \- test program for the tcp_wrapper ++.SH SYNOPSIS ++.B try-from ++.SH DESCRIPTION ++The ++.B try-from ++command can be called via a remote shell command to find out ++if the hostname and address are properly recognized ++by the ++.B tcp_wrapper ++library, if username lookup works, and (SysV only) if the TLI ++on top of IP heuristics work. Diagnostics are reported through ++.BR syslog (3) ++and redirected to stderr. ++ ++Example: ++ ++rsh host /some/where/try-from ++ ++.SH SEE ALSO ++.BR hosts_access (5), ++.BR hosts_options (5), ++.BR tcpd (8) ++.SH AUTHOR ++Wietse Venema, Eindhoven University of Technology, The Netherlands. ++ +diff -Naur tcp_wrappers_7.6/weak_symbols.c tcp_wrappers_7.6.gimli/weak_symbols.c +--- tcp_wrappers_7.6/weak_symbols.c 1969-12-31 18:00:00.000000000 -0600 ++++ tcp_wrappers_7.6.gimli/weak_symbols.c 2002-01-07 08:50:19.000000000 -0600 +@@ -0,0 +1,11 @@ ++ /* ++ * @(#) weak_symbols.h 1.5 99/12/29 23:50 ++ * ++ * Author: Anthony Towns <ajt@debian.org> ++ */ ++ ++#ifdef HAVE_WEAKSYMS ++#include <syslog.h> ++int deny_severity = LOG_WARNING; ++int allow_severity = SEVERITY; ++#endif diff --git a/core/tcp_wrappers/tcp-wrappers-7.6-ipv6-1.14.patch b/core/tcp_wrappers/tcp-wrappers-7.6-ipv6-1.14.patch new file mode 100644 index 000000000..c1593d051 --- /dev/null +++ b/core/tcp_wrappers/tcp-wrappers-7.6-ipv6-1.14.patch @@ -0,0 +1,1233 @@ +;; IPv6 patch for tcp_wrappers_7.6 1.14 +;; Dec 29, 2001 by Hajimu UMEMOTO <ume@mahoroba.org> +;; +;; This patch supports IPv4/IPv6 dual stack and IPv4-mapped IPv6 address. +;; You can replace stock tcpd or libwrap.a with this. +;; IPv6 address pattern is as a `[net]/prefixlen' pair. +;; This patch was tested on KAME/FreeBSD, KAME/FreeBSD3, KAME/NetBSD, +;; RedHat 5.1 with kernel 2.1.126, and RedHat 6.0 with kernel 2.2.10. +;; Solaris 8 is now supported. Thanks Alexander Gall <gall@switch.ch> +;; and Shigechika AIKAWA <shige@cin.nihon-u.ac.jp>. +;; +;; This version is using getaddrinfo()/getnameinfo() instead of +;; getipnode*() to support scoped address. Use of +;; getaddrinfo()/getnameinfo() and scoped address support is only +;; tested on KAME. +;; +;; CAUTION: +;; Back out change for field separater. Now, field separater is `:' +;; not `|'. To specify IPv6 address, enclose IPv6 address with `[' +;; and `]'. +;; +;; For Linux users: +;; If your libc doesn't have sockaddr_storage, try target `linux-old'. +diff -u src/tcp_wrappers/fix_options.c:1.1.1.1 src/tcp_wrappers/fix_options.c:1.4 +--- src/tcp_wrappers/fix_options.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/fix_options.c Tue Sep 28 04:13:19 1999 +@@ -11,6 +11,9 @@ + + #include <sys/types.h> + #include <sys/param.h> ++#ifdef INET6 ++#include <sys/socket.h> ++#endif + #include <netinet/in.h> + #include <netinet/in_systm.h> + #include <netinet/ip.h> +@@ -41,6 +44,22 @@ + unsigned int opt; + int optlen; + struct in_addr dummy; ++#ifdef INET6 ++ struct sockaddr_storage ss; ++ int sslen; ++ ++ /* ++ * check if this is AF_INET socket ++ * XXX IPv6 support? ++ */ ++ sslen = sizeof(ss); ++ if (getsockname(fd, (struct sockaddr *)&ss, &sslen) < 0) { ++ syslog(LOG_ERR, "getpeername: %m"); ++ clean_exit(request); ++ } ++ if (ss.ss_family != AF_INET) ++ return; ++#endif + + if ((ip = getprotobyname("ip")) != 0) + ipproto = ip->p_proto; +Index: src/tcp_wrappers/inetcf.c +diff -u src/tcp_wrappers/inetcf.c:1.1.1.1 src/tcp_wrappers/inetcf.c:1.2 +--- src/tcp_wrappers/inetcf.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/inetcf.c Tue May 4 21:58:36 1999 +@@ -26,6 +26,9 @@ + * guesses. Shorter names follow longer ones. + */ + char *inet_files[] = { ++#ifdef INET6 ++ "/usr/local/v6/etc/inet6d.conf", /* KAME */ ++#endif + "/private/etc/inetd.conf", /* NEXT */ + "/etc/inet/inetd.conf", /* SYSV4 */ + "/usr/etc/inetd.conf", /* IRIX?? */ +Index: src/tcp_wrappers/misc.c +diff -u src/tcp_wrappers/misc.c:1.1.1.1 src/tcp_wrappers/misc.c:1.4 +--- src/tcp_wrappers/misc.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/misc.c Mon Aug 23 01:32:43 1999 +@@ -58,9 +58,31 @@ + { + char *cp; + ++#ifdef INET6 ++ int bracket = 0; ++ ++ for (cp = string; cp && *cp; cp++) { ++ switch (*cp) { ++ case '[': ++ bracket++; ++ break; ++ case ']': ++ bracket--; ++ break; ++ default: ++ if (bracket == 0 && *cp == delimiter) { ++ *cp++ = 0; ++ return cp; ++ } ++ break; ++ } ++ } ++ return (NULL); ++#else + if ((cp = strchr(string, delimiter)) != 0) + *cp++ = 0; + return (cp); ++#endif + } + + /* dot_quad_addr - convert dotted quad to internal form */ +Index: src/tcp_wrappers/refuse.c +diff -u src/tcp_wrappers/refuse.c:1.1.1.1 src/tcp_wrappers/refuse.c:1.2 +--- src/tcp_wrappers/refuse.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/refuse.c Tue May 4 21:58:36 1999 +@@ -25,7 +25,12 @@ + void refuse(request) + struct request_info *request; + { ++#ifdef INET6 ++ syslog(deny_severity, "refused connect from %s (%s)", ++ eval_client(request), eval_hostaddr(request->client)); ++#else + syslog(deny_severity, "refused connect from %s", eval_client(request)); ++#endif + clean_exit(request); + /* NOTREACHED */ + } +Index: src/tcp_wrappers/rfc931.c +diff -u src/tcp_wrappers/rfc931.c:1.1.1.1 src/tcp_wrappers/rfc931.c:1.7 +--- src/tcp_wrappers/rfc931.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/rfc931.c Mon Aug 23 01:32:43 1999 +@@ -68,20 +68,50 @@ + /* rfc931 - return remote user name, given socket structures */ + + void rfc931(rmt_sin, our_sin, dest) ++#ifdef INET6 ++struct sockaddr *rmt_sin; ++struct sockaddr *our_sin; ++#else + struct sockaddr_in *rmt_sin; + struct sockaddr_in *our_sin; ++#endif + char *dest; + { + unsigned rmt_port; + unsigned our_port; ++#ifdef INET6 ++ struct sockaddr_storage rmt_query_sin; ++ struct sockaddr_storage our_query_sin; ++ int alen; ++#else + struct sockaddr_in rmt_query_sin; + struct sockaddr_in our_query_sin; ++#endif + char user[256]; /* XXX */ + char buffer[512]; /* XXX */ + char *cp; + char *result = unknown; + FILE *fp; + ++#ifdef INET6 ++ /* address family must be the same */ ++ if (rmt_sin->sa_family != our_sin->sa_family) { ++ STRN_CPY(dest, result, STRING_LENGTH); ++ return; ++ } ++ switch (our_sin->sa_family) { ++ case AF_INET: ++ alen = sizeof(struct sockaddr_in); ++ break; ++ case AF_INET6: ++ alen = sizeof(struct sockaddr_in6); ++ break; ++ default: ++ STRN_CPY(dest, result, STRING_LENGTH); ++ return; ++ } ++#endif ++ + /* + * Use one unbuffered stdio stream for writing to and for reading from + * the RFC931 etc. server. This is done because of a bug in the SunOS +@@ -92,7 +122,11 @@ + * sockets. + */ + ++#ifdef INET6 ++ if ((fp = fsocket(our_sin->sa_family, SOCK_STREAM, 0)) != 0) { ++#else + if ((fp = fsocket(AF_INET, SOCK_STREAM, 0)) != 0) { ++#endif + setbuf(fp, (char *) 0); + + /* +@@ -112,6 +146,25 @@ + * addresses from the query socket. + */ + ++#ifdef INET6 ++ memcpy(&our_query_sin, our_sin, alen); ++ memcpy(&rmt_query_sin, rmt_sin, alen); ++ switch (our_sin->sa_family) { ++ case AF_INET: ++ ((struct sockaddr_in *)&our_query_sin)->sin_port = htons(ANY_PORT); ++ ((struct sockaddr_in *)&rmt_query_sin)->sin_port = htons(RFC931_PORT); ++ break; ++ case AF_INET6: ++ ((struct sockaddr_in6 *)&our_query_sin)->sin6_port = htons(ANY_PORT); ++ ((struct sockaddr_in6 *)&rmt_query_sin)->sin6_port = htons(RFC931_PORT); ++ break; ++ } ++ ++ if (bind(fileno(fp), (struct sockaddr *) & our_query_sin, ++ alen) >= 0 && ++ connect(fileno(fp), (struct sockaddr *) & rmt_query_sin, ++ alen) >= 0) { ++#else + our_query_sin = *our_sin; + our_query_sin.sin_port = htons(ANY_PORT); + rmt_query_sin = *rmt_sin; +@@ -121,6 +174,7 @@ + sizeof(our_query_sin)) >= 0 && + connect(fileno(fp), (struct sockaddr *) & rmt_query_sin, + sizeof(rmt_query_sin)) >= 0) { ++#endif + + /* + * Send query to server. Neglect the risk that a 13-byte +@@ -129,8 +183,13 @@ + */ + + fprintf(fp, "%u,%u\r\n", ++#ifdef INET6 ++ ntohs(((struct sockaddr_in *)rmt_sin)->sin_port), ++ ntohs(((struct sockaddr_in *)our_sin)->sin_port)); ++#else + ntohs(rmt_sin->sin_port), + ntohs(our_sin->sin_port)); ++#endif + fflush(fp); + + /* +@@ -144,8 +203,13 @@ + && ferror(fp) == 0 && feof(fp) == 0 + && sscanf(buffer, "%u , %u : USERID :%*[^:]:%255s", + &rmt_port, &our_port, user) == 3 ++#ifdef INET6 ++ && ntohs(((struct sockaddr_in *)rmt_sin)->sin_port) == rmt_port ++ && ntohs(((struct sockaddr_in *)our_sin)->sin_port) == our_port) { ++#else + && ntohs(rmt_sin->sin_port) == rmt_port + && ntohs(our_sin->sin_port) == our_port) { ++#endif + + /* + * Strip trailing carriage return. It is part of the +Index: src/tcp_wrappers/scaffold.c +diff -u src/tcp_wrappers/scaffold.c:1.1.1.1 src/tcp_wrappers/scaffold.c:1.12 +--- src/tcp_wrappers/scaffold.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/scaffold.c Fri May 5 18:54:46 2000 +@@ -39,6 +41,7 @@ + int deny_severity = LOG_WARNING; + int rfc931_timeout = RFC931_TIMEOUT; + ++#ifndef INET6 + /* dup_hostent - create hostent in one memory block */ + + static struct hostent *dup_hostent(hp) +@@ -73,9 +76,46 @@ + } + return (&hb->host); + } ++#endif + + /* find_inet_addr - find all addresses for this host, result to free() */ + ++#ifdef INET6 ++struct addrinfo *find_inet_addr(host) ++char *host; ++{ ++ struct addrinfo hints, *res; ++ ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = PF_UNSPEC; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; ++ if (getaddrinfo(host, NULL, &hints, &res) == 0) ++ return (res); ++ ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = PF_UNSPEC; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_flags = AI_PASSIVE | AI_CANONNAME; ++ if (getaddrinfo(host, NULL, &hints, &res) != 0) { ++ tcpd_warn("%s: host not found", host); ++ return (0); ++ } ++ if (res->ai_family != AF_INET6 && res->ai_family != AF_INET) { ++ tcpd_warn("%d: not an internet host", res->ai_family); ++ freeaddrinfo(res); ++ return (0); ++ } ++ if (!res->ai_canonname) { ++ tcpd_warn("%s: hostname alias", host); ++ tcpd_warn("(cannot obtain official name)", res->ai_canonname); ++ } else if (STR_NE(host, res->ai_canonname)) { ++ tcpd_warn("%s: hostname alias", host); ++ tcpd_warn("(official name: %.*s)", STRING_LENGTH, res->ai_canonname); ++ } ++ return (res); ++} ++#else + struct hostent *find_inet_addr(host) + char *host; + { +@@ -118,6 +158,7 @@ + } + return (dup_hostent(hp)); + } ++#endif + + /* check_dns - give each address thorough workout, return address count */ + +@@ -125,8 +166,13 @@ + char *host; + { + struct request_info request; ++#ifdef INET6 ++ struct sockaddr_storage sin; ++ struct addrinfo *hp, *res; ++#else + struct sockaddr_in sin; + struct hostent *hp; ++#endif + int count; + char *addr; + +@@ -134,11 +180,18 @@ + return (0); + request_init(&request, RQ_CLIENT_SIN, &sin, 0); + sock_methods(&request); ++#ifndef INET6 + memset((char *) &sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; ++#endif + ++#ifdef INET6 ++ for (res = hp, count = 0; res; res = res->ai_next, count++) { ++ memcpy(&sin, res->ai_addr, res->ai_addrlen); ++#else + for (count = 0; (addr = hp->h_addr_list[count]) != 0; count++) { + memcpy((char *) &sin.sin_addr, addr, sizeof(sin.sin_addr)); ++#endif + + /* + * Force host name and address conversions. Use the request structure +@@ -151,7 +204,11 @@ + tcpd_warn("host address %s->name lookup failed", + eval_hostaddr(request.client)); + } ++#ifdef INET6 ++ freeaddrinfo(hp); ++#else + free((char *) hp); ++#endif + return (count); + } + +Index: src/tcp_wrappers/scaffold.h +diff -u src/tcp_wrappers/scaffold.h:1.1.1.1 src/tcp_wrappers/scaffold.h:1.2 +--- src/tcp_wrappers/scaffold.h:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/scaffold.h Fri May 5 18:28:13 2000 +@@ -4,6 +4,10 @@ + * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. + */ + ++#ifdef INET6 ++extern struct addrinfo *find_inet_addr(); ++#else + extern struct hostent *find_inet_addr(); ++#endif + extern int check_dns(); + extern int check_path(); +Index: src/tcp_wrappers/socket.c +diff -u src/tcp_wrappers/socket.c:1.1.1.1 src/tcp_wrappers/socket.c:1.20 +--- src/tcp_wrappers/socket.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/socket.c Thu Jul 5 05:26:07 2001 +@@ -24,13 +24,22 @@ + #include <sys/types.h> + #include <sys/param.h> + #include <sys/socket.h> ++#ifdef INT32_T ++typedef uint32_t u_int32_t; ++#endif + #include <netinet/in.h> + #include <netdb.h> + #include <stdio.h> + #include <syslog.h> + #include <string.h> + ++#ifdef INET6 ++#ifndef NI_WITHSCOPEID ++#define NI_WITHSCOPEID 0 ++#endif ++#else + extern char *inet_ntoa(); ++#endif + + /* Local stuff. */ + +@@ -74,8 +83,13 @@ + void sock_host(request) + struct request_info *request; + { ++#ifdef INET6 ++ static struct sockaddr_storage client; ++ static struct sockaddr_storage server; ++#else + static struct sockaddr_in client; + static struct sockaddr_in server; ++#endif + int len; + char buf[BUFSIZ]; + int fd = request->fd; +@@ -104,7 +118,11 @@ + memset(buf, 0 sizeof(buf)); + #endif + } ++#ifdef INET6 ++ request->client->sin = (struct sockaddr *)&client; ++#else + request->client->sin = &client; ++#endif + + /* + * Determine the server binding. This is used for client username +@@ -117,7 +135,11 @@ + tcpd_warn("getsockname: %m"); + return; + } ++#ifdef INET6 ++ request->server->sin = (struct sockaddr *)&server; ++#else + request->server->sin = &server; ++#endif + } + + /* sock_hostaddr - map endpoint address to printable form */ +@@ -125,10 +147,26 @@ + void sock_hostaddr(host) + struct host_info *host; + { ++#ifdef INET6 ++ struct sockaddr *sin = host->sin; ++ int salen; ++ ++ if (!sin) ++ return; ++#ifdef SIN6_LEN ++ salen = sin->sa_len; ++#else ++ salen = (sin->sa_family == AF_INET) ? sizeof(struct sockaddr_in) ++ : sizeof(struct sockaddr_in6); ++#endif ++ getnameinfo(sin, salen, host->addr, sizeof(host->addr), ++ NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID); ++#else + struct sockaddr_in *sin = host->sin; + + if (sin != 0) + STRN_CPY(host->addr, inet_ntoa(sin->sin_addr), sizeof(host->addr)); ++#endif + } + + /* sock_hostname - map endpoint address to host name */ +@@ -136,6 +174,160 @@ + void sock_hostname(host) + struct host_info *host; + { ++#ifdef INET6 ++ struct sockaddr *sin = host->sin; ++ struct sockaddr_in sin4; ++ struct addrinfo hints, *res, *res0 = NULL; ++ int salen, alen, err = 1; ++ char *ap = NULL, *rap, hname[NI_MAXHOST]; ++ ++ if (sin != NULL) { ++ if (sin->sa_family == AF_INET6) { ++ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sin; ++ ++ if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { ++ memset(&sin4, 0, sizeof(sin4)); ++#ifdef SIN6_LEN ++ sin4.sin_len = sizeof(sin4); ++#endif ++ sin4.sin_family = AF_INET; ++ sin4.sin_port = sin6->sin6_port; ++ sin4.sin_addr.s_addr = *(u_int32_t *)&sin6->sin6_addr.s6_addr[12]; ++ sin = (struct sockaddr *)&sin4; ++ } ++ } ++ switch (sin->sa_family) { ++ case AF_INET: ++ ap = (char *)&((struct sockaddr_in *)sin)->sin_addr; ++ alen = sizeof(struct in_addr); ++ salen = sizeof(struct sockaddr_in); ++ break; ++ case AF_INET6: ++ ap = (char *)&((struct sockaddr_in6 *)sin)->sin6_addr; ++ alen = sizeof(struct in6_addr); ++ salen = sizeof(struct sockaddr_in6); ++ break; ++ default: ++ break; ++ } ++ if (ap) ++ err = getnameinfo(sin, salen, hname, sizeof(hname), ++ NULL, 0, NI_WITHSCOPEID | NI_NAMEREQD); ++ } ++ if (!err) { ++ ++ STRN_CPY(host->name, hname, sizeof(host->name)); ++ ++ /* reject numeric addresses */ ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = sin->sa_family; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_flags = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST; ++ if ((err = getaddrinfo(host->name, NULL, &hints, &res0)) == 0) { ++ freeaddrinfo(res0); ++ res0 = NULL; ++ tcpd_warn("host name/name mismatch: " ++ "reverse lookup results in non-FQDN %s", ++ host->name); ++ strcpy(host->name, paranoid); /* name is bad, clobber it */ ++ } ++ err = !err; ++ } ++ if (!err) { ++ /* we are now sure that this is non-numeric */ ++ ++ /* ++ * 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. ++ */ ++ ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = sin->sa_family; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_flags = AI_PASSIVE | AI_CANONNAME; ++ if (getaddrinfo(host->name, NULL, &hints, &res0) != 0) { ++ ++ /* ++ * 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: getaddrinfo(%s, %s) failed", ++ host->name, ++ (sin->sa_family == AF_INET) ? "AF_INET" : "AF_INET6"); ++ ++ } else if ((res0->ai_canonname == NULL ++ || STR_NE(host->name, res0->ai_canonname)) ++ && STR_NE(host->name, "localhost")) { ++ ++ /* ++ * 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. ++ */ ++ ++ tcpd_warn("host name/name mismatch: %s != %.*s", ++ host->name, STRING_LENGTH, ++ (res0->ai_canonname == NULL) ? "" : res0->ai_canonname); ++ ++ } else { ++ ++ /* ++ * 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 (res = res0; res; res = res->ai_next) { ++ if (res->ai_family != sin->sa_family) ++ continue; ++ switch (res->ai_family) { ++ case AF_INET: ++ rap = (char *)&((struct sockaddr_in *)res->ai_addr)->sin_addr; ++ break; ++ case AF_INET6: ++ /* need to check scope_id */ ++ if (((struct sockaddr_in6 *)sin)->sin6_scope_id != ++ ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id) { ++ continue; ++ } ++ rap = (char *)&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr; ++ break; ++ default: ++ continue; ++ } ++ if (memcmp(rap, ap, alen) == 0) { ++ freeaddrinfo(res0); ++ 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. ++ */ ++ ++ getnameinfo(sin, salen, hname, sizeof(hname), ++ NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID); ++ tcpd_warn("host name/address mismatch: %s != %.*s", ++ hname, STRING_LENGTH, ++ (res0->ai_canonname == NULL) ? "" : res0->ai_canonname); ++ } ++ strcpy(host->name, paranoid); /* name is bad, clobber it */ ++ if (res0) ++ freeaddrinfo(res0); ++ } ++#else /* INET6 */ + struct sockaddr_in *sin = host->sin; + struct hostent *hp; + int i; +@@ -215,6 +407,7 @@ + } + strcpy(host->name, paranoid); /* name is bad, clobber it */ + } ++#endif /* INET6 */ + } + + /* sock_sink - absorb unreceived IP datagram */ +@@ -223,7 +416,11 @@ + int fd; + { + char buf[BUFSIZ]; ++#ifdef INET6 ++ struct sockaddr_storage sin; ++#else + struct sockaddr_in sin; ++#endif + int size = sizeof(sin); + + /* +Index: src/tcp_wrappers/tcpd.c +diff -u src/tcp_wrappers/tcpd.c:1.1.1.1 src/tcp_wrappers/tcpd.c:1.2 +--- src/tcp_wrappers/tcpd.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/tcpd.c Tue May 4 21:58:36 1999 +@@ -120,7 +120,12 @@ + + /* Report request and invoke the real daemon program. */ + ++#ifdef INET6 ++ syslog(allow_severity, "connect from %s (%s)", ++ eval_client(&request), eval_hostaddr(request.client)); ++#else + syslog(allow_severity, "connect from %s", eval_client(&request)); ++#endif + closelog(); + (void) execv(path, argv); + syslog(LOG_ERR, "error: cannot execute %s: %m", path); +Index: src/tcp_wrappers/tcpd.h +diff -u src/tcp_wrappers/tcpd.h:1.1.1.1 src/tcp_wrappers/tcpd.h:1.7 +--- src/tcp_wrappers/tcpd.h:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/tcpd.h Mon Aug 23 01:32:43 1999 +@@ -11,7 +11,11 @@ + struct host_info { + char name[STRING_LENGTH]; /* access via eval_hostname(host) */ + char addr[STRING_LENGTH]; /* access via eval_hostaddr(host) */ ++#ifdef INET6 ++ struct sockaddr *sin; /* socket address or 0 */ ++#else + struct sockaddr_in *sin; /* socket address or 0 */ ++#endif + struct t_unitdata *unit; /* TLI transport address or 0 */ + struct request_info *request; /* for shared information */ + }; +Index: src/tcp_wrappers/tcpdchk.c +diff -u src/tcp_wrappers/tcpdchk.c:1.1.1.1 src/tcp_wrappers/tcpdchk.c:1.5 +--- src/tcp_wrappers/tcpdchk.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/tcpdchk.c Fri May 5 18:28:13 2000 +@@ -22,6 +22,9 @@ + + #include <sys/types.h> + #include <sys/stat.h> ++#ifdef INET6 ++#include <sys/socket.h> ++#endif + #include <netinet/in.h> + #include <arpa/inet.h> + #include <stdio.h> +@@ -397,6 +400,31 @@ + } + } + ++#ifdef INET6 ++static int is_inet6_addr(pat) ++ char *pat; ++{ ++ struct addrinfo hints, *res; ++ int len, ret; ++ char ch; ++ ++ if (*pat != '[') ++ return (0); ++ len = strlen(pat); ++ if ((ch = pat[len - 1]) != ']') ++ return (0); ++ pat[len - 1] = '\0'; ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = AF_INET6; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; ++ if ((ret = getaddrinfo(pat + 1, NULL, &hints, &res)) == 0) ++ freeaddrinfo(res); ++ pat[len - 1] = ch; ++ return (ret == 0); ++} ++#endif ++ + /* check_host - criticize host pattern */ + + static int check_host(pat) +@@ -423,14 +451,27 @@ + #endif + #endif + } else if (mask = split_at(pat, '/')) { /* network/netmask */ ++#ifdef INET6 ++ int mask_len; ++ ++ if ((dot_quad_addr(pat) == INADDR_NONE ++ || dot_quad_addr(mask) == INADDR_NONE) ++ && (!is_inet6_addr(pat) ++ || ((mask_len = atoi(mask)) < 0 || mask_len > 128))) ++#else + if (dot_quad_addr(pat) == INADDR_NONE + || dot_quad_addr(mask) == INADDR_NONE) ++#endif + tcpd_warn("%s/%s: bad net/mask pattern", pat, mask); + } else if (STR_EQ(pat, "FAIL")) { /* obsolete */ + tcpd_warn("FAIL is no longer recognized"); + tcpd_warn("(use EXCEPT or DENY instead)"); + } else if (reserved_name(pat)) { /* other reserved */ + /* void */ ; ++#ifdef INET6 ++ } else if (is_inet6_addr(pat)) { /* IPv6 address */ ++ addr_count = 1; ++#endif + } else if (NOT_INADDR(pat)) { /* internet name */ + if (pat[strlen(pat) - 1] == '.') { + tcpd_warn("%s: domain or host name ends in dot", pat); +Index: src/tcp_wrappers/tcpdmatch.c +diff -u src/tcp_wrappers/tcpdmatch.c:1.1.1.1 src/tcp_wrappers/tcpdmatch.c:1.7 +--- src/tcp_wrappers/tcpdmatch.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/tcpdmatch.c Fri May 5 19:06:40 2000 +@@ -57,7 +57,11 @@ + int argc; + char **argv; + { ++#ifdef INET6 ++ struct addrinfo hints, *hp, *res; ++#else + struct hostent *hp; ++#endif + char *myname = argv[0]; + char *client; + char *server; +@@ -68,8 +72,13 @@ + int ch; + char *inetcf = 0; + int count; ++#ifdef INET6 ++ struct sockaddr_storage server_sin; ++ struct sockaddr_storage client_sin; ++#else + struct sockaddr_in server_sin; + struct sockaddr_in client_sin; ++#endif + struct stat st; + + /* +@@ -172,13 +181,20 @@ + if (NOT_INADDR(server) == 0 || HOSTNAME_KNOWN(server)) { + if ((hp = find_inet_addr(server)) == 0) + exit(1); ++#ifndef INET6 + memset((char *) &server_sin, 0, sizeof(server_sin)); + server_sin.sin_family = AF_INET; ++#endif + request_set(&request, RQ_SERVER_SIN, &server_sin, 0); + ++#ifdef INET6 ++ for (res = hp, count = 0; res; res = res->ai_next, count++) { ++ memcpy(&server_sin, res->ai_addr, res->ai_addrlen); ++#else + for (count = 0; (addr = hp->h_addr_list[count]) != 0; count++) { + memcpy((char *) &server_sin.sin_addr, addr, + sizeof(server_sin.sin_addr)); ++#endif + + /* + * Force evaluation of server host name and address. Host name +@@ -194,7 +210,11 @@ + fprintf(stderr, "Please specify an address instead\n"); + exit(1); + } ++#ifdef INET6 ++ freeaddrinfo(hp); ++#else + free((char *) hp); ++#endif + } else { + request_set(&request, RQ_SERVER_NAME, server, 0); + } +@@ -208,6 +228,18 @@ + tcpdmatch(&request); + exit(0); + } ++#ifdef INET6 ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = AF_INET6; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; ++ if (getaddrinfo(client, NULL, &hints, &res) == 0) { ++ freeaddrinfo(res); ++ request_set(&request, RQ_CLIENT_ADDR, client, 0); ++ tcpdmatch(&request); ++ exit(0); ++ } ++#endif + + /* + * Perhaps they are testing special client hostname patterns that aren't +@@ -229,6 +261,34 @@ + */ + if ((hp = find_inet_addr(client)) == 0) + exit(1); ++#ifdef INET6 ++ request_set(&request, RQ_CLIENT_SIN, &client_sin, 0); ++ ++ for (res = hp, count = 0; res; res = res->ai_next, count++) { ++ memcpy(&client_sin, res->ai_addr, res->ai_addrlen); ++ ++ /* ++ * getnameinfo() doesn't do reverse lookup against link-local ++ * address. So, we pass through host name evaluation against ++ * such addresses. ++ */ ++ if (res->ai_family != AF_INET6 || ++ !IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr)) { ++ /* ++ * Force evaluation of client host name and address. Host name ++ * conflicts will be reported while eval_hostname() does its job. ++ */ ++ request_set(&request, RQ_CLIENT_NAME, "", RQ_CLIENT_ADDR, "", 0); ++ if (STR_EQ(eval_hostname(request.client), unknown)) ++ tcpd_warn("host address %s->name lookup failed", ++ eval_hostaddr(request.client)); ++ } ++ tcpdmatch(&request); ++ if (res->ai_next) ++ printf("\n"); ++ } ++ freeaddrinfo(hp); ++#else + memset((char *) &client_sin, 0, sizeof(client_sin)); + client_sin.sin_family = AF_INET; + request_set(&request, RQ_CLIENT_SIN, &client_sin, 0); +@@ -250,6 +310,7 @@ + printf("\n"); + } + free((char *) hp); ++#endif + exit(0); + } + +Index: src/tcp_wrappers/tli.c +diff -u src/tcp_wrappers/tli.c:1.1.1.1 src/tcp_wrappers/tli.c:1.4 +--- src/tcp_wrappers/tli.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/tli.c Fri May 5 19:15:09 2000 +@@ -65,8 +65,13 @@ + void tli_host(request) + struct request_info *request; + { ++#ifdef INET6 ++ static struct sockaddr_storage client; ++ static struct sockaddr_storage server; ++#else + static struct sockaddr_in client; + static struct sockaddr_in server; ++#endif + + /* + * If we discover that we are using an IP transport, pretend we never +@@ -76,14 +81,29 @@ + + tli_endpoints(request); + if ((request->config = tli_transport(request->fd)) != 0 ++#ifdef INET6 ++ && (STR_EQ(request->config->nc_protofmly, "inet") || ++ STR_EQ(request->config->nc_protofmly, "inet6"))) { ++#else + && STR_EQ(request->config->nc_protofmly, "inet")) { ++#endif + if (request->client->unit != 0) { ++#ifdef INET6 ++ client = *(struct sockaddr_storage *) request->client->unit->addr.buf; ++ request->client->sin = (struct sockaddr *) &client; ++#else + client = *(struct sockaddr_in *) request->client->unit->addr.buf; + request->client->sin = &client; ++#endif + } + if (request->server->unit != 0) { ++#ifdef INET6 ++ server = *(struct sockaddr_storage *) request->server->unit->addr.buf; ++ request->server->sin = (struct sockaddr *) &server; ++#else + server = *(struct sockaddr_in *) request->server->unit->addr.buf; + request->server->sin = &server; ++#endif + } + tli_cleanup(request); + sock_methods(request); +@@ -187,7 +207,15 @@ + } + while (config = getnetconfig(handlep)) { + if (stat(config->nc_device, &from_config) == 0) { ++#ifdef NO_CLONE_DEVICE ++ /* ++ * If the network devices are not cloned (as is the case for ++ * Solaris 8 Beta), we must compare the major device numbers. ++ */ ++ if (major(from_config.st_rdev) == major(from_client.st_rdev)) ++#else + if (minor(from_config.st_rdev) == major(from_client.st_rdev)) ++#endif + break; + } + } +Index: src/tcp_wrappers/update.c +diff -u src/tcp_wrappers/update.c:1.1.1.1 src/tcp_wrappers/update.c:1.3 +--- src/tcp_wrappers/update.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/update.c Mon Aug 23 01:32:43 1999 +@@ -46,10 +46,18 @@ + request->fd = va_arg(ap, int); + continue; + case RQ_CLIENT_SIN: ++#ifdef INET6 ++ request->client->sin = va_arg(ap, struct sockaddr *); ++#else + request->client->sin = va_arg(ap, struct sockaddr_in *); ++#endif + continue; + case RQ_SERVER_SIN: ++#ifdef INET6 ++ request->server->sin = va_arg(ap, struct sockaddr *); ++#else + request->server->sin = va_arg(ap, struct sockaddr_in *); ++#endif + continue; + + /* +Index: src/tcp_wrappers/workarounds.c +diff -u src/tcp_wrappers/workarounds.c:1.1.1.1 src/tcp_wrappers/workarounds.c:1.3 +--- src/tcp_wrappers/workarounds.c:1.1.1.1 Tue May 4 21:56:04 1999 ++++ src/tcp_wrappers/workarounds.c Mon Aug 23 01:32:43 1999 +@@ -166,11 +166,22 @@ + int *len; + { + int ret; ++#ifdef INET6 ++ struct sockaddr *sin = sa; ++#else + struct sockaddr_in *sin = (struct sockaddr_in *) sa; ++#endif + + if ((ret = getpeername(sock, sa, len)) >= 0 ++#ifdef INET6 ++ && ((sin->su_si.si_family == AF_INET6 ++ && IN6_IS_ADDR_UNSPECIFIED(&sin->su_sin6.sin6_addr)) ++ || (sin->su_si.si_family == AF_INET ++ && sin->su_sin.sin_addr.s_addr == 0))) { ++#else + && sa->sa_family == AF_INET + && sin->sin_addr.s_addr == 0) { ++#endif + errno = ENOTCONN; + return (-1); + } else { +--- src/tcp_wrappers/hosts_access.c 2003-08-04 21:36:20.000000000 +0000 ++++ src/tcp_wrappers/hosts_access.c 2003-08-04 21:45:59.000000000 +0000 +@@ -24,7 +24,13 @@ + /* System libraries. */ + + #include <sys/types.h> ++#ifdef INT32_T ++ typedef uint32_t u_int32_t; ++#endif + #include <sys/param.h> ++#ifdef INET6 ++#include <sys/socket.h> ++#endif + #include <netinet/in.h> + #include <arpa/inet.h> + #include <stdio.h> +@@ -33,6 +39,9 @@ + #include <errno.h> + #include <setjmp.h> + #include <string.h> ++#ifdef INET6 ++#include <netdb.h> ++#endif + + extern char *fgets(); + extern int errno; +@@ -83,6 +92,10 @@ + static int host_match(); + static int string_match(); + static int masked_match(); ++#ifdef INET6 ++static int masked_match4(); ++static int masked_match6(); ++#endif + + /* Size of logical line buffer. */ + +@@ -312,6 +325,13 @@ + { + int n; + ++#ifdef INET6 ++ /* convert IPv4 mapped IPv6 address to IPv4 address */ ++ if (STRN_EQ(string, "::ffff:", 7) ++ && dot_quad_addr(string + 7) != INADDR_NONE) { ++ string += 7; ++ } ++#endif + #ifndef DISABLE_WILDCARD_MATCHING + if (strchr(tok, '*') || strchr(tok,'?')) { /* contains '*' or '?' */ + /* we must convert the both to lowercase as match_pattern_ylo is case-sensitive */ +@@ -333,21 +353,72 @@ + } else if (tok[(n = strlen(tok)) - 1] == '.') { /* prefix */ + return (STRN_EQ(tok, string, n)); + } else { /* exact match */ ++#ifdef INET6 ++ struct addrinfo hints, *res; ++ struct sockaddr_in6 pat, addr; ++ int len, ret; ++ char ch; ++ ++ len = strlen(tok); ++ if (*tok == '[' && tok[len - 1] == ']') { ++ ch = tok[len - 1]; ++ tok[len - 1] = '\0'; ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = AF_INET6; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; ++ if ((ret = getaddrinfo(tok + 1, NULL, &hints, &res)) == 0) { ++ memcpy(&pat, res->ai_addr, sizeof(pat)); ++ freeaddrinfo(res); ++ } ++ tok[len - 1] = ch; ++ if (ret != 0 || getaddrinfo(string, NULL, &hints, &res) != 0) ++ return NO; ++ memcpy(&addr, res->ai_addr, sizeof(addr)); ++ freeaddrinfo(res); ++#ifdef NI_WITHSCOPEID ++ if (pat.sin6_scope_id != 0 && ++ addr.sin6_scope_id != pat.sin6_scope_id) ++ return NO; ++#endif ++ return (!memcmp(&pat.sin6_addr, &addr.sin6_addr, ++ sizeof(struct in6_addr))); ++ return (ret); ++ } ++#endif + return (STR_EQ(tok, string)); + } + } + + /* masked_match - match address against netnumber/netmask */ + ++#ifdef INET6 + static int masked_match(net_tok, mask_tok, string) + char *net_tok; + char *mask_tok; + char *string; + { ++ return (masked_match4(net_tok, mask_tok, string) || ++ masked_match6(net_tok, mask_tok, string)); ++} ++ ++static int masked_match4(net_tok, mask_tok, string) ++#else ++static int masked_match(net_tok, mask_tok, string) ++#endif ++char *net_tok; ++char *mask_tok; ++char *string; ++{ ++#ifdef INET6 ++ u_int32_t net; ++ u_int32_t mask; ++ u_int32_t addr; ++#else + unsigned long net; + unsigned long mask; + unsigned long addr; +- ++#endif + /* + * Disallow forms other than dotted quad: the treatment that inet_addr() + * gives to forms with less than four components is inconsistent with the +@@ -358,12 +429,81 @@ + return (NO); + if ((net = dot_quad_addr(net_tok)) == INADDR_NONE + || (mask = dot_quad_addr(mask_tok)) == INADDR_NONE) { ++#ifndef INET6 + tcpd_warn("bad net/mask expression: %s/%s", net_tok, mask_tok); ++#endif + return (NO); /* not tcpd_jump() */ + } + return ((addr & mask) == net); + } + ++#ifdef INET6 ++static int masked_match6(net_tok, mask_tok, string) ++char *net_tok; ++char *mask_tok; ++char *string; ++{ ++ struct addrinfo hints, *res; ++ struct sockaddr_in6 net, addr; ++ u_int32_t mask; ++ int len, mask_len, i = 0; ++ char ch; ++ ++ /* ++ * Behavior of getaddrinfo() against IPv4-mapped IPv6 address is ++ * different between KAME and Solaris8. While KAME returns ++ * AF_INET6, Solaris8 returns AF_INET. So, we avoid this here. ++ */ ++ if (STRN_EQ(string, "::ffff:", 7) ++ && dot_quad_addr(string + 7) != INADDR_NONE) ++ return (masked_match4(net_tok, mask_tok, string + 7)); ++ ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = AF_INET6; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; ++ if (getaddrinfo(string, NULL, &hints, &res) != 0) ++ return NO; ++ memcpy(&addr, res->ai_addr, sizeof(addr)); ++ freeaddrinfo(res); ++ ++ /* match IPv6 address against netnumber/prefixlen */ ++ len = strlen(net_tok); ++ if (*net_tok != '[' || net_tok[len - 1] != ']') ++ return NO; ++ ch = net_tok[len - 1]; ++ net_tok[len - 1] = '\0'; ++ if (getaddrinfo(net_tok + 1, NULL, &hints, &res) != 0) { ++ net_tok[len - 1] = ch; ++ return NO; ++ } ++ memcpy(&net, res->ai_addr, sizeof(net)); ++ freeaddrinfo(res); ++ net_tok[len - 1] = ch; ++ if ((mask_len = atoi(mask_tok)) < 0 || mask_len > 128) ++ return NO; ++ ++#ifdef NI_WITHSCOPEID ++ if (net.sin6_scope_id != 0 && addr.sin6_scope_id != net.sin6_scope_id) ++ return NO; ++#endif ++ while (mask_len > 0) { ++ if (mask_len < 32) { ++ mask = htonl(~(0xffffffff >> mask_len)); ++ if ((*(u_int32_t *)&addr.sin6_addr.s6_addr[i] & mask) != (*(u_int32_t *)&net.sin6_addr.s6_addr[i] & mask)) ++ return NO; ++ break; ++ } ++ if (*(u_int32_t *)&addr.sin6_addr.s6_addr[i] != *(u_int32_t *)&net.sin6_addr.s6_addr[i]) ++ return NO; ++ i += 4; ++ mask_len -= 32; ++ } ++ return YES; ++} ++#endif /* INET6 */ ++ ++ + #ifndef DISABLE_WILDCARD_MATCHING + /* Note: this feature has been adapted in a pretty straightforward way + from Tatu Ylonen's last SSH version under free license by +--- src/tcp_wrappers/hosts_access.5 2003-08-04 21:52:29.000000000 +0000 ++++ src/tcp_wrappers/hosts_access.5 2003-08-04 21:53:39.000000000 +0000 +@@ -85,7 +85,7 @@ + for daemon process names or for client user names. + .IP \(bu + An expression of the form `n.n.n.n/m.m.m.m\' is interpreted as a +-`net/mask\' pair. A host address is matched if `net\' is equal to the ++`net/mask\' pair. A IPv4 host address is matched if `net\' is equal to the + bitwise AND of the address and the `mask\'. For example, the net/mask + pattern `131.155.72.0/255.255.254.0\' matches every address in the + range `131.155.72.0\' through `131.155.73.255\'. +@@ -96,6 +96,13 @@ + zero or more lines with zero or more host name or address patterns + separated by whitespace. A file name pattern can be used anywhere + a host name or address pattern can be used. ++.IP \(bu ++An expression of the form `[n:n:n:n:n:n:n:n]/m\' is interpreted as a ++`[net]/prefixlen\' pair. A IPv6 host address is matched if ++`prefixlen\' bits of `net\' is equal to the `prefixlen\' bits of the ++address. For example, the [net]/prefixlen pattern ++`[3ffe:505:2:1::]/64\' matches every address in the range ++`3ffe:505:2:1::\' through `3ffe:505:2:1:ffff:ffff:ffff:ffff\'. + .SH WILDCARDS + The access control language supports explicit wildcards: + .IP ALL diff --git a/core/tcp_wrappers/try-from.8 b/core/tcp_wrappers/try-from.8 new file mode 100644 index 000000000..9c8f30543 --- /dev/null +++ b/core/tcp_wrappers/try-from.8 @@ -0,0 +1,28 @@ +.TH TRY-FROM 8 "21th June 1997" Linux "Linux Programmer's Manual" +.SH NAME +try-from \- test program for the tcp_wrapper +.SH SYNOPSIS +.B try-from +.SH DESCRIPTION +The +.B try-from +command can be called via a remote shell command to find out +if the hostname and address are properly recognized +by the +.B tcp_wrapper +library, if username lookup works, and (SysV only) if the TLI +on top of IP heuristics work. Diagnostics are reported through +.BR syslog (3) +and redirected to stderr. + +Example: + +rsh host /some/where/try-from + +.SH SEE ALSO +.BR hosts_access (5), +.BR hosts_options (5), +.BR tcpd (8) +.SH AUTHOR +Wietse Venema, Eindhoven University of Technology, The Netherlands. + |