⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hosts_access.5

📁 基于TCP-WRAP原理的系统监控的c语言实现代码
💻 5
字号:
.TH HOSTS_ACCESS 5.SH NAMEhosts_access \- format of host access control files.SH DESCRIPTIONThis manual page describes a simple access control language that isbased on client (host name/address, user name), and server (processname, host name/address) patterns.  Examples are given at the end. Theimpatient reader is encouraged to skip to the EXAMPLES section for aquick introduction..PPAn extended version of the access control language is described in the\fIhosts_options\fR(5) document. The extensions are turned on atprogram build time by building with -DPROCESS_OPTIONS..PPIn the following text, \fIdaemon\fR is the the process name of anetwork daemon process, and \fIclient\fR is the name and/or address ofa host requesting service. Network daemon process names are specifiedin the inetd configuration file..SH ACCESS CONTROL FILESThe access control software consults two files. The search stopsat the first match:.IP \(buAccess will be granted when a (daemon,client) pair matches an entry inthe \fI/etc/hosts.allow\fR file..IP \(buOtherwise, access will be denied when a (daemon,client) pair matches anentry in the \fI/etc/hosts.deny\fR file..IP \(buOtherwise, access will be granted..PPA non-existing access control file is treated as if it were an emptyfile. Thus, access control can be turned off by providing no accesscontrol files..SH ACCESS CONTROL RULESEach access control file consists of zero or more lines of text.  Theselines are processed in order of appearance. The search terminates when amatch is found..IP \(buA newline character is ignored when it is preceded by a backslashcharacter. This permits you to break up long lines so that they areeasier to edit..IP \(buBlank lines or lines that begin with a `#\' character are ignored.This permits you to insert comments and whitespace so that the tablesare easier to read..IP \(buAll other lines should satisfy the following format, things between []being optional:.sp.ti +3daemon_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 listof one or more host names, host addresses, patterns or wildcards (seebelow) that will be matched against the client host name or address..PPThe more complex forms \fIdaemon@host\fR and \fIuser@host\fR areexplained in the sections on server endpoint patterns and on clientusername lookups, respectively..PPList elements should be separated by blanks and/or commas.  .PPWith the exception of NIS (YP) netgroup lookups, all access controlchecks are case insensitive..ne 4.SH PATTERNSThe access control language implements the following patterns:.IP \(buA string that begins with a `.\' character. A host name is matched ifthe last components of its name match the specified pattern.  Forexample, the pattern `.tue.nl\' matches the host name`wzv.win.tue.nl\'..IP \(buA string that ends with a `.\' character. A host address is matched ifits first numeric fields match the given string.  For example, thepattern `131.155.\' matches the address of (almost) every host on theEind\%hoven University network (131.155.x.x)..IP \(buA string that begins with an `@\' character is treated as an NIS(formerly YP) netgroup name. A host name is matched if it is a hostmember of the specified netgroup. Netgroup matches are not supportedfor daemon process names or for client user names..IP \(buAn 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 thebitwise AND of the address and the `mask\'. For example, the net/maskpattern `131.155.72.0/255.255.254.0\' matches every address in therange `131.155.72.0\' through `131.155.73.255\'..SH WILDCARDSThe access control language supports explicit wildcards:.IP ALLThe universal wildcard, always matches..IP LOCALMatches any host whose name does not contain a dot character..IP UNKNOWNMatches any user whose name is unknown, and matches any host whose name\fIor\fR address are unknown.  This pattern should be used with care:host names may be unavailable due to temporary name server problems. Anetwork address will be unavailable when the software cannot figure outwhat type of network it is talking to..IP KNOWNMatches any user whose name is known, and matches any host whose name\fIand\fR address are known. This pattern should be used with care:host names may be unavailable due to temporary name server problems.  Anetwork address will be unavailable when the software cannot figure outwhat type of network it is talking to..IP PARANOIDMatches any host whose name does not match its address.  When tcpd isbuilt with -DPARANOID (default mode), it drops requests from suchclients even before looking at the access control tables.  Buildwithout -DPARANOID when you want more control over such requests..ne 6.SH OPERATORS.IP EXCEPTIntended use is of the form: `list_1 EXCEPT list_2\'; this constructmatches anything that matches \fIlist_1\fR unless it matches\fIlist_2\fR.  The EXCEPT operator can be used in daemon_lists and inclient_lists. The EXCEPT operator can be nested: if the controllanguage would permit the use of parentheses, `a EXCEPT b EXCEPT c\'would parse as `(a EXCEPT (b EXCEPT c))\'..br.ne 6.SH SHELL COMMANDSIf the first-matched access control rule contains a shell command, thatcommand is subjected to %<letter> substitutions (see next section).The result is executed by a \fI/bin/sh\fR child process with standardinput, 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 hascompleted..PPShell commands should not rely on the PATH setting of the inetd.Instead, they should use absolute path names, or they should begin withan explicit PATH=whatever statement..PPThe \fIhosts_options\fR(5) document describes an alternative languagethat uses the shell command field in a different and incompatible way..SH % EXPANSIONSThe following expansions are available within shell commands:.IP "%a (%A)"The client (server) host address..IP %cClient information: user@host, user@address, a host name, or just anaddress, depending on how much information is available..IP %dThe daemon process name (argv[0] value)..IP "%h (%H)"The client (server) host name or address, if the host name isunavailable..IP "%n (%N)"The client (server) host name (or "unknown" or "paranoid")..IP %pThe daemon process id..IP %sServer information: daemon@host, daemon@address, or just a daemon name,depending on how much information is available..IP %uThe client user name (or "unknown")..IP %%Expands to a single `%\' character..PPCharacters in % expansions that may confuse the shell are replaced byunderscores..SH SERVER ENDPOINT PATTERNSIn order to distinguish clients by the network address that theyconnect to, use patterns of the form:.sp.ti +3process_name@host_pattern : client_list ....spPatterns like these can be used when the machine has different internetaddresses with different internet hostnames.  Service providers can usethis facility to offer FTP, GOPHER or WWW archives with internet namesthat 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 physicalinterface; with other systems you may have to resort to SLIP or PPPpseudo interfaces that live in a dedicated network address space..spThe host_pattern obeys the same syntax rules as host names andaddresses in client_list context. Usually, server endpoint informationis available only with connection-oriented services..SH CLIENT USERNAME LOOKUPWhen the client host supports the RFC 931 protocol or one of itsdescendants (TAP, IDENT, RFC 1413) the wrapper programs can retrieveadditional information about the owner of a connection. Client usernameinformation, when available, is logged together with the client hostname, and can be used to match patterns like:.PP.ti +3daemon_list : ... user_pattern@host_pattern ....PPThe daemon wrappers can be configured at compile time to performrule-driven username lookups (default) or to always interrogate theclient host.  In the case of rule-driven username lookups, the aboverule would cause username lookup only when both the \fIdaemon_list\fRand the \fIhost_pattern\fR match. .PPA user pattern has the same syntax as a daemon process pattern, so thesame wildcards apply (netgroup membership is not supported).  Oneshould not get carried away with username lookups, though..IP \(buThe client username information cannot be trusted when it is neededmost, 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 \(buUsername lookups are possible only with TCP-based services, and onlywhen the client host runs a suitable daemon; in all other cases theresult is "unknown"..IP \(buA well-known UNIX kernel bug may cause loss of service when usernamelookups are blocked by a firewall. The wrapper README documentdescribes a procedure to find out if your kernel has this bug..IP \(buUsername lookups may cause noticeable delays for non-UNIX users.  Thedefault timeout for username lookups is 10 seconds: too short to copewith slow networks, but long enough to irritate PC users..PPSelective username lookups can alleviate the last problem. For example,a rule like:.PP.ti +3daemon_list : @pcnetgroup ALL@ALL.PPwould match members of the pc netgroup without doing username lookups,but would perform username lookups with all other systems..SH DETECTING ADDRESS SPOOFING ATTACKSA flaw in the sequence number generator of many TCP/IP implementationsallows intruders to easily impersonate trusted hosts and to break invia, for example, the remote shell service.  The IDENT (RFC931 etc.)service can be used to detect such and other host address spoofingattacks..PPBefore accepting a client request, the wrappers can use the IDENTservice to find out that the client did not send the request at all.When the client host provides IDENT service, a negative IDENT lookupresult (the client matches `UNKNOWN@host') is strong evidence of a hostspoofing attack..PPA positive IDENT lookup result (the client matches `KNOWN@host') isless trustworthy. It is possible for an intruder to spoof both theclient connection and the IDENT lookup, although doing so is muchharder than spoofing just a client connection. It may also be thatthe client\'s IDENT server is lying..PPNote: IDENT lookups don\'t work with UDP services. .SH EXAMPLESThe language is flexible enough that different types of access controlpolicy can be expressed with a minimum of fuss. Although the languageuses two access control tables, the most common policies can beimplemented with one of the tables being trivial or even empty..PPWhen reading the examples below it is important to realize that theallow table is scanned before the deny table, that the searchterminates when a match is found, and that access is granted when nomatch is found at all..PPThe examples use host and domain names. They can be improved byincluding address and/or network/netmask information, to reduce theimpact of temporary name server lookup failures..SH MOSTLY CLOSEDIn this case, access is denied by default. Only explicitly authorizedhosts are permitted access. .PPThe default policy (no access) is implemented with a trivial denyfile:.PP.ne 2/etc/hosts.deny: .in +3ALL: ALL.PPThis denies all service to all hosts, unless they are permitted accessby entries in the allow file..PPThe explicitly authorized hosts are listed in the allow file.For example:.PP.ne 2/etc/hosts.allow: .in +3ALL: LOCAL @some_netgroup.brALL: .foobar.edu EXCEPT terminalserver.foobar.edu.PPThe first rule permits access from hosts in the local domain (no `.\'in the host name) and from members of the \fIsome_netgroup\fPnetgroup.  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 OPENHere, access is granted by default; only explicitly specified hosts arerefused service. .PPThe default policy (access granted) makes the allow file redundant sothat it can be omitted.  The explicitly non-authorized hosts are listedin the deny file. For example:.PP/etc/hosts.deny:.in +3ALL: some.host.name, .some.domain.brALL EXCEPT in.fingerd: other.host.name, .other.domain.PPThe first rule denies some hosts and domains all services; the secondrule still permits finger requests from other hosts and domains..SH BOOBY TRAPSThe 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 offendinghost. The result is mailed to the superuser..PP.ne 2/etc/hosts.allow:.in +3.nfin.tftpd: LOCAL, .my.domain.PP.ne 2/etc/hosts.deny:.in +3.nfin.tftpd: ALL: (/some/where/safe_finger -l @%h | \\	/usr/ucb/mail -s %d-%h root) &.fi.PPThe safe_finger command comes with the tcpd wrapper and should beinstalled in a suitable place. It limits possible damage from data sentby the remote finger server.  It gives better protection than thestandard finger command..PPThe expansion of the %h (client host) and %d (service name) sequencesis described in the section on shell commands..PPWarning: do not booby-trap your finger daemon, unless you are preparedfor infinite finger loops..PPOn network firewall systems this trick can be carried even further.The typical network firewall only provides a limited set of services tothe outer world. All other services can be "bugged" just like the abovetftp example. The result is an excellent early-warning system..br.ne 4.SH DIAGNOSTICSAn error is reported when a syntax error is found in a host accesscontrol rule; when the length of an access control rule exceeds thecapacity of an internal buffer; when an access control rule is notterminated by a newline character; when the result of %<letter>expansion would overflow an internal buffer; when a system call failsthat 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.nftcpd(8) tcp/ip daemon wrapper program.tcpdchk(8), tcpdmatch(8), test programs..SH BUGSIf a name server lookup times out, the host name will not be availableto the access control software, even though the host is registered..PPDomain name server lookups are case insensitive; NIS (formerly YP)netgroup lookups are case sensitive..SH AUTHOR.na.nfWietse Venema (wietse@wzv.win.tue.nl)Department of Mathematics and Computing ScienceEindhoven University of TechnologyDen Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands\" @(#) hosts_access.5 1.20 95/01/30 19:51:46

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -