18.12.2012 Views

O'Reilly - Practical UNIX & Internet Sec... 7015KB

O'Reilly - Practical UNIX & Internet Sec... 7015KB

O'Reilly - Practical UNIX & Internet Sec... 7015KB

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

22.3.5 Advanced tcpwrapper Options<br />

Instead of specifying a particular shell command that should be executed when a (daemon, host) line is matched, tcpwrapper allows<br />

you to specify a rich set of options. To use options, you compile the tcpwrapper program with the option -DPROCESS_OPTIONS. If<br />

you compile with -DPROCESS_OPTIONS, you must change the files /etc/hosts.allow and /etc/hosts.deny files to reflect that change;<br />

the format of these files when tcpwrapper is compiled with -DPROCESS_OPTIONS is incompatible with the format of the files<br />

when tcpwrapper is compiled without the options.<br />

If you do compile with -DPROCESS_OPTIONS, the new format of the /etc/hosts.allow and /etc/hosts.deny becomes:<br />

daemon_list : client_host_list : option : option ...<br />

Because you may have more than one option on a line, if you need to place a colon (:) within the option, you must protect it with a<br />

backslash (\).<br />

The options allow you considerable flexibility in handling a variety of conditions. They also somewhat obsolete the need to have<br />

separate /etc/hosts.allow and /etc/hosts.deny files, as the words "allow" and "deny" are now option keywords (making it possible to<br />

deny a specific pair (daemon, client) in the /etc/hosts.allow file, or vice versa). Although you should check tcpwrapper's<br />

documentation for a current list of options, most of them are included in Table 22.3<br />

Table 22.3: Advanced Options for tcpwrapper When Compiled with -DPROCESS_OPTIONS<br />

Option Effect<br />

allow Allows the connection.<br />

deny Denies the connection.<br />

Options for dealing with sub-shells:<br />

nice nn Changes the priority of the process to nn. Use numbers such as +4 or +8 to reduce the amount of CPU<br />

time allocated to network services.<br />

setenv name value Sets the environment variable name to value for the daemon.<br />

spawn shell_command Runs the shell_command. The streams stdin, stdout, and stderr are connected to /dev/null to avoid<br />

conflict with any communications with the client.<br />

twist shell_command Runs the shell_command. The streams stdin, stdout, and stderr are connected to the remote client. This<br />

allows you to run a server process other than the one specified in the file /etc/inetd.conf. (Note: Will not<br />

work with some UDP services.)<br />

umask nnn Specifies the umask that should be used for sub-shells. Specify it in octal.<br />

user username Assume the privileges of username. (Note: tcpwrapper must be running as root for this option to work.)<br />

user username.groupname Assume the privileges of username and set the current group to be groupname.<br />

Options for dealing with the network connection:<br />

banners /some/directory/ Specifies a directory that contains banner files. If a filename is found in the banner directory that has the<br />

same name as the network server (such as telnetd), the contents of the banner file are sent to the client<br />

before the TCP connection is turned over to the server. This process allows you to send clients messages,<br />

for example, informing them that unauthorized use of your computer is prohibited.<br />

keepalive Causes the <strong>UNIX</strong> kernel to periodically send a message to a client process; if the message cannot be<br />

sent, the connection is automatically broken.<br />

linger seconds Specifies how long the <strong>UNIX</strong> kernel should spend trying to send a message to the remote client after the<br />

server closes the connection.<br />

rfc931 [timeout in seconds] Specifies that the ident protocol should be used to attempt to determine the username of the person<br />

running the client program on the remote computer. The timeout, if specified, is the number of seconds<br />

that tcpwrapper should spend waiting for this information.<br />

.<br />

[Chapter 22] 22.3 tcpwrapper<br />

Don't be afraid of using these so-called "advanced" options: they actually allow you to have simpler configurations than the<br />

/etc/hosts.allow and /etc/hosts.deny files.<br />

NOTE: The following examples use DNS hostnames for clarity. For added security, use IP addresses instead.<br />

Suppose you wish to allow all connections to your computer, except those from the computers in the domain pirate.net, with this<br />

very simple /etc/hosts.allow file; specify:<br />

file:///C|/Oreilly Unix etc/<strong>O'Reilly</strong> Reference Library/networking/puis/ch22_03.htm (5 of 9) [2002-04-12 10:45:59]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!