1 See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=17847
3 diff -ruN tcp_wrappers_7.6.orig/hosts_access.5 tcp_wrappers_7.6/hosts_access.5
4 --- tcp_wrappers_7.6.orig/hosts_access.5 2004-04-10 18:54:33.000000000 +0200
5 +++ tcp_wrappers_7.6/hosts_access.5 2004-04-10 18:54:27.000000000 +0200
7 bitwise AND of the address and the `mask\'. For example, the net/mask
8 pattern `131.155.72.0/255.255.254.0\' matches every address in the
9 range `131.155.72.0\' through `131.155.73.255\'.
11 +Wildcards `*\' and `?\' can be used to match hostnames or IP addresses. This
12 +method of matching cannot be used in conjunction with `net/mask\' matching,
13 +hostname matching beginning with `.\' or IP address matching ending with `.\'.
15 The access control language supports explicit wildcards:
17 diff -ruN tcp_wrappers_7.6.orig/hosts_access.c tcp_wrappers_7.6/hosts_access.c
18 --- tcp_wrappers_7.6.orig/hosts_access.c 1997-02-12 02:13:23.000000000 +0100
19 +++ tcp_wrappers_7.6/hosts_access.c 2004-04-10 18:52:21.000000000 +0200
24 +#ifndef DISABLE_WILDCARD_MATCHING
25 + if (strchr(tok, '*') || strchr(tok,'?')) { /* contains '*' or '?' */
26 + return (match_pattern_ylo(string,tok));
29 if (tok[0] == '.') { /* suffix */
30 n = strlen(string) - strlen(tok);
31 return (n > 0 && STR_EQ(tok, string + n));
34 return ((addr & mask) == net);
37 +#ifndef DISABLE_WILDCARD_MATCHING
38 +/* Note: this feature has been adapted in a pretty straightforward way
39 + from Tatu Ylonen's last SSH version under free license by
40 + Pekka Savola <pekkas@netcore.fi>.
42 + Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
45 +/* Returns true if the given string matches the pattern (which may contain
46 + ? and * as wildcards), and zero if it does not match. */
48 +int match_pattern_ylo(const char *s, const char *pattern)
52 + /* If at end of pattern, accept if also at end of string. */
57 + if (*pattern == '*')
59 + /* Skip the asterisk. */
62 + /* If at end of pattern, accept immediately. */
66 + /* If next character in pattern is known, optimize. */
67 + if (*pattern != '?' && *pattern != '*')
69 + /* Look instances of the next character in pattern, and try
70 + to match starting from those. */
72 + if (*s == *pattern &&
73 + match_pattern_ylo(s + 1, pattern + 1))
79 + /* Move ahead one character at a time and try to match at each
82 + if (match_pattern_ylo(s, pattern))
88 + /* There must be at least one more character in the string. If we are
89 + at the end, fail. */
93 + /* Check if the next character of the string is acceptable. */
94 + if (*pattern != '?' && *pattern != *s)
97 + /* Move to the next character, both in string and in pattern. */
103 +#endif /* DISABLE_WILDCARD_MATCHING */