HostedDB - Dedicated UNIX Servers

-->
Internet Security Professional Reference:How to Build a Firewall
Previous Table of Contents Next


Description

The smap client implements a minimal version of SMTP, accepting messages from over the network and writing them to disk for future delivery by smapd. smap is designed to run under chroot(2) as a non-privileged process. This arrangement overcomes potential security risks presented by privileged mailers running where they can be accessed from over a network.

smap is invoked from inetd and exits when its session is completed. Each session’s mail is recorded in a temporary file in its spool directory, with the SMTP envelope encoded in the heading of the file. To coordinate processing with smapd the file is locked while it is being written. As a secondary means of signaling when a message is completely gathered, the mode of the file, which is initially 644, is changed to 755. In this manner the system can identify truncated or partial files left after a system crash or reboot.

Options

smap takes no command-line options. All configuration rules in netperm-table for application “smap” are read, and the following clauses and parameters are recognized:

userid name

The userid option specifies the userid that smap should run under. The name can be either a name from the password database, or a numeric user-ID. This userid should be the same as the ID under which smapd runs, and should have write permission to the spool directory.

directory pathname

The directory option specifies the spool directory where smap should store incoming messages. A chroot(2) system call is used to irrevocably make the specified directory the root file system for the remainder of the process.

maxbytes value

maxbytes specifies the maximum size of messages to gather, in bytes. If no value is set, message sizes are limited by the amount of disk space in the spool area.

maxrecip value

The maxrecip option specifies the maximum number of recipients allowed for any message. This option is only for administrators who are worried about the more esoteric denial of service attacks.

timeout value

This option specifies a timeout, after which smap should exit if it has not collected a message. If no timeout value is specified, smap will never time out a connection.

Installation

To install smap, locate the spool directory where mail will be collected. Identify the userid that smap will run as (generally daemon), and make sure that it owns the spool directory. Install smap in /etc/inetd.conf as follows (path names may change):

smtp stream tcp nowait root /usr/local/etc/smap smap

After modifying /etc/inetd.conf you need to signal inetd to reload its configuration information; you also need to make sure that sendmail is no longer running on the system.

In the spool directory, it may be necessary to make an /etc directory with system-specific configuration files if the C support library on the host Unix requires them. Usually, the best recommendation is to build smap so that it is completely standalone; that is, a statically-linked executable that is linked to a resolver library that will not crash if it is unable to read /etc/resolv.conf. A small number of support files (/etc/hosts, /etc/resolv.conf ) may be required. Be careful not to install any device files or executables in the spool directory. Test installation by using telnet to connect to the SMTP port.


Note:  smap assumes that smapd will also be running on the system.

smapd—Sendmail Wrapper Daemon

Synopsis

smapd (invoked from rc.local)

Description

The smapd daemon periodically scans the mail spool area maintained by smap and delivers any messages that have been gathered and stored. Mail is delivered via sendmail and the spool file is deleted. If the mail cannot be delivered normally, smapd can be configured to store spooled files to an area for later examination.

Options

smapd takes no command-line options, and reads its configuration information from the firewall Toolkit configuration file netperm-table. All configuration rules in netperm-table for application “smapd” are read, and the following clauses and parameters are recognized:

executable pathname

The executable option specifies the pathname of the smapd executable itself. For historical reasons, smapd forks and execs copies of itself to handle delivering each individual message. This entry is mandatory.

sendmail pathname

The sendmail option specifies an alternate pathname for the sendmail executable. smapd assumes the use of sendmail but does not require it. An alternate mail delivery system can replace sendmail, but to do so it needs to be able to accept arguments in the form of:

executable -f fromname recip1 [recip2 …]

The reason for this requirement is the exit code from the mailer is used to determine the status of delivery. Replacements for sendmail should use similar exit codes.

baddir pathname

The baddir option specifies a directory where smapd should move any spooled mail that cannot be delivered normally. This directory must be on the same device as the spool directory because the rename(2) system call is employed. The pathname specified should not contain a trailing forward slash (/).

userid name

The userid option specifies the userid under which smapd should run. The name can be either a name from the password database, or a numeric user-ID. This userid should be the same as the one smap uses when it runs, and should have write permission to the spool directory.

directory pathname

The directory option specifies the spool directory in which smapd should search for files. smapd should have write permission to this directory.

wakeup value

wakeup specifies the number of seconds smapd should sleep between scans of the spool directory. The default is 60 seconds.

Installation

To install smapd configure the executable and directory options in netperm-table and add them to /etc/rc.local. A sample netperm-table configuration for smap and smapd looks like this:

# e-mail wrapper control
smap, smapd:   userid 4
smap, smapd:   directory /mail/inspool
smapd:   executable /usr/local/etc/smapd
smap:    maxrecip 4000
smap:    maxbytes 1048576
smap:    timeout 3600

In this example, both smap and smapd are running with user-id #4 (UUCP) in the spool directory /mail/inspool. Because sendmail is not running in daemon mode, messages that cannot be delivered and are queued must be delivered by periodically invoking sendmail to process the queue. To do this, add something similar to the following line in the crontab file:

0,30 * * * * /usr/lib/sendmail -q < /dev/null 2>&1

tn-gw—telnet Proxy Server

Synopsis

tn-gw [invoked from inetd]


Previous Table of Contents Next