diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libwrap/hosts_access.3 | 188 | ||||
-rw-r--r-- | lib/libwrap/hosts_access.5 | 422 | ||||
-rw-r--r-- | lib/libwrap/hosts_options.5 | 236 |
3 files changed, 517 insertions, 329 deletions
diff --git a/lib/libwrap/hosts_access.3 b/lib/libwrap/hosts_access.3 index cd14d066abf..b94e61d1e6f 100644 --- a/lib/libwrap/hosts_access.3 +++ b/lib/libwrap/hosts_access.3 @@ -1,94 +1,146 @@ -.\" $OpenBSD: hosts_access.3,v 1.2 1997/02/26 03:12:48 downsj Exp $ -.TH HOSTS_ACCESS 3 -.SH NAME -hosts_access, hosts_ctl, request_init, request_set \- access control library -.SH SYNOPSIS -.nf -#include <tcpd.h> - -extern int allow_severity; -extern int deny_severity; - -struct request_info *request_init(request, key, value, ..., 0) -struct request_info *request; - -struct request_info *request_set(request, key, value, ..., 0) -struct request_info *request; - -int hosts_access(request) -struct request_info *request; - -int hosts_ctl(daemon, client_name, client_addr, client_user) -char *daemon; -char *client_name; -char *client_addr; -char *client_user; -.fi -.SH DESCRIPTION -The routines described in this document are part of the \fIlibwrap.a\fR -library. They implement a rule-based access control language with +.\" $OpenBSD: hosts_access.3,v 1.3 1997/06/23 11:12:40 downsj Exp $ +.\" +.\" Copyright (c) 1997, Jason Downs. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Jason Downs for the +.\" OpenBSD system. +.\" 4. Neither the name(s) of the author(s) nor the name OpenBSD +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, +.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd June 23, 1997 +.Dt HOSTS_ACCESS 3 +.Os +.Sh NAME +.Nm hosts_access , +.Nm hosts_ctl , +.Nm request_init , +.Nm request_set +.Nd access control library +.Sh SYNOPSIS +.Fd #include <tcpd.h> +.Vt extern int allow_severity; +.Vt extern int deny_severity; +.Ft struct request_info * +.Fn request_init "struct request_info *request" "int key" value ... 0 +.Ft struct request_info * +.Fn request_set "struct request_info *request" "int key" value ... 0 +.Ft int +.Fn hosts_access "struct request_info *request" +.Ft int +.Fn hosts_ctl "char *daemon" "char *client_name" "char *client_addr" "char *client_user" +.Sh DESCRIPTION +The routines described in this document are part of the +.Nm libwrap.a +library. They implement a rule-based access control language with optional shell commands that are executed when a rule fires. -.PP -request_init() initializes a structure with information about a client -request. request_set() updates an already initialized request -structure. Both functions take a variable-length list of key-value -pairs and return their first argument. The argument lists are -terminated with a zero key value. All string-valued arguments are -copied. The expected keys (and corresponding value types) are: -.IP "RQ_FILE (int)" +.Pp +.Fn request_init +initializes a structure with information about a client +request. +.Fn request_set +updates an already initialized request structure. Both functions take a +variable-length list of key-value pairs and return their first argument. +The argument lists are terminated with a zero key value. All string-valued +arguments are copied. The expected keys (and corresponding value types) are: +.Bl -tag -width XXXXXXXXXXXXXXXXXXXXXXXX +.It "RQ_FILE (int)" The file descriptor associated with the request. -.IP "RQ_CLIENT_NAME (char *)" +.It "RQ_CLIENT_NAME (char *)" The client host name. -.IP "RQ_CLIENT_ADDR (char *)" +.It "RQ_CLIENT_ADDR (char *)" A printable representation of the client network address. -.IP "RQ_CLIENT_SIN (struct sockaddr_in *)" +.It "RQ_CLIENT_SIN (struct sockaddr_in *)" An internal representation of the client network address and port. The contents of the structure are not copied. -.IP "RQ_SERVER_NAME (char *)" +.It "RQ_SERVER_NAME (char *)" The hostname associated with the server endpoint address. -.IP "RQ_SERVER_ADDR (char *)" +.It "RQ_SERVER_ADDR (char *)" A printable representation of the server endpoint address. -.IP "RQ_SERVER_SIN (struct sockaddr_in *)" +.It "RQ_SERVER_SIN (struct sockaddr_in *)" An internal representation of the server endpoint address and port. The contents of the structure are not copied. -.IP "RQ_DAEMON (char *)" +.It "RQ_DAEMON (char *)" The name of the daemon process running on the server host. -.IP "RQ_USER (char *)" +.It "RQ_USER (char *)" The name of the user on whose behalf the client host makes the request. -.PP -hosts_access() consults the access control tables described in the -\fIhosts_access(5)\fR manual page. When internal endpoint information -is available, host names and client user names are looked up on demand, -using the request structure as a cache. hosts_access() returns zero if -access should be denied. -.PP -hosts_ctl() is a wrapper around the request_init() and hosts_access() +.El +.Pp +.Fn hosts_access +consults the access control tables described in the +.Xr hosts_access 5 +manual page. When internal endpoint information is available, host names +and client user names are looked up on demand, using the request structure +as a cache. +.Fn hosts_access +returns zero if access should be denied. +.Pp +.Fn hosts_ctl +is a wrapper around the +.Fn request_init +and +.Fn hosts_access routines with a perhaps more convenient interface (though it does not pass on enough information to support automated client username lookups). The client host address, client host name and username -arguments should contain valid data or STRING_UNKNOWN. hosts_ctl() +arguments should contain valid data or STRING_UNKNOWN. +.Fn hosts_ctl returns zero if access should be denied. -.PP -The \fIallow_severity\fR and \fIdeny_severity\fR variables determine +.Pp +The +.Fa allow_severity +and +.Fa deny_severity +variables determine how accepted and rejected requests may be logged. They must be provided by the caller and may be modified by rules in the access control tables. -.SH DIAGNOSTICS +.Sh DIAGNOSTICS Problems are reported via the syslog daemon. -.SH SEE ALSO -hosts_access(5), format of the access control tables. -hosts_options(5), optional extensions to the base language. -.SH FILES -/etc/hosts.allow, /etc/hosts.deny, access control tables. -.SH BUGS -hosts_access() uses the strtok() library function. This may interfere -with other code that relies on strtok(). -.SH AUTHOR -.na -.nf +.Sh SEE ALSO +.Xr hosts_access 5 , +.Xr hosts_options 5 . +.Sh FILES +.Bl -tag -width /etc/hosts.allow -compact +.It Pa /etc/hosts.allow +Access control table (allow list) +.It Pa /etc/hosts.deny +Access control table (deny list) +.El +.Sh BUGS +.Fn hosts_access +uses the +.Fn strtok +library function. This may interfere with other code that relies on +.Fn strtok . +.Sh AUTHOR +.Bd -unfilled -offset indent Wietse Venema (wietse@wzv.win.tue.nl) Department of Mathematics and Computing Science Eindhoven University of Technology Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands +.Ed \" @(#) hosts_access.3 1.8 96/02/11 17:01:26 diff --git a/lib/libwrap/hosts_access.5 b/lib/libwrap/hosts_access.5 index a37636b1122..7d01c1cbd37 100644 --- a/lib/libwrap/hosts_access.5 +++ b/lib/libwrap/hosts_access.5 @@ -1,379 +1,457 @@ -.\" $OpenBSD: hosts_access.5,v 1.2 1997/04/09 02:28:33 deraadt Exp $ -.TH HOSTS_ACCESS 5 -.SH NAME -hosts_access \- format of host access control files -.SH DESCRIPTION +.\" $OpenBSD: hosts_access.5,v 1.3 1997/06/23 11:12:40 downsj Exp $ +.\" +.\" Copyright (c) 1997, Jason Downs. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Jason Downs for the +.\" OpenBSD system. +.\" 4. Neither the name(s) of the author(s) nor the name OpenBSD +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, +.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd June 23, 1997 +.Dt HOSTS_ACCESS 5 +.Os +.Sh NAME +.Nm hosts_access +.Nd format of host access control files +.Sh DESCRIPTION This manual page describes a simple access control language that is based on client (host name/address, user name), and server (process -name, host name/address) patterns. Examples are given at the end. The +name, host name/address) patterns. Examples are given at the end. The impatient reader is encouraged to skip to the EXAMPLES section for a quick introduction. -.PP +.Pp An extended version of the access control language is described in the -\fIhosts_options\fR(5) document. The extensions are turned on at -program build time by building with -DPROCESS_OPTIONS. -.PP -In the following text, \fIdaemon\fR is the process name of a -network daemon process, and \fIclient\fR is the name and/or address of -a host requesting service. Network daemon process names are specified -in the inetd configuration file. -.SH ACCESS CONTROL FILES +.Xr hosts_options 5 +document. +.\" The extensions are turned on at +.\" program build time by building with -DPROCESS_OPTIONS. +.Pp +In the following text, +.Ar daemon +is the process name of a network daemon process, and +.Ar client +is the name and/or address of a host requesting service. Network daemon +process names are specified in the inetd configuration file. +.Sh ACCESS CONTROL FILES The access control software consults two files. The search stops at the first match: -.IP \(bu +.Bl -tag -width XXX +.It \(bu Access will be granted when a (daemon,client) pair matches an entry in -the \fI/etc/hosts.allow\fR file. -.IP \(bu +the +.Pa /etc/hosts.allow +file. +.It \(bu Otherwise, access will be denied when a (daemon,client) pair matches an -entry in the \fI/etc/hosts.deny\fR file. -.IP \(bu +entry in the +.Pa /etc/hosts.deny +file. +.It \(bu Otherwise, access will be granted. -.PP +.El +.Pp A non-existing access control file is treated as if it were an empty file. Thus, access control can be turned off by providing no access control files. -.SH ACCESS CONTROL RULES +.Sh ACCESS CONTROL RULES Each access control file consists of zero or more lines of text. These -lines are processed in order of appearance. The search terminates when a +lines are processed in order of appearance. The search terminates when a match is found. -.IP \(bu +.Bl -tag -width XXX +.It \(bu A newline character is ignored when it is preceded by a backslash character. This permits you to break up long lines so that they are easier to edit. -.IP \(bu +.It \(bu Blank lines or lines that begin with a `#\' character are ignored. This permits you to insert comments and whitespace so that the tables are easier to read. -.IP \(bu +.It \(bu All other lines should satisfy the following format, things between [] being optional: -.sp -.ti +3 +.Bd -unfilled -offset indent daemon_list : client_list [ : shell_command ] -.PP -\fIdaemon_list\fR is a list of one or more daemon process names -(argv[0] values) or wildcards (see below). -.PP -\fIclient_list\fR is a list -of one or more host names, host addresses, patterns or wildcards (see +.Ed +.El +.Pp +.Ar daemon_list +is a list of one or more daemon process names +.Pf ( Va argv[0] +values) or wildcards (see below). +.Pp +.Ar client_list +is a list of one or more host names, host addresses, patterns or wildcards (see below) that will be matched against the client host name or address. -.PP -The more complex forms \fIdaemon@host\fR and \fIuser@host\fR are +.Pp +The more complex forms +.Ar daemon@host +and +.Ar user@host +are explained in the sections on server endpoint patterns and on client username lookups, respectively. -.PP +.Pp List elements should be separated by blanks and/or commas. -.PP +.Pp With the exception of NIS (YP) netgroup lookups, all access control checks are case insensitive. -.ne 4 -.SH PATTERNS +.Sh PATTERNS The access control language implements the following patterns: -.IP \(bu +.Bl -tag -width XXX +.It \(bu A string that begins with a `.\' character. A host name is matched if the last components of its name match the specified pattern. For example, the pattern `.tue.nl\' matches the host name `wzv.win.tue.nl\'. -.IP \(bu +.It \(bu A string that ends with a `.\' character. A host address is matched if its first numeric fields match the given string. For example, the pattern `131.155.\' matches the address of (almost) every host on the Eind\%hoven University network (131.155.x.x). -.IP \(bu +.It \(bu A string that begins with an `@\' character is treated as an NIS (formerly YP) netgroup name. A host name is matched if it is a host member of the specified netgroup. Netgroup matches are not supported for daemon process names or for client user names. -.IP \(bu +.It \(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 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\'. -.SH WILDCARDS +.El +.Sh WILDCARDS The access control language supports explicit wildcards: -.IP ALL +.Bl -tag -width XXXXXXX +.It ALL The universal wildcard, always matches. -.IP LOCAL +.It LOCAL Matches any host whose name does not contain a dot character. -.IP UNKNOWN +.It UNKNOWN Matches any user whose name is unknown, and matches any host whose name -\fIor\fR address are unknown. This pattern should be used with care: +or address are unknown. This pattern should be used with care: host names may be unavailable due to temporary name server problems. A network address will be unavailable when the software cannot figure out what type of network it is talking to. -.IP KNOWN +.It KNOWN Matches any user whose name is known, and matches any host whose name -\fIand\fR address are known. This pattern should be used with care: +and address are known. This pattern should be used with care: host names may be unavailable due to temporary name server problems. A network address will be unavailable when the software cannot figure out what type of network it is talking to. -.IP PARANOID -Matches any host whose name does not match its address. When tcpd is -built with -DPARANOID (default mode), it drops requests from such -clients even before looking at the access control tables. Build -without -DPARANOID when you want more control over such requests. -.ne 6 -.SH OPERATORS +.\" .IP PARANOID +.\" Matches any host whose name does not match its address. When tcpd is +.\" built with -DPARANOID (default mode), it drops requests from such +.\" clients even before looking at the access control tables. Build +.\" without -DPARANOID when you want more control over such requests. +.Sh OPERATORS .IP EXCEPT Intended use is of the form: `list_1 EXCEPT list_2\'; this construct -matches anything that matches \fIlist_1\fR unless it matches -\fIlist_2\fR. The EXCEPT operator can be used in daemon_lists and in +matches anything that matches +.Ar list_1 +unless it matches +.Ar list_2 . +The EXCEPT operator can be used in daemon_lists and in client_lists. The EXCEPT operator can be nested: if the control language would permit the use of parentheses, `a EXCEPT b EXCEPT c\' would parse as `(a EXCEPT (b EXCEPT c))\'. -.br -.ne 6 -.SH SHELL COMMANDS +.Sh SHELL COMMANDS If the first-matched access control rule contains a shell command, that command is subjected to %<letter> substitutions (see next section). -The result is executed by a \fI/bin/sh\fR child process with standard -input, output and error connected to \fI/dev/null\fR. Specify an `&\' -at the end of the command if you do not want to wait until it has -completed. -.PP +The result is executed by a +.Pa /bin/sh +child process with standard +input, output and error connected to +.Pa /dev/null . +Specify an `&\' at the end of the command if you do not want to wait until +it has completed. +.Pp Shell commands should not rely on the PATH setting of the inetd. Instead, they should use absolute path names, or they should begin with an explicit PATH=whatever statement. -.PP -The \fIhosts_options\fR(5) document describes an alternative language +.Pp +The +.Xr hosts_options 5 +document describes an alternative language that uses the shell command field in a different and incompatible way. -.SH % EXPANSIONS +.Sh % EXPANSIONS The following expansions are available within shell commands: -.IP "%a (%A)" +.Bl -tag -width XXXXXXX +.It "%a (%A)" The client (server) host address. -.IP %c +.It %c Client information: user@host, user@address, a host name, or just an address, depending on how much information is available. -.IP %d -The daemon process name (argv[0] value). -.IP "%h (%H)" +.It %d +The daemon process name +.Pf ( Va argv[0] +value). +.It "%h (%H)" The client (server) host name or address, if the host name is unavailable. -.IP "%n (%N)" +.It "%n (%N)" The client (server) host name (or "unknown" or "paranoid"). -.IP %p +.It %p The daemon process id. -.IP %s +.It %s Server information: daemon@host, daemon@address, or just a daemon name, depending on how much information is available. -.IP %u +.It %u The client user name (or "unknown"). -.IP %% +.It %% Expands to a single `%\' character. -.PP +.El +.Pp Characters in % expansions that may confuse the shell are replaced by underscores. -.SH SERVER ENDPOINT PATTERNS +.Sh SERVER ENDPOINT PATTERNS In order to distinguish clients by the network address that they connect to, use patterns of the form: -.sp -.ti +3 +.Bd -unfilled -offset indent process_name@host_pattern : client_list ... -.sp +.Ed +.Pp Patterns like these can be used when the machine has different internet addresses with different internet hostnames. Service providers can use this facility to offer FTP, GOPHER or WWW archives with internet names that may even belong to different organizations. See also the `twist' -option in the hosts_options(5) document. Some systems (Solaris, -FreeBSD) can have more than one internet address on one physical +option in the +.Xr hosts_options 5 +document. Many systems can have more than one internet address on one physical interface; with other systems you may have to resort to SLIP or PPP pseudo interfaces that live in a dedicated network address space. -.sp +.Pp The host_pattern obeys the same syntax rules as host names and addresses in client_list context. Usually, server endpoint information is available only with connection-oriented services. -.SH CLIENT USERNAME LOOKUP +.Sh CLIENT USERNAME LOOKUP When the client host supports the RFC 931 protocol or one of its descendants (TAP, IDENT, RFC 1413) the wrapper programs can retrieve additional information about the owner of a connection. Client username information, when available, is logged together with the client host name, and can be used to match patterns like: -.PP -.ti +3 +.Pp +.Bd -unfilled -offset indent daemon_list : ... user_pattern@host_pattern ... -.PP +.Ed +.Pp The daemon wrappers can be configured at compile time to perform rule-driven username lookups (default) or to always interrogate the client host. In the case of rule-driven username lookups, the above -rule would cause username lookup only when both the \fIdaemon_list\fR -and the \fIhost_pattern\fR match. -.PP +rule would cause username lookup only when both the +.Ar daemon_list +and the +.Ar host_pattern +match. +.Pp A user pattern has the same syntax as a daemon process pattern, so the same wildcards apply (netgroup membership is not supported). One should not get carried away with username lookups, though. -.IP \(bu +.Bl -tag -width XXX +.It \(bu The client username information cannot be trusted when it is needed most, i.e. when the client system has been compromised. In general, ALL and (UN)KNOWN are the only user name patterns that make sense. -.IP \(bu +.It \(bu Username lookups are possible only with TCP-based services, and only when the client host runs a suitable daemon; in all other cases the result is "unknown". -.IP \(bu -A well-known UNIX kernel bug may cause loss of service when username -lookups are blocked by a firewall. The wrapper README document -describes a procedure to find out if your kernel has this bug. -.IP \(bu +.\" .It \(bu +.\" A well-known UNIX kernel bug may cause loss of service when username +.\" lookups are blocked by a firewall. The wrapper README document +.\" describes a procedure to find out if your kernel has this bug. +.It \(bu Username lookups may cause noticeable delays for non-UNIX users. The default timeout for username lookups is 10 seconds: too short to cope with slow networks, but long enough to irritate PC users. -.PP +.El +.Pp Selective username lookups can alleviate the last problem. For example, a rule like: -.PP -.ti +3 +.Pp +.Bd -unfilled -offset indent daemon_list : @pcnetgroup ALL@ALL -.PP +.Ed +.Pp would match members of the pc netgroup without doing username lookups, but would perform username lookups with all other systems. -.SH DETECTING ADDRESS SPOOFING ATTACKS +.Sh DETECTING ADDRESS SPOOFING ATTACKS A flaw in the sequence number generator of many TCP/IP implementations allows intruders to easily impersonate trusted hosts and to break in via, for example, the remote shell service. The IDENT (RFC931 etc.) service can be used to detect such and other host address spoofing attacks. -.PP +.Pp Before accepting a client request, the wrappers can use the IDENT service to find out that the client did not send the request at all. When the client host provides IDENT service, a negative IDENT lookup result (the client matches `UNKNOWN@host') is strong evidence of a host spoofing attack. -.PP +.Pp A positive IDENT lookup result (the client matches `KNOWN@host') is less trustworthy. It is possible for an intruder to spoof both the client connection and the IDENT lookup, although doing so is much harder than spoofing just a client connection. It may also be that the client\'s IDENT server is lying. -.PP +.Pp Note: IDENT lookups don\'t work with UDP services. -.SH EXAMPLES +.Sh EXAMPLES The language is flexible enough that different types of access control policy can be expressed with a minimum of fuss. Although the language uses two access control tables, the most common policies can be implemented with one of the tables being trivial or even empty. -.PP +.Pp When reading the examples below it is important to realize that the allow table is scanned before the deny table, that the search terminates when a match is found, and that access is granted when no match is found at all. -.PP +.Pp The examples use host and domain names. They can be improved by including address and/or network/netmask information, to reduce the impact of temporary name server lookup failures. -.SH MOSTLY CLOSED +.Sh MOSTLY CLOSED In this case, access is denied by default. Only explicitly authorized hosts are permitted access. -.PP +.Pp The default policy (no access) is implemented with a trivial deny file: -.PP -.ne 2 +.Pp +.Bd -unfilled -offset indent /etc/hosts.deny: -.in +3 +.Bd -unfilled -offset indent 2 ALL: ALL -.PP +.Ed +.Ed +.Pp This denies all service to all hosts, unless they are permitted access by entries in the allow file. -.PP +.Pp The explicitly authorized hosts are listed in the allow file. For example: -.PP -.ne 2 +.Pp +.Bd -unfilled -offset indent /etc/hosts.allow: -.in +3 +.Bd -unfilled -offset indent 2 ALL: LOCAL @some_netgroup -.br ALL: .foobar.edu EXCEPT terminalserver.foobar.edu -.PP +.Ed +.Ed +.Pp The first rule permits access from hosts in the local domain (no `.\' -in the host name) and from members of the \fIsome_netgroup\fP +in the host name) and from members of the +.Ar some_netgroup netgroup. The second rule permits access from all hosts in the -\fIfoobar.edu\fP domain (notice the leading dot), with the exception of -\fIterminalserver.foobar.edu\fP. -.SH MOSTLY OPEN +.Ar foobar.edu +domain (notice the leading dot), with the exception of +.Ar terminalserver.foobar.edu . +.Sh MOSTLY OPEN Here, access is granted by default; only explicitly specified hosts are refused service. -.PP +.Pp The default policy (access granted) makes the allow file redundant so that it can be omitted. The explicitly non-authorized hosts are listed in the deny file. For example: -.PP +.Pp +.Bd -unfilled -offset indent /etc/hosts.deny: -.in +3 +.Bd -unfilled -offset indent 2 ALL: some.host.name, .some.domain -.br ALL EXCEPT in.fingerd: other.host.name, .other.domain -.PP +.Ed +.Ed +.Pp The first rule denies some hosts and domains all services; the second rule still permits finger requests from other hosts and domains. -.SH BOOBY TRAPS +.Sh BOOBY TRAPS The next example permits tftp requests from hosts in the local domain (notice the leading dot). Requests from any other hosts are denied. Instead of the requested file, a finger probe is sent to the offending host. The result is mailed to the superuser. -.PP -.ne 2 +.Pp +.Bd -unfilled -offset indent /etc/hosts.allow: -.in +3 -.nf -in.tftpd: LOCAL, .my.domain -.PP -.ne 2 +.Bd -unfilled -offset indent 2 +tftpd: LOCAL, .my.domain +.Ed +.Ed +.Pp +.Bd -unfilled -offset indent /etc/hosts.deny: -.in +3 -.nf -in.tftpd: ALL: (/some/where/safe_finger -l @%h | \\ - /usr/ucb/mail -s %d-%h root) & -.fi -.PP -The safe_finger command comes with the tcpd wrapper and should be +.Bd -unfilled -offset indent 2 +tftpd: ALL: (/some/where/safe_finger -l @%h | \\ + /usr/bin/mail -s %d-%h root) & +.Ed +.Ed +.Pp +The +.Nm safe_finger +command comes with the tcpd wrapper and should be installed in a suitable place. It limits possible damage from data sent by the remote finger server. It gives better protection than the standard finger command. -.PP +.Pp The expansion of the %h (client host) and %d (service name) sequences is described in the section on shell commands. -.PP +.Pp Warning: do not booby-trap your finger daemon, unless you are prepared for infinite finger loops. -.PP +.Pp On network firewall systems this trick can be carried even further. The typical network firewall only provides a limited set of services to the outer world. All other services can be "bugged" just like the above tftp example. The result is an excellent early-warning system. -.br -.ne 4 -.SH DIAGNOSTICS +.Sh DIAGNOSTICS An error is reported when a syntax error is found in a host access control rule; when the length of an access control rule exceeds the capacity of an internal buffer; when an access control rule is not terminated by a newline character; when the result of %<letter> expansion would overflow an internal buffer; when a system call fails that shouldn\'t. All problems are reported via the syslog daemon. -.SH FILES -.na -.nf -/etc/hosts.allow, (daemon,client) pairs that are granted access. -/etc/hosts.deny, (daemon,client) pairs that are denied access. -.ad -.fi -.SH SEE ALSO -.nf -tcpd(8) tcp/ip daemon wrapper program. -tcpdchk(8), tcpdmatch(8), test programs. -.SH BUGS +.Sh FILES +.Bl -tag -width /etc/hosts.allow -compact +.It Pa /etc/hosts.allow +Access control table (allow list) +.It Pa /etc/hosts.deny +Access control table (deny list) +.Sh SEE ALSO +.Xr tcpd 8 , +.Xr tcpdchk 8 , +.Xr tcpdmatch 8 . +.Sh BUGS If a name server lookup times out, the host name will not be available to the access control software, even though the host is registered. -.PP +.Pp Domain name server lookups are case insensitive; NIS (formerly YP) netgroup lookups are case sensitive. -.SH AUTHOR -.na -.nf +.Sh AUTHOR +.Bd -unfilled -offset indent Wietse Venema (wietse@wzv.win.tue.nl) Department of Mathematics and Computing Science Eindhoven University of Technology Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands +.Ed \" @(#) hosts_access.5 1.20 95/01/30 19:51:46 diff --git a/lib/libwrap/hosts_options.5 b/lib/libwrap/hosts_options.5 index 0a727c9e76e..0bd7e6f7973 100644 --- a/lib/libwrap/hosts_options.5 +++ b/lib/libwrap/hosts_options.5 @@ -1,121 +1,172 @@ -.\" $OpenBSD: hosts_options.5,v 1.1 1997/02/26 03:06:53 downsj Exp $ -.TH HOSTS_OPTIONS 5 -.SH NAME -hosts_options \- host access control language extensions -.SH DESCRIPTION +.\" $OpenBSD: hosts_options.5,v 1.2 1997/06/23 11:12:41 downsj Exp $ +.\" +.\" Copyright (c) 1997, Jason Downs. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Jason Downs for the +.\" OpenBSD system. +.\" 4. Neither the name(s) of the author(s) nor the name OpenBSD +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, +.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd June 23, 1997 +.Dt HOSTS_OPTIONS 5 +.Os +.Sh NAME +.Nm hosts_options +.Nd host access control language extensions +.Sh DESCRIPTION This document describes optional extensions to the language described -in the hosts_access(5) document. The extensions are enabled at program -build time. For example, by editing the Makefile and turning on the -PROCESS_OPTIONS compile-time option. -.PP +in the +.Xr hosts_access 5 +document. +.\" The extensions are enabled at program build time. +.\" For example, by editing the Makefile and turning on the +.\" PROCESS_OPTIONS compile-time option. +.Pp The extensible language uses the following format: -.sp -.ti +3 +.Bd -unfilled -offset indent daemon_list : client_list : option : option ... -.PP -The first two fields are described in the hosts_access(5) manual page. +.Ed +.Pp +The first two fields are described in the +.Xr hosts_access 5 +manual page. The remainder of the rules is a list of zero or more options. Any ":" characters within options should be protected with a backslash. -.PP +.Pp An option is of the form "keyword" or "keyword value". Options are processed in the specified order. Some options are subjected to %<letter> substitutions. For the sake of backwards compatibility with earlier versions, an "=" is permitted between keyword and value. -.SH LOGGING -.IP "severity mail.info" -.IP "severity notice" +.Sh LOGGING +.Bl -tag -width "severity mail.info" +.It "severity mail.info" +.It "severity notice" Change the severity level at which the event will be logged. Facility names (such as mail) are optional, and are not supported on systems with older syslog implementations. The severity option can be used to emphasize or to ignore specific events. -.SH ACCESS CONTROL -.IP "allow" -.IP "deny" +.El +.Sh ACCESS CONTROL +.Bl -tag -width allow +.It "allow" +.It "deny" Grant (deny) service. These options must appear at the end of a rule. -.PP -The \fIallow\fR and \fIdeny\fR keywords make it possible to keep all +.El +.Pp +The +.Ar allow +and +.Ar deny +keywords make it possible to keep all access control rules within a single file, for example in the -\fIhosts.allow\fR file. -.sp +.Pa /etc/hosts.allow +file. +.Pp To permit access from specific hosts only: -.sp -.ne 2 -.ti +3 +.Pp +.Bd -unfilled -offset indent ALL: .friendly.domain: ALLOW -.ti +3 ALL: ALL: DENY -.sp +.Ed +.Pp To permit access from all hosts except a few trouble makers: -.sp -.ne 2 -.ti +3 +.Pp +.Bd -unfilled -offset indent ALL: .bad.domain: DENY -.ti +3 ALL: ALL: ALLOW -.sp +.Ed +.Pp Notice the leading dot on the domain name patterns. -.SH RUNNING OTHER COMMANDS -.IP "spawn shell_command" +.Sh RUNNING OTHER COMMANDS +.Bl -tag -width "spawn shell_command" +.It "spawn shell_command" 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 conversation with the client host. Example: -.sp -.nf -.ti +3 +.Bd -unfilled -offset indent spawn (/some/where/safe_finger -l @%h | /usr/ucb/mail root) & -.fi -.sp +.Ed +.Pp executes, in a background child process, the shell command "safe_finger -l @%h | mail root" after replacing %h by the name or address of the remote host. -.sp +.Pp The example uses the "safe_finger" command instead of the regular "finger" command, to limit possible damage from data sent by the finger server. The "safe_finger" command is part of the daemon wrapper package; it is a wrapper around the regular finger command that filters the data sent by the remote host. -.IP "twist shell_command" +.It "twist shell_command" Replace the current process by an instance of the specified shell command, after performing the %<letter> expansions described in the -hosts_access(5) manual page. Stdin, stdout and stderr are connected to +.Xr hosts_access 5 +manual page. Stdin, stdout and stderr are connected to the client process. This option must appear at the end of a rule. -.sp +.Pp To send a customized bounce message to the client instead of running the real ftp daemon: -.sp -.nf -.ti +3 -in.ftpd : ... : twist /bin/echo 421 Some bounce message -.fi -.sp +.Bd -unfilled -offset indent +ftpd : ... : twist /bin/echo 421 Some bounce message +.Ed +.Pp For an alternative way to talk to client processes, see the -\fIbanners\fR option below. -.sp -To run /some/other/in.telnetd without polluting its command-line +.Ar banners +option below. +.Pp +To run /some/other/telnetd without polluting its command-line array or its process environment: -.sp -.nf -.ti +3 -in.telnetd : ... : twist PATH=/some/other; exec in.telnetd -.fi -.sp +.Bd -unfilled -offset indent +telnetd : ... : twist PATH=/some/other; exec in.telnetd +.Ed +.Pp Warning: in case of UDP services, do not twist to commands that use -the standard I/O or the read(2)/write(2) routines to communicate with +the standard I/O or the +.Xr read 2 +or +.Xr write 2 +routines to communicate with the client process; UDP requires other I/O primitives. -.SH NETWORK OPTIONS -.IP "keepalive" +.El +.Sh NETWORK OPTIONS +.Bl -tag -width "linger number_of_seconds" +.It "keepalive" Causes the server to periodically send a message to the client. The connection is considered broken when the client does not respond. The keepalive option can be useful when users turn off their machine while it is still connected to a server. The keepalive option is not useful for datagram (UDP) services. -.IP "linger number_of_seconds" +.It "linger number_of_seconds" Specifies how long the kernel will try to deliver not-yet delivered data after the server process closes a connection. -.SH USERNAME LOOKUP -.IP "rfc931 [ timeout_in_seconds ]" +.El +.Sh USERNAME LOOKUP +.Bl -tag -width "rfc931 [ timeout_in_seconds ]" +.It "rfc931 [ timeout_in_seconds ]" Look up the client user name with the RFC 931 (TAP, IDENT, RFC 1413) protocol. This option is silently ignored in case of services based on transports other than TCP. It requires that the client system runs an @@ -123,51 +174,58 @@ RFC 931 (IDENT, etc.) -compliant daemon, and may cause noticeable delays with connections from non-UNIX clients. The timeout period is optional. If no timeout is specified a compile-time defined default value is taken. -.SH MISCELLANEOUS -.IP "banners /some/directory" -Look for a file in `/some/directory' with the same name as the daemon -process (for example in.telnetd for the telnet service), and copy its -contents to the client. Newline characters are replaced by -carriage-return newline, and %<letter> sequences are expanded (see -the hosts_access(5) manual page). -.sp -The tcp wrappers source code distribution provides a sample makefile -(Banners.Makefile) for convenient banner maintenance. -.sp +.El +.Sh MISCELLANEOUS +.Bl -tag -width "banners /some/directory" +.It "banners /some/directory" +Look for a file in +.Pa /some/directory +with the same name as the daemon process (for example +.Nm telnetd +for the telnet service), and copy its contents to the client. +Newline characters are replaced by carriage-return newline, and %<letter> +sequences are expanded (see the +.Xr hosts_access 5 +manual page). +.Pp +.\" The tcp wrappers source code distribution provides a sample makefile +.\" (Banners.Makefile) for convenient banner maintenance. +.\" .Pp Warning: banners are supported for connection-oriented (TCP) network services only. -.IP "nice [ number ]" +.It "nice [ number ]" Change the nice value of the process (default 10). Specify a positive value to spend more CPU resources on other processes. -.IP "setenv name value" +.It "setenv name value" Place a (name, value) pair into the process environment. The value is subjected to %<letter> expansions and may contain whitespace (but leading and trailing blanks are stripped off). -.sp +.Pp Warning: many network daemons reset their environment before spawning a login or shell process. -.IP "umask 022" +.It "umask 022" Like the umask command that is built into the shell. An umask of 022 prevents the creation of files with group and world write permission. The umask argument should be an octal number. -.IP "user nobody" -.IP "user nobody.kmem" +.It "user nobody" +.It "user nobody.kmem" Assume the privileges of the "nobody" userid (or user "nobody", group "kmem"). The first form is useful with inetd implementations that run all services with root privilege. The second form is useful for services that need special group privileges only. -.SH DIAGNOSTICS +.El +.Sh DIAGNOSTICS When a syntax error is found in an access control rule, the error is reported to the syslog daemon; further options will be ignored, and service is denied. -.SH SEE ALSO -hosts_access(5), the default access control language -.SH AUTHOR -.na -.nf +.Sh SEE ALSO +.Xr hosts_access 5 . +.Sh AUTHOR +.Bd -unfilled -indent Wietse Venema (wietse@wzv.win.tue.nl) Department of Mathematics and Computing Science Eindhoven University of Technology Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands +.Ed \" @(#) hosts_options.5 1.10 94/12/28 17:42:28 |