hosts_access.c revision 1.12 1 1.12 atatat /* $NetBSD: hosts_access.c,v 1.12 2002/04/04 19:50:27 atatat Exp $ */
2 1.2 christos
3 1.1 mrg /*
4 1.1 mrg * This module implements a simple access control language that is based on
5 1.1 mrg * host (or domain) names, NIS (host) netgroup names, IP addresses (or
6 1.1 mrg * network numbers) and daemon process names. When a match is found the
7 1.1 mrg * search is terminated, and depending on whether PROCESS_OPTIONS is defined,
8 1.1 mrg * a list of options is executed or an optional shell command is executed.
9 1.8 simonb *
10 1.1 mrg * Host and user names are looked up on demand, provided that suitable endpoint
11 1.1 mrg * information is available as sockaddr_in structures or TLI netbufs. As a
12 1.1 mrg * side effect, the pattern matching process may change the contents of
13 1.1 mrg * request structure fields.
14 1.8 simonb *
15 1.1 mrg * Diagnostics are reported through syslog(3).
16 1.8 simonb *
17 1.1 mrg * Compile with -DNETGROUP if your library provides support for netgroups.
18 1.8 simonb *
19 1.1 mrg * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
20 1.1 mrg */
21 1.1 mrg
22 1.2 christos #include <sys/cdefs.h>
23 1.1 mrg #ifndef lint
24 1.2 christos #if 0
25 1.9 itojun static char sccsid[] = "@(#) hosts_access.c 1.21 97/02/12 02:13:22";
26 1.2 christos #else
27 1.12 atatat __RCSID("$NetBSD: hosts_access.c,v 1.12 2002/04/04 19:50:27 atatat Exp $");
28 1.2 christos #endif
29 1.1 mrg #endif
30 1.1 mrg
31 1.1 mrg /* System libraries. */
32 1.1 mrg
33 1.1 mrg #include <sys/types.h>
34 1.1 mrg #include <sys/param.h>
35 1.10 itojun #ifdef INET6
36 1.10 itojun #include <sys/socket.h>
37 1.10 itojun #endif
38 1.1 mrg #include <netinet/in.h>
39 1.1 mrg #include <arpa/inet.h>
40 1.1 mrg #include <stdio.h>
41 1.4 christos #include <stdlib.h>
42 1.1 mrg #include <syslog.h>
43 1.1 mrg #include <ctype.h>
44 1.1 mrg #include <errno.h>
45 1.1 mrg #include <setjmp.h>
46 1.1 mrg #include <string.h>
47 1.4 christos #include <netdb.h>
48 1.3 christos #ifdef NETGROUP
49 1.3 christos #include <netgroup.h>
50 1.3 christos #include <rpcsvc/ypclnt.h>
51 1.3 christos #endif
52 1.1 mrg
53 1.1 mrg #ifndef INADDR_NONE
54 1.1 mrg #define INADDR_NONE (-1) /* XXX should be 0xffffffff */
55 1.1 mrg #endif
56 1.1 mrg
57 1.1 mrg /* Local stuff. */
58 1.1 mrg
59 1.1 mrg #include "tcpd.h"
60 1.1 mrg
61 1.1 mrg /* Error handling. */
62 1.1 mrg
63 1.1 mrg extern jmp_buf tcpd_buf;
64 1.1 mrg
65 1.1 mrg /* Delimiters for lists of daemons or clients. */
66 1.1 mrg
67 1.1 mrg static char sep[] = ", \t\r\n";
68 1.1 mrg
69 1.1 mrg /* Constants to be used in assignments only, not in comparisons... */
70 1.1 mrg
71 1.1 mrg #define YES 1
72 1.1 mrg #define NO 0
73 1.1 mrg
74 1.1 mrg /*
75 1.1 mrg * These variables are globally visible so that they can be redirected in
76 1.1 mrg * verification mode.
77 1.1 mrg */
78 1.1 mrg
79 1.1 mrg char *hosts_allow_table = HOSTS_ALLOW;
80 1.1 mrg char *hosts_deny_table = HOSTS_DENY;
81 1.1 mrg int hosts_access_verbose = 0;
82 1.1 mrg
83 1.1 mrg /*
84 1.1 mrg * In a long-running process, we are not at liberty to just go away.
85 1.1 mrg */
86 1.1 mrg
87 1.1 mrg int resident = (-1); /* -1, 0: unknown; +1: yes */
88 1.1 mrg
89 1.1 mrg /* Forward declarations. */
90 1.1 mrg
91 1.2 christos static int table_match __P((char *, struct request_info *));
92 1.2 christos static int list_match __P((char *, struct request_info *,
93 1.2 christos int (*)(char *, struct request_info *)));
94 1.2 christos static int server_match __P((char *, struct request_info *));
95 1.2 christos static int client_match __P((char *, struct request_info *));
96 1.2 christos static int host_match __P((char *, struct host_info *));
97 1.4 christos static int rbl_match __P((char *, char *));
98 1.2 christos static int string_match __P((char *, char *));
99 1.2 christos static int masked_match __P((char *, char *, char *));
100 1.10 itojun static int masked_match4 __P((char *, char *, char *));
101 1.10 itojun #ifdef INET6
102 1.10 itojun static int masked_match6 __P((char *, char *, char *));
103 1.10 itojun #endif
104 1.1 mrg
105 1.1 mrg /* Size of logical line buffer. */
106 1.1 mrg
107 1.1 mrg #define BUFLEN 2048
108 1.1 mrg
109 1.1 mrg /* hosts_access - host access control facility */
110 1.1 mrg
111 1.1 mrg int hosts_access(request)
112 1.1 mrg struct request_info *request;
113 1.1 mrg {
114 1.1 mrg int verdict;
115 1.1 mrg
116 1.1 mrg /*
117 1.1 mrg * If the (daemon, client) pair is matched by an entry in the file
118 1.1 mrg * /etc/hosts.allow, access is granted. Otherwise, if the (daemon,
119 1.1 mrg * client) pair is matched by an entry in the file /etc/hosts.deny,
120 1.1 mrg * access is denied. Otherwise, access is granted. A non-existent
121 1.1 mrg * access-control file is treated as an empty file.
122 1.8 simonb *
123 1.1 mrg * After a rule has been matched, the optional language extensions may
124 1.1 mrg * decide to grant or refuse service anyway. Or, while a rule is being
125 1.1 mrg * processed, a serious error is found, and it seems better to play safe
126 1.1 mrg * and deny service. All this is done by jumping back into the
127 1.1 mrg * hosts_access() routine, bypassing the regular return from the
128 1.1 mrg * table_match() function calls below.
129 1.1 mrg */
130 1.1 mrg
131 1.1 mrg if (resident <= 0)
132 1.1 mrg resident++;
133 1.9 itojun verdict = setjmp(tcpd_buf);
134 1.9 itojun if (verdict != 0)
135 1.1 mrg return (verdict == AC_PERMIT);
136 1.1 mrg if (table_match(hosts_allow_table, request))
137 1.1 mrg return (YES);
138 1.1 mrg if (table_match(hosts_deny_table, request))
139 1.1 mrg return (NO);
140 1.1 mrg return (YES);
141 1.1 mrg }
142 1.1 mrg
143 1.1 mrg /* table_match - match table entries with (daemon, client) pair */
144 1.1 mrg
145 1.1 mrg static int table_match(table, request)
146 1.1 mrg char *table;
147 1.1 mrg struct request_info *request;
148 1.1 mrg {
149 1.1 mrg FILE *fp;
150 1.1 mrg char sv_list[BUFLEN]; /* becomes list of daemons */
151 1.1 mrg char *cl_list; /* becomes list of clients */
152 1.2 christos char *sh_cmd = NULL; /* becomes optional shell command */
153 1.1 mrg int match = NO;
154 1.1 mrg struct tcpd_context saved_context;
155 1.1 mrg
156 1.1 mrg saved_context = tcpd_context; /* stupid compilers */
157 1.1 mrg
158 1.1 mrg /*
159 1.1 mrg * Between the fopen() and fclose() calls, avoid jumps that may cause
160 1.1 mrg * file descriptor leaks.
161 1.1 mrg */
162 1.1 mrg
163 1.1 mrg if ((fp = fopen(table, "r")) != 0) {
164 1.1 mrg tcpd_context.file = table;
165 1.1 mrg tcpd_context.line = 0;
166 1.1 mrg while (match == NO && xgets(sv_list, sizeof(sv_list), fp) != 0) {
167 1.1 mrg if (sv_list[strlen(sv_list) - 1] != '\n') {
168 1.1 mrg tcpd_warn("missing newline or line too long");
169 1.1 mrg continue;
170 1.1 mrg }
171 1.1 mrg if (sv_list[0] == '#' || sv_list[strspn(sv_list, " \t\r\n")] == 0)
172 1.1 mrg continue;
173 1.1 mrg if ((cl_list = split_at(sv_list, ':')) == 0) {
174 1.1 mrg tcpd_warn("missing \":\" separator");
175 1.1 mrg continue;
176 1.1 mrg }
177 1.1 mrg sh_cmd = split_at(cl_list, ':');
178 1.1 mrg match = list_match(sv_list, request, server_match)
179 1.1 mrg && list_match(cl_list, request, client_match);
180 1.1 mrg }
181 1.1 mrg (void) fclose(fp);
182 1.1 mrg } else if (errno != ENOENT) {
183 1.1 mrg tcpd_warn("cannot open %s: %m", table);
184 1.1 mrg }
185 1.1 mrg if (match) {
186 1.1 mrg if (hosts_access_verbose > 1)
187 1.1 mrg syslog(LOG_DEBUG, "matched: %s line %d",
188 1.1 mrg tcpd_context.file, tcpd_context.line);
189 1.1 mrg if (sh_cmd) {
190 1.1 mrg #ifdef PROCESS_OPTIONS
191 1.1 mrg process_options(sh_cmd, request);
192 1.1 mrg #else
193 1.1 mrg char cmd[BUFSIZ];
194 1.1 mrg shell_cmd(percent_x(cmd, sizeof(cmd), sh_cmd, request));
195 1.1 mrg #endif
196 1.1 mrg }
197 1.1 mrg }
198 1.1 mrg tcpd_context = saved_context;
199 1.1 mrg return (match);
200 1.1 mrg }
201 1.1 mrg
202 1.1 mrg /* list_match - match a request against a list of patterns with exceptions */
203 1.1 mrg
204 1.1 mrg static int list_match(list, request, match_fn)
205 1.1 mrg char *list;
206 1.1 mrg struct request_info *request;
207 1.2 christos int (*match_fn) __P((char *, struct request_info *));
208 1.1 mrg {
209 1.1 mrg char *tok;
210 1.10 itojun int l;
211 1.1 mrg
212 1.1 mrg /*
213 1.1 mrg * Process tokens one at a time. We have exhausted all possible matches
214 1.1 mrg * when we reach an "EXCEPT" token or the end of the list. If we do find
215 1.1 mrg * a match, look for an "EXCEPT" list and recurse to determine whether
216 1.1 mrg * the match is affected by any exceptions.
217 1.1 mrg */
218 1.1 mrg
219 1.1 mrg for (tok = strtok(list, sep); tok != 0; tok = strtok((char *) 0, sep)) {
220 1.1 mrg if (STR_EQ(tok, "EXCEPT")) /* EXCEPT: give up */
221 1.1 mrg return (NO);
222 1.10 itojun l = strlen(tok);
223 1.10 itojun if (*tok == '[' && tok[l - 1] == ']') {
224 1.10 itojun tok[l - 1] = '\0';
225 1.10 itojun tok++;
226 1.10 itojun }
227 1.1 mrg if (match_fn(tok, request)) { /* YES: look for exceptions */
228 1.1 mrg while ((tok = strtok((char *) 0, sep)) && STR_NE(tok, "EXCEPT"))
229 1.1 mrg /* VOID */ ;
230 1.1 mrg return (tok == 0 || list_match((char *) 0, request, match_fn) == 0);
231 1.1 mrg }
232 1.1 mrg }
233 1.1 mrg return (NO);
234 1.1 mrg }
235 1.1 mrg
236 1.1 mrg /* server_match - match server information */
237 1.1 mrg
238 1.1 mrg static int server_match(tok, request)
239 1.1 mrg char *tok;
240 1.1 mrg struct request_info *request;
241 1.1 mrg {
242 1.1 mrg char *host;
243 1.1 mrg
244 1.1 mrg if ((host = split_at(tok + 1, '@')) == 0) { /* plain daemon */
245 1.1 mrg return (string_match(tok, eval_daemon(request)));
246 1.1 mrg } else { /* daemon@host */
247 1.1 mrg return (string_match(tok, eval_daemon(request))
248 1.1 mrg && host_match(host, request->server));
249 1.1 mrg }
250 1.1 mrg }
251 1.1 mrg
252 1.1 mrg /* client_match - match client information */
253 1.1 mrg
254 1.1 mrg static int client_match(tok, request)
255 1.1 mrg char *tok;
256 1.1 mrg struct request_info *request;
257 1.1 mrg {
258 1.1 mrg char *host;
259 1.1 mrg
260 1.1 mrg if ((host = split_at(tok + 1, '@')) == 0) { /* plain host */
261 1.1 mrg return (host_match(tok, request->client));
262 1.1 mrg } else { /* user@host */
263 1.1 mrg return (host_match(host, request->client)
264 1.1 mrg && string_match(tok, eval_user(request)));
265 1.1 mrg }
266 1.1 mrg }
267 1.1 mrg
268 1.1 mrg /* host_match - match host name and/or address against pattern */
269 1.1 mrg
270 1.1 mrg static int host_match(tok, host)
271 1.1 mrg char *tok;
272 1.1 mrg struct host_info *host;
273 1.1 mrg {
274 1.1 mrg char *mask;
275 1.1 mrg
276 1.1 mrg /*
277 1.1 mrg * This code looks a little hairy because we want to avoid unnecessary
278 1.1 mrg * hostname lookups.
279 1.8 simonb *
280 1.1 mrg * The KNOWN pattern requires that both address AND name be known; some
281 1.1 mrg * patterns are specific to host names or to host addresses; all other
282 1.1 mrg * patterns are satisfied when either the address OR the name match.
283 1.1 mrg */
284 1.1 mrg
285 1.1 mrg if (tok[0] == '@') { /* netgroup: look it up */
286 1.1 mrg #ifdef NETGROUP
287 1.1 mrg static char *mydomain = 0;
288 1.1 mrg if (mydomain == 0)
289 1.1 mrg yp_get_default_domain(&mydomain);
290 1.1 mrg return (innetgr(tok + 1, eval_hostname(host), (char *) 0, mydomain));
291 1.1 mrg #else
292 1.1 mrg tcpd_warn("netgroup support is disabled"); /* not tcpd_jump() */
293 1.1 mrg return (NO);
294 1.1 mrg #endif
295 1.1 mrg } else if (STR_EQ(tok, "KNOWN")) { /* check address and name */
296 1.1 mrg char *name = eval_hostname(host);
297 1.1 mrg return (STR_NE(eval_hostaddr(host), unknown) && HOSTNAME_KNOWN(name));
298 1.1 mrg } else if (STR_EQ(tok, "LOCAL")) { /* local: no dots in name */
299 1.1 mrg char *name = eval_hostname(host);
300 1.1 mrg return (strchr(name, '.') == 0 && HOSTNAME_KNOWN(name));
301 1.4 christos } else if (strncmp(tok, "{RBL}.", 6) == 0) { /* RBL lookup in domain */
302 1.4 christos return rbl_match(tok+6, eval_hostaddr(host));
303 1.1 mrg } else if ((mask = split_at(tok, '/')) != 0) { /* net/mask */
304 1.1 mrg return (masked_match(tok, mask, eval_hostaddr(host)));
305 1.1 mrg } else { /* anything else */
306 1.1 mrg return (string_match(tok, eval_hostaddr(host))
307 1.1 mrg || (NOT_INADDR(tok) && string_match(tok, eval_hostname(host))));
308 1.1 mrg }
309 1.4 christos }
310 1.4 christos
311 1.4 christos /* rbl_match() - match host by looking up in RBL domain */
312 1.4 christos
313 1.4 christos static int rbl_match(rbl_domain, rbl_hostaddr)
314 1.4 christos char *rbl_domain; /* RBL domain */
315 1.4 christos char *rbl_hostaddr; /* hostaddr */
316 1.4 christos {
317 1.4 christos char *rbl_name;
318 1.4 christos unsigned long host_address;
319 1.4 christos int ret = NO;
320 1.5 christos size_t len = strlen(rbl_domain) + (4 * 4) + 2;
321 1.8 simonb
322 1.6 christos if (dot_quad_addr(rbl_hostaddr, &host_address) != 0) {
323 1.4 christos tcpd_warn("unable to convert %s to address", rbl_hostaddr);
324 1.4 christos return (NO);
325 1.4 christos }
326 1.4 christos /* construct the rbl name to look up */
327 1.5 christos if ((rbl_name = malloc(len)) == NULL) {
328 1.4 christos tcpd_jump("not enough memory to build RBL name for %s in %s", rbl_hostaddr, rbl_domain);
329 1.4 christos /* NOTREACHED */
330 1.4 christos }
331 1.5 christos snprintf(rbl_name, len, "%u.%u.%u.%u.%s",
332 1.4 christos (unsigned int) ((host_address) & 0xff),
333 1.4 christos (unsigned int) ((host_address >> 8) & 0xff),
334 1.4 christos (unsigned int) ((host_address >> 16) & 0xff),
335 1.4 christos (unsigned int) ((host_address >> 24) & 0xff),
336 1.4 christos rbl_domain);
337 1.4 christos /* look it up */
338 1.4 christos if (gethostbyname(rbl_name) != NULL) {
339 1.4 christos /* successful lookup - they're on the RBL list */
340 1.4 christos ret = YES;
341 1.4 christos }
342 1.4 christos free(rbl_name);
343 1.4 christos
344 1.4 christos return ret;
345 1.1 mrg }
346 1.1 mrg
347 1.1 mrg /* string_match - match string against pattern */
348 1.1 mrg
349 1.1 mrg static int string_match(tok, string)
350 1.1 mrg char *tok;
351 1.1 mrg char *string;
352 1.1 mrg {
353 1.1 mrg int n;
354 1.1 mrg
355 1.1 mrg if (tok[0] == '.') { /* suffix */
356 1.1 mrg n = strlen(string) - strlen(tok);
357 1.1 mrg return (n > 0 && STR_EQ(tok, string + n));
358 1.1 mrg } else if (STR_EQ(tok, "ALL")) { /* all: match any */
359 1.1 mrg return (YES);
360 1.1 mrg } else if (STR_EQ(tok, "KNOWN")) { /* not unknown */
361 1.1 mrg return (STR_NE(string, unknown));
362 1.1 mrg } else if (tok[(n = strlen(tok)) - 1] == '.') { /* prefix */
363 1.1 mrg return (STRN_EQ(tok, string, n));
364 1.1 mrg } else { /* exact match */
365 1.1 mrg return (STR_EQ(tok, string));
366 1.1 mrg }
367 1.1 mrg }
368 1.1 mrg
369 1.1 mrg /* masked_match - match address against netnumber/netmask */
370 1.1 mrg
371 1.1 mrg static int masked_match(net_tok, mask_tok, string)
372 1.1 mrg char *net_tok;
373 1.1 mrg char *mask_tok;
374 1.1 mrg char *string;
375 1.1 mrg {
376 1.10 itojun #ifndef INET6
377 1.10 itojun return masked_match4(net_tok, mask_tok, string);
378 1.10 itojun #else
379 1.10 itojun if (dot_quad_addr(net_tok, NULL) != INADDR_NONE
380 1.10 itojun && dot_quad_addr(mask_tok, NULL) != INADDR_NONE
381 1.10 itojun && dot_quad_addr(string, NULL) != INADDR_NONE) {
382 1.10 itojun return masked_match4(net_tok, mask_tok, string);
383 1.10 itojun } else
384 1.10 itojun return masked_match6(net_tok, mask_tok, string);
385 1.10 itojun #endif
386 1.10 itojun }
387 1.10 itojun
388 1.10 itojun static int masked_match4(net_tok, mask_tok, string)
389 1.10 itojun char *net_tok;
390 1.10 itojun char *mask_tok;
391 1.10 itojun char *string;
392 1.10 itojun {
393 1.1 mrg unsigned long net;
394 1.1 mrg unsigned long mask;
395 1.1 mrg unsigned long addr;
396 1.1 mrg
397 1.1 mrg /*
398 1.1 mrg * Disallow forms other than dotted quad: the treatment that inet_addr()
399 1.1 mrg * gives to forms with less than four components is inconsistent with the
400 1.1 mrg * access control language. John P. Rouillard <rouilj (at) cs.umb.edu>.
401 1.1 mrg */
402 1.1 mrg
403 1.6 christos if (dot_quad_addr(string, &addr) != 0)
404 1.1 mrg return (NO);
405 1.6 christos if (dot_quad_addr(net_tok, &net) != 0
406 1.6 christos || dot_quad_addr(mask_tok, &mask) != 0) {
407 1.1 mrg tcpd_warn("bad net/mask expression: %s/%s", net_tok, mask_tok);
408 1.1 mrg return (NO); /* not tcpd_jump() */
409 1.1 mrg }
410 1.12 atatat
411 1.12 atatat if ((net & ~mask) != 0)
412 1.12 atatat tcpd_warn("host bits not all zero in %s/%s", net_tok, mask_tok);
413 1.12 atatat
414 1.1 mrg return ((addr & mask) == net);
415 1.1 mrg }
416 1.10 itojun
417 1.10 itojun #ifdef INET6
418 1.10 itojun /* Ugly because it covers IPv4 mapped address. I hate mapped addresses. */
419 1.10 itojun static int masked_match6(net_tok, mask_tok, string)
420 1.10 itojun char *net_tok;
421 1.10 itojun char *mask_tok;
422 1.10 itojun char *string;
423 1.10 itojun {
424 1.10 itojun struct in6_addr net;
425 1.10 itojun struct in6_addr mask;
426 1.10 itojun struct in6_addr addr;
427 1.10 itojun int masklen;
428 1.10 itojun int fail;
429 1.10 itojun int i;
430 1.10 itojun int maskoff;
431 1.10 itojun int netaf;
432 1.12 atatat int dirty;
433 1.10 itojun const int sizoff64 = sizeof(struct in6_addr) - sizeof(struct in_addr);
434 1.10 itojun
435 1.10 itojun memset(&addr, 0, sizeof(addr));
436 1.10 itojun if (inet_pton(AF_INET6, string, &addr) == 1)
437 1.10 itojun ; /* okay */
438 1.10 itojun else if (inet_pton(AF_INET, string, &addr.s6_addr[sizoff64]) == 1)
439 1.10 itojun addr.s6_addr[10] = addr.s6_addr[11] = 0xff;
440 1.10 itojun else
441 1.10 itojun return NO;
442 1.10 itojun
443 1.10 itojun memset(&net, 0, sizeof(net));
444 1.10 itojun if (inet_pton(AF_INET6, net_tok, &net) == 1) {
445 1.10 itojun netaf = AF_INET6;
446 1.10 itojun maskoff = 0;
447 1.10 itojun } else if (inet_pton(AF_INET, net_tok, &net.s6_addr[sizoff64]) == 1) {
448 1.10 itojun netaf = AF_INET;
449 1.10 itojun maskoff = sizoff64;
450 1.10 itojun net.s6_addr[10] = net.s6_addr[11] = 0xff;
451 1.10 itojun } else
452 1.10 itojun return NO;
453 1.10 itojun
454 1.10 itojun fail = 0;
455 1.10 itojun if (mask_tok[strspn(mask_tok, "0123456789")] == '\0') {
456 1.10 itojun masklen = atoi(mask_tok) + maskoff * 8;
457 1.10 itojun if (0 <= masklen && masklen <= 128) {
458 1.10 itojun memset(&mask, 0, sizeof(mask));
459 1.10 itojun memset(&mask, 0xff, masklen / 8);
460 1.10 itojun if (masklen % 8) {
461 1.10 itojun ((u_char *)&mask)[masklen / 8] =
462 1.10 itojun (0xff00 >> (masklen % 8)) & 0xff;
463 1.10 itojun }
464 1.10 itojun } else
465 1.10 itojun fail++;
466 1.10 itojun } else if (netaf == AF_INET6 && inet_pton(AF_INET6, mask_tok, &mask) == 1)
467 1.10 itojun ; /* okay */
468 1.10 itojun else if (netaf == AF_INET
469 1.10 itojun && inet_pton(AF_INET, mask_tok, &mask.s6_addr[12]) == 1) {
470 1.10 itojun memset(&mask, 0xff, sizoff64);
471 1.10 itojun } else
472 1.10 itojun fail++;
473 1.10 itojun if (fail) {
474 1.10 itojun tcpd_warn("bad net/mask expression: %s/%s", net_tok, mask_tok);
475 1.10 itojun return (NO); /* not tcpd_jump() */
476 1.10 itojun }
477 1.10 itojun
478 1.12 atatat for (i = 0; i < sizeof(addr); i++) {
479 1.10 itojun addr.s6_addr[i] &= mask.s6_addr[i];
480 1.12 atatat dirty |= (net.s6_addr[i] & ~mask.s6_addr[i]);
481 1.12 atatat }
482 1.12 atatat
483 1.12 atatat if (dirty)
484 1.12 atatat tcpd_warn("host bits not all zero in %s/%s", net_tok, mask_tok);
485 1.12 atatat
486 1.10 itojun return (memcmp(&addr, &net, sizeof(addr)) == 0);
487 1.10 itojun }
488 1.10 itojun #endif
489