encap_getarg() was not properly loading the pointer argument associated
[dragonfly.git] / contrib / tcp_wrappers / hosts_access.5
1 .TH HOSTS_ACCESS 5
2 .SH NAME
3 hosts_access \- format of host access control files
4 .SH DESCRIPTION
5 This manual page describes a simple access control language that is
6 based on client (host name/address, user name), and server (process
7 name, host name/address) patterns.  Examples are given at the end. The
8 impatient reader is encouraged to skip to the EXAMPLES section for a
9 quick introduction.
10 .PP
11 An extended version of the access control language is described in the
12 \fIhosts_options\fR(5) document. The extensions are turned on at
13 program build time by building with -DPROCESS_OPTIONS.
14 .PP
15 In the following text, \fIdaemon\fR is the the process name of a
16 network daemon process, and \fIclient\fR is the name and/or address of
17 a host requesting service. Network daemon process names are specified
18 in the inetd configuration file.
19 .SH ACCESS CONTROL FILES
20 The access control software consults two files. The search stops
21 at the first match:
22 .IP \(bu
23 Access will be granted when a (daemon,client) pair matches an entry in
24 the \fI/etc/hosts.allow\fR file.
25 .IP \(bu
26 Otherwise, access will be denied when a (daemon,client) pair matches an
27 entry in the \fI/etc/hosts.deny\fR file.
28 .IP \(bu
29 Otherwise, access will be granted.
30 .PP
31 A non-existing access control file is treated as if it were an empty
32 file. Thus, access control can be turned off by providing no access
33 control files.
34 .SH ACCESS CONTROL RULES
35 Each access control file consists of zero or more lines of text.  These
36 lines are processed in order of appearance. The search terminates when a
37 match is found.
38 .IP \(bu
39 A newline character is ignored when it is preceded by a backslash
40 character. This permits you to break up long lines so that they are
41 easier to edit.
42 .IP \(bu
43 Blank lines or lines that begin with a `#\' character are ignored.
44 This permits you to insert comments and whitespace so that the tables
45 are easier to read.
46 .IP \(bu
47 All other lines should satisfy the following format, things between []
48 being optional:
49 .sp
50 .ti +3
51 daemon_list : client_list [ : shell_command ]
52 .PP
53 \fIdaemon_list\fR is a list of one or more daemon process names
54 (argv[0] values) or wildcards (see below).  
55 .PP
56 \fIclient_list\fR is a list
57 of one or more host names, host addresses, patterns or wildcards (see
58 below) that will be matched against the client host name or address.
59 .PP
60 The more complex forms \fIdaemon@host\fR and \fIuser@host\fR are
61 explained in the sections on server endpoint patterns and on client
62 username lookups, respectively.
63 .PP
64 List elements should be separated by blanks and/or commas.  
65 .PP
66 With the exception of NIS (YP) netgroup lookups, all access control
67 checks are case insensitive.
68 .ne 4
69 .SH PATTERNS
70 The access control language implements the following patterns:
71 .IP \(bu
72 A string that begins with a `.\' character. A host name is matched if
73 the last components of its name match the specified pattern.  For
74 example, the pattern `.tue.nl\' matches the host name
75 `wzv.win.tue.nl\'.
76 .IP \(bu
77 A string that ends with a `.\' character. A host address is matched if
78 its first numeric fields match the given string.  For example, the
79 pattern `131.155.\' matches the address of (almost) every host on the
80 Eind\%hoven University network (131.155.x.x).
81 .IP \(bu
82 A string that begins with an `@\' character is treated as an NIS
83 (formerly YP) netgroup name. A host name is matched if it is a host
84 member of the specified netgroup. Netgroup matches are not supported
85 for daemon process names or for client user names.
86 .IP \(bu
87 An expression of the form `n.n.n.n/m.m.m.m\' is interpreted as a
88 `net/mask\' pair. A host address is matched if `net\' is equal to the
89 bitwise AND of the address and the `mask\'. For example, the net/mask
90 pattern `131.155.72.0/255.255.254.0\' matches every address in the
91 range `131.155.72.0\' through `131.155.73.255\'.
92 .IP \(bu
93 An expression of the form `[n:n:n:n:n:n:n:n]/m\' is interpreted as a
94 `[net]/prefixlen\' pair. A IPv6 host address is matched if
95 `prefixlen\' bits of `net\' is equal to the `prefixlen\' bits of the
96 address. For example, the [net]/prefixlen pattern
97 `[3ffe:505:2:1::]/64\' matches every address in the range
98 `3ffe:505:2:1::\' through `3ffe:505:2:1:ffff:ffff:ffff:ffff\'.
99 .IP \(bu
100 A string that begins with a `/\' character is treated as a file
101 name. A host name or address is matched if it matches any host name
102 or address pattern listed in the named file. The file format is
103 zero or more lines with zero or more host name or address patterns
104 separated by whitespace.  A file name pattern can be used anywhere
105 a host name or address pattern can be used.
106 .SH WILDCARDS
107 The access control language supports explicit wildcards:
108 .IP ALL
109 The universal wildcard, always matches.
110 .IP LOCAL
111 Matches any host whose name does not contain a dot character.
112 .IP UNKNOWN
113 Matches any user whose name is unknown, and matches any host whose name
114 \fIor\fR address are unknown.  This pattern should be used with care:
115 host names may be unavailable due to temporary name server problems. A
116 network address will be unavailable when the software cannot figure out
117 what type of network it is talking to.
118 .IP KNOWN
119 Matches any user whose name is known, and matches any host whose name
120 \fIand\fR address are known. This pattern should be used with care:
121 host names may be unavailable due to temporary name server problems.  A
122 network address will be unavailable when the software cannot figure out
123 what type of network it is talking to.
124 .IP PARANOID
125 Matches any host whose name does not match its address.  When tcpd is
126 built with -DPARANOID (default mode), it drops requests from such
127 clients even before looking at the access control tables.  Build
128 without -DPARANOID when you want more control over such requests.
129 .ne 6
130 .SH OPERATORS
131 .IP EXCEPT
132 Intended use is of the form: `list_1 EXCEPT list_2\'; this construct
133 matches anything that matches \fIlist_1\fR unless it matches
134 \fIlist_2\fR.  The EXCEPT operator can be used in daemon_lists and in
135 client_lists. The EXCEPT operator can be nested: if the control
136 language would permit the use of parentheses, `a EXCEPT b EXCEPT c\'
137 would parse as `(a EXCEPT (b EXCEPT c))\'.
138 .br
139 .ne 6
140 .SH SHELL COMMANDS
141 If the first-matched access control rule contains a shell command, that
142 command is subjected to %<letter> substitutions (see next section).
143 The result is executed by a \fI/bin/sh\fR child process with standard
144 input, output and error connected to \fI/dev/null\fR.  Specify an `&\'
145 at the end of the command if you do not want to wait until it has
146 completed.
147 .PP
148 Shell commands should not rely on the PATH setting of the inetd.
149 Instead, they should use absolute path names, or they should begin with
150 an explicit PATH=whatever statement.
151 .PP
152 The \fIhosts_options\fR(5) document describes an alternative language
153 that uses the shell command field in a different and incompatible way.
154 .SH % EXPANSIONS
155 The following expansions are available within shell commands:
156 .IP "%a (%A)"
157 The client (server) host address.
158 .IP %c
159 Client information: user@host, user@address, a host name, or just an
160 address, depending on how much information is available.
161 .IP %d
162 The daemon process name (argv[0] value).
163 .IP "%h (%H)"
164 The client (server) host name or address, if the host name is
165 unavailable.
166 .IP "%n (%N)"
167 The client (server) host name (or "unknown" or "paranoid").
168 .IP %p
169 The daemon process id.
170 .IP %s
171 Server information: daemon@host, daemon@address, or just a daemon name,
172 depending on how much information is available.
173 .IP %u
174 The client user name (or "unknown").
175 .IP %%
176 Expands to a single `%\' character.
177 .PP
178 Characters in % expansions that may confuse the shell are replaced by
179 underscores.
180 .SH SERVER ENDPOINT PATTERNS
181 In order to distinguish clients by the network address that they
182 connect to, use patterns of the form:
183 .sp
184 .ti +3
185 process_name@host_pattern : client_list ...
186 .sp
187 Patterns like these can be used when the machine has different internet
188 addresses with different internet hostnames.  Service providers can use
189 this facility to offer FTP, GOPHER or WWW archives with internet names
190 that may even belong to different organizations. See also the `twist'
191 option in the hosts_options(5) document. Some systems (Solaris,
192 FreeBSD) can have more than one internet address on one physical
193 interface; with other systems you may have to resort to SLIP or PPP
194 pseudo interfaces that live in a dedicated network address space.
195 .sp
196 The host_pattern obeys the same syntax rules as host names and
197 addresses in client_list context. Usually, server endpoint information
198 is available only with connection-oriented services.
199 .SH CLIENT USERNAME LOOKUP
200 When the client host supports the RFC 931 protocol or one of its
201 descendants (TAP, IDENT, RFC 1413) the wrapper programs can retrieve
202 additional information about the owner of a connection. Client username
203 information, when available, is logged together with the client host
204 name, and can be used to match patterns like:
205 .PP
206 .ti +3
207 daemon_list : ... user_pattern@host_pattern ...
208 .PP
209 The daemon wrappers can be configured at compile time to perform
210 rule-driven username lookups (default) or to always interrogate the
211 client host.  In the case of rule-driven username lookups, the above
212 rule would cause username lookup only when both the \fIdaemon_list\fR
213 and the \fIhost_pattern\fR match. 
214 .PP
215 A user pattern has the same syntax as a daemon process pattern, so the
216 same wildcards apply (netgroup membership is not supported).  One
217 should not get carried away with username lookups, though.
218 .IP \(bu
219 The client username information cannot be trusted when it is needed
220 most, i.e. when the client system has been compromised.  In general,
221 ALL and (UN)KNOWN are the only user name patterns that make sense.
222 .IP \(bu
223 Username lookups are possible only with TCP-based services, and only
224 when the client host runs a suitable daemon; in all other cases the
225 result is "unknown".
226 .IP \(bu
227 A well-known UNIX kernel bug may cause loss of service when username
228 lookups are blocked by a firewall. The wrapper README document
229 describes a procedure to find out if your kernel has this bug.
230 .IP \(bu
231 Username lookups may cause noticeable delays for non-UNIX users.  The
232 default timeout for username lookups is 10 seconds: too short to cope
233 with slow networks, but long enough to irritate PC users.
234 .PP
235 Selective username lookups can alleviate the last problem. For example,
236 a rule like:
237 .PP
238 .ti +3
239 daemon_list : @pcnetgroup ALL@ALL
240 .PP
241 would match members of the pc netgroup without doing username lookups,
242 but would perform username lookups with all other systems.
243 .SH DETECTING ADDRESS SPOOFING ATTACKS
244 A flaw in the sequence number generator of many TCP/IP implementations
245 allows intruders to easily impersonate trusted hosts and to break in
246 via, for example, the remote shell service.  The IDENT (RFC931 etc.)
247 service can be used to detect such and other host address spoofing
248 attacks.
249 .PP
250 Before accepting a client request, the wrappers can use the IDENT
251 service to find out that the client did not send the request at all.
252 When the client host provides IDENT service, a negative IDENT lookup
253 result (the client matches `UNKNOWN@host') is strong evidence of a host
254 spoofing attack.
255 .PP
256 A positive IDENT lookup result (the client matches `KNOWN@host') is
257 less trustworthy. It is possible for an intruder to spoof both the
258 client connection and the IDENT lookup, although doing so is much
259 harder than spoofing just a client connection. It may also be that
260 the client\'s IDENT server is lying.
261 .PP
262 Note: IDENT lookups don\'t work with UDP services. 
263 .SH EXAMPLES
264 The language is flexible enough that different types of access control
265 policy can be expressed with a minimum of fuss. Although the language
266 uses two access control tables, the most common policies can be
267 implemented with one of the tables being trivial or even empty.
268 .PP
269 When reading the examples below it is important to realize that the
270 allow table is scanned before the deny table, that the search
271 terminates when a match is found, and that access is granted when no
272 match is found at all.
273 .PP
274 The examples use host and domain names. They can be improved by
275 including address and/or network/netmask information, to reduce the
276 impact of temporary name server lookup failures.
277 .SH MOSTLY CLOSED
278 In this case, access is denied by default. Only explicitly authorized
279 hosts are permitted access. 
280 .PP
281 The default policy (no access) is implemented with a trivial deny
282 file:
283 .PP
284 .ne 2
285 /etc/hosts.deny: 
286 .in +3
287 ALL: ALL
288 .PP
289 This denies all service to all hosts, unless they are permitted access
290 by entries in the allow file.
291 .PP
292 The explicitly authorized hosts are listed in the allow file.
293 For example:
294 .PP
295 .ne 2
296 /etc/hosts.allow: 
297 .in +3
298 ALL: LOCAL @some_netgroup
299 .br
300 ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
301 .PP
302 The first rule permits access from hosts in the local domain (no `.\'
303 in the host name) and from members of the \fIsome_netgroup\fP
304 netgroup.  The second rule permits access from all hosts in the
305 \fIfoobar.edu\fP domain (notice the leading dot), with the exception of
306 \fIterminalserver.foobar.edu\fP.
307 .SH MOSTLY OPEN
308 Here, access is granted by default; only explicitly specified hosts are
309 refused service. 
310 .PP
311 The default policy (access granted) makes the allow file redundant so
312 that it can be omitted.  The explicitly non-authorized hosts are listed
313 in the deny file. For example:
314 .PP
315 /etc/hosts.deny:
316 .in +3
317 ALL: some.host.name, .some.domain
318 .br
319 ALL EXCEPT in.fingerd: other.host.name, .other.domain
320 .PP
321 The first rule denies some hosts and domains all services; the second
322 rule still permits finger requests from other hosts and domains.
323 .SH BOOBY TRAPS
324 The next example permits tftp requests from hosts in the local domain
325 (notice the leading dot).  Requests from any other hosts are denied.
326 Instead of the requested file, a finger probe is sent to the offending
327 host. The result is mailed to the superuser.
328 .PP
329 .ne 2
330 /etc/hosts.allow:
331 .in +3
332 .nf
333 in.tftpd: LOCAL, .my.domain
334 .PP
335 .ne 2
336 /etc/hosts.deny:
337 .in +3
338 .nf
339 in.tftpd: ALL: (/some/where/safe_finger -l @%h | \\
340         /usr/ucb/mail -s %d-%h root) &
341 .fi
342 .PP
343 The safe_finger command is intended for use in back-fingering and should be
344 installed in a suitable place. It limits possible damage from data sent
345 by the remote finger server.  It gives better protection than the
346 standard finger command.
347 .PP
348 The expansion of the %h (client host) and %d (service name) sequences
349 is described in the section on shell commands.
350 .PP
351 Warning: do not booby-trap your finger daemon, unless you are prepared
352 for infinite finger loops.
353 .PP
354 On network firewall systems this trick can be carried even further.
355 The typical network firewall only provides a limited set of services to
356 the outer world. All other services can be "bugged" just like the above
357 tftp example. The result is an excellent early-warning system.
358 .br
359 .ne 4
360 .SH DIAGNOSTICS
361 An error is reported when a syntax error is found in a host access
362 control rule; when the length of an access control rule exceeds the
363 capacity of an internal buffer; when an access control rule is not
364 terminated by a newline character; when the result of %<letter>
365 expansion would overflow an internal buffer; when a system call fails
366 that shouldn\'t.  All problems are reported via the syslog daemon.
367 .SH IMPLEMENTATION NOTES
368 Some operating systems are distributed with TCP Wrappers as part of the
369 base system. It is common for such systems to build wrapping functionality
370 into networking utilities. Notably, some systems offer an \fIinetd\fR(8)
371 which does not require the use of the \fItcpd\fR(8). Check your system's
372 documentation for details.
373 .SH FILES
374 .na
375 .nf
376 /etc/hosts.allow, (daemon,client) pairs that are granted access.
377 /etc/hosts.deny, (daemon,client) pairs that are denied access.
378 .ad
379 .fi
380 .SH SEE ALSO
381 .nf
382 tcpd(8) tcp/ip daemon wrapper program.
383 tcpdchk(8), tcpdmatch(8), test programs.
384 .SH BUGS
385 If a name server lookup times out, the host name will not be available
386 to the access control software, even though the host is registered.
387 .PP
388 Domain name server lookups are case insensitive; NIS (formerly YP)
389 netgroup lookups are case sensitive.
390 .SH AUTHOR
391 .na
392 .nf
393 Wietse Venema (wietse@wzv.win.tue.nl)
394 Department of Mathematics and Computing Science
395 Eindhoven University of Technology
396 Den Dolech 2, P.O. Box 513, 
397 5600 MB Eindhoven, The Netherlands
398 \" @(#) hosts_access.5 1.20 95/01/30 19:51:46
399 \" $FreeBSD: src/contrib/tcp_wrappers/hosts_access.5,v 1.3 2000/02/03 10:26:57 shin Exp $
400 \" $DragonFly: src/contrib/tcp_wrappers/hosts_access.5,v 1.2 2003/06/17 04:24:06 dillon Exp $