
- •Contents
- •Preface to second edition
- •1 Introduction
- •1.2 Applying technology in an environment
- •1.3 The human role in systems
- •1.4 Ethical issues
- •1.7 Common practice and good practice
- •1.8 Bugs and emergent phenomena
- •1.10 Knowledge is a jigsaw puzzle
- •1.11 To the student
- •1.12 Some road-maps
- •2 System components
- •2.2 Handling hardware
- •2.3 Operating systems
- •2.4 Filesystems
- •2.5 Processes and job control
- •2.6 Networks
- •2.7 IPv4 networks
- •2.8 Address space in IPv4
- •2.9 IPv6 networks
- •3 Networked communities
- •3.1 Communities and enterprises
- •3.2 Policy blueprints
- •3.4 User behavior: socio-anthropology
- •3.5 Clients, servers and delegation
- •3.6 Host identities and name services
- •3.8 Local network orientation and analysis
- •4 Host management
- •4.1 Global view, local action
- •4.2 Physical considerations of server room
- •4.3 Computer startup and shutdown
- •4.5 Installing a Unix disk
- •4.6 Installation of the operating system
- •4.7 Software installation
- •4.8 Kernel customization
- •5 User management
- •5.1 Issues
- •5.2 User registration
- •5.3 Account policy
- •5.4 Login environment
- •5.5 User support services
- •5.6 Controlling user resources
- •5.7 Online user services
- •5.9 Ethical conduct of administrators and users
- •5.10 Computer usage policy
- •6 Models of network and system administration
- •6.5 Creating infrastructure
- •6.7 Competition, immunity and convergence
- •6.8 Policy and configuration automation
- •7.2 Methods: controlling causes and symptoms
- •7.4 Declarative languages
- •7.6 Common assumptions: clock synchronization
- •7.7 Human–computer job scheduling
- •7.9 Preventative host maintenance
- •7.10 SNMP tools
- •7.11 Cfengine
- •8 Diagnostics, fault and change management
- •8.1 Fault tolerance and propagation
- •8.2 Networks and small worlds
- •8.3 Causality and dependency
- •8.4 Defining the system
- •8.5 Faults
- •8.6 Cause trees
- •8.7 Probabilistic fault trees
- •8.9 Game-theoretical strategy selection
- •8.10 Monitoring
- •8.12 Principles of quality assurance
- •9 Application-level services
- •9.1 Application-level services
- •9.2 Proxies and agents
- •9.3 Installing a new service
- •9.4 Summoning daemons
- •9.5 Setting up the DNS nameservice
- •9.7 E-mail configuration
- •9.8 OpenLDAP directory service
- •9.10 Samba
- •9.11 The printer service
- •9.12 Java web and enterprise services
- •10 Network-level services
- •10.1 The Internet
- •10.2 A recap of networking concepts
- •10.3 Getting traffic to its destination
- •10.4 Alternative network transport technologies
- •10.5 Alternative network connection technologies
- •10.6 IP routing and forwarding
- •10.7 Multi-Protocol Label Switching (MPLS)
- •10.8 Quality of Service
- •10.9 Competition or cooperation for service?
- •10.10 Service Level Agreements
- •11 Principles of security
- •11.1 Four independent issues
- •11.2 Physical security
- •11.3 Trust relationships
- •11.7 Preventing and minimizing failure modes
- •12 Security implementation
- •12.2 The recovery plan
- •12.3 Data integrity and protection
- •12.5 Analyzing network security
- •12.6 VPNs: secure shell and FreeS/WAN
- •12.7 Role-based security and capabilities
- •12.8 WWW security
- •12.9 IPSec – secure IP
- •12.10 Ordered access control and policy conflicts
- •12.11 IP filtering for firewalls
- •12.12 Firewalls
- •12.13 Intrusion detection and forensics
- •13 Analytical system administration
- •13.1 Science vs technology
- •13.2 Studying complex systems
- •13.3 The purpose of observation
- •13.5 Evaluating a hierarchical system
- •13.6 Deterministic and stochastic behavior
- •13.7 Observational errors
- •13.8 Strategic analyses
- •13.9 Summary
- •14 Summary and outlook
- •14.3 Pervasive computing
- •B.1 Make
- •B.2 Perl
- •Bibliography
- •Index

9.7. E-MAIL CONFIGURATION |
365 |
9.7 E-mail configuration
Configuration of E-mail is one of the most complex issues for the system administrator, because it involves both nagging policy decisions and technical acrobatics. For many system administrators, the phrase Nightmares on ELM2 Street does not conjure up a vision of Freddie Kruger, but of dark nights spent with E-mail configuration. E-mail is used for so many crucial purposes; it is the de-facto form of communication in a network environment [202, 8, 177, 81, 87].
Why should E-mail be so complex? Part of the trouble is that, in the past, there were many different kinds of network protocol and many different ways of connecting up to different hosts. This made it quite a complex issue to relay messages all over the world. Today things are much simpler: most sites use the Internet protocols and some of the technical aspects of mail configuration can be simplified. Some operating systems provide a program which automatically helps set up E-mail for simple host configurations, but these are no substitute for a carefully considered E-mail system.
In this chapter we shall consider only the popular mail transfer agent sendmail. Sendmail changes so often that anything specific written about it is likely to be out of date by the time you read this, so this section will necessarily be of a schematic nature. The source code and documentation for sendmail are available from ref. [275]. No matter whether the majority of local users read mail on a PC or on a Unix workstation, every site requires a mail transfer agent like sendmail in order to handle incoming and outgoing transfers.
9.7.1Models of mail receipt and delivery
E-mail comprises two separate challenges: the delivery of messages and user access to a mailbox. E-mail can be delivered either locally (where the sending host is the same as the destination host) or across a network (where the destination host is different from the sending host). Non-local delivery uses the SMTP (actually ESMTP) mail protocol.
User access to a mailbox uses one of three methods: direct (local) access, POP or IMAP. Regardless of whether local or network delivery is used, E-mail has to end up in a mailbox system. For Unix-like operating systems, there are several actual choices:
•mbox: (or Berkeley format) This can be used with POP or local access methods.
•maildir: (from Qmail) can be used with POP, IMAP or local access.
•Cyrus: part of the Cyrus implementation of POP and IMAP.
•mbx: (from UWash IMAP) is basically an indexed mbox format as in RFC 822.
•MH: (for use with the MH and XMH mailers).
Windows has its own mailbox formats:
• PST: MS Outlook
2ELM is a free mail reader written by an employee of Hewlett Packard which redefined the standard for E-mail interfaces in the 1980s.
366 |
CHAPTER 9. APPLICATION-LEVEL SERVICES |
•DBX: Outlook Express
•SNM: Netscape Messenger or Netscape Collabra
•MBX: Eudora Mail.
The mailbox formats fall into two categories: those, such as the Berkeley format, that put all messages in a single file, one after the other with ‘From’ lines to mark the start of a new message, and those, such as maildir or Cyrus, that keep directories of mail with a new file for each message. In the former case, a bad character in a file can confuse mail readers about where one message ends and the next one starts; in the latter case, the addition or removal of a message must be accompanied by the update of index files or else the mailbox becomes corrupted. All mailbox formats are vulnerable to corruption by ad hoc editing, so users and administrators should be discouraged from attempting this.
As soon as a network is involved in E-mail transmission, there are many choices to be made. Some of the basic choices involve deciding a logistic topology for the E-mail service: should we consolidate mail services to one host, or should we deliver mail to every host independently. The consequences of the latter are that users will have different E-mail on every host they have an account on. Usually, users require and desire only one mailbox per institution.
One way to avoid having different E-mail on every host is to share an mbox filesystem between all hosts, using NFS. The Berkeley mail spool system is kept in one of the directories
/var/spool/mail
/usr/spool/mail
/var/mail
/usr/mail
depending on the flavor of operating system. To do this, we pick a special host which has the physical disk and we force every other host to mount that disk so that users see the same mailbox, independently of which host they happen to be logged onto. This lends itself to a non-distributed solution to E-mail however: if all mail has to end up on one disk, then the host with the disk should get the mail. If independent hosts try to perform local mail delivery to the same NFS-mounted filesystem there can be mailbox corruption due to locking contentions across many hosts. Some sites report that this is not a problem, however it is generally not advisable to use NFS in this way. A centralized solution is preferable. For a discussion of scalable sendmail configurations see ref. [63].
9.7.2Relaying
Another issue which has attracted focus in recent times is whether or not a site should relay mail from other hosts, and if so which hosts. In order to build a flexible local mail solution, we usually need to relay mail between machines within our local domain. However, relaying of E-mail from other sites has become a security and ethical issue in recent times, with the explosion of mail spamming. Hostile senders often attempt to cover their tracks by relaying E-mail via an intermediate
9.7. E-MAIL CONFIGURATION |
367 |
domain. This has led mail exchangers to revise policy on relaying. Whereas mail relaying was allowed by default, it is now generally denied by default. In most cases this is correct and safe behavior; however, some sites, within particularly complex organizations, might find the need to relay E-mail from a limited number of other additional sites.
9.7.3Consolidated and distributed mail solutions
There are two main models for handling electronic mail at a domain. One is that every host receives mail independently. Since users normally have the same password and account on all of the hosts on a network, this is not usually appropriate.
The second approach is to have a mail ‘hub’, or central mail processor. In this model, all incoming mail is diverted to the hub and all outgoing mail is sent via the hub. With this approach, we focus all our effort into optimizing E-mail configuration on the hub, and all other machines have a simple configuration which simply collects or forwards mail on to the hub.
In order for mail to be diverted to a hub, we have to arrange for the mail exchanger data in DNS to point to the hub, for every system, i.e. for every host in DNS we should have an MX record accompanying the A record:
hostname A xxx.yyy.zzx.mmm MX mailhub
Without such an MX record, mail which is addressed to
user@hostname.domain
will be sent directly to hostname. With such a record the mail for hostname is sent to mailhub instead. It can later be forwarded to hostname if desired using a mailertable. This has several advantages: first of all it means that mail configuration can be centralized, spam filtering can be performed even for dumb hosts and aliases can be expanded here without the need for a distributed alias database like NIS. The second advantage concerns security. If all mail is forced to pass through this hub then a secure setup here will help prevent SMTP attacks on weaker hosts, thus this simplifies the security administration of mail also. A further precaution is then to configure the site router to accept SMTP traffic only for the mailhub since it is supposed to go there anyway. That way, if one forgets an MX record in DNS there will be no back-doors for would-be attackers.
9.7.4Compiling and installing sendmail
In this section we shall look only at the mail agent called sendmail. Some alternatives to sendmail also now exist, such as smail, exim and postfix.
This section provides only an outline of the installation procedure for sendmail, which has changed considerably in recent years. Information about sendmail and the latest version can be obtained from ref. [275]. After unpacking the distribution, we need to compile it. Sendmail uses BIND and TCP-wrappers libraries; these
368 |
CHAPTER 9. APPLICATION-LEVEL SERVICES |
should be in place. Consider searching for the latest versions of these libraries on the Internet before compiling. BIND is the resolver library. The official place to get BIND is ref. [31]. This also contains a library lib44bsd.a which might be necessary. The latest version of TCP wrappers may be obtained from ref. [311]. Many of the database-lookup features require the Berkeley db package. This is obtainable from ref. [89].
Using the principle of separation, we build sendmail and keep it in a separate directory, along with its attendant files.
myhost# mkdir -p /usr/local/mail/bin
Then, the simplest installation is found by
vger$ tar zxf sendmail.8.12.9.tar.gz vger$ cd sendmail-8.12.9/
vger$ sh Build Making all in:
/home/mark/sendmail-8.12.9/libsm Configuration: pfx=, os=Linux,...
The script Build selects the operating system type and compiles the program and places it in a directory that has the form:
obj.Linux.2.4.10-4GB.i686
where the string after ‘obj’ represents your kernel version. The built executables are placed here. We can copy these to /usr/local/mail/bin.
Our operating system most likely expects to find the sendmail executable file in either the /usr/lib/ directory, or the /usr/sbin directory on newer systems. We must replace the old executable in these directories by making a link to the new executable. For example:
mv /usr/lib/sendmail /usr/lib/sendmail.old
ln -s /usr/local/mail/bin/sendmail /usr/lib/sendmail
Make sure that the old file is no longer setuid or setgid, in case it contains any security vulnerabilities.
9.7.5Configuring sendmail
To finish the installation, we need to create configuration files for our mail domain. Begin by going back to the sendmail distribution and copying the cf directory to the mail directory, like this:
cp -r sendmail-x.y.z/cf /usr/local/mail
Next make a lib directory.
mkdir /usr/local/mail/lib
9.7. E-MAIL CONFIGURATION |
369 |
To create a sendmail.cf file, we need to create a so-called macro file containing configuration options /usr/local/mail/lib/domain.mc. Here is an example file for domain domain.tld. We should only need to change the domain name and the OS name of the mailhost in the first three lines. Using this file we will be able to build the sendmail configuration more or less automatically. This example is for sendmail x.y.z for a mail hub:
divert(-1) include(‘/local/site/mail/cf/m4/cf.m4’)
VERSIONID(‘$Id: mercury.mc,v 1.1 1997/04/08 08:52:28 mroot Exp mroot $’) OSTYPE(solaris2)dnl
DOMAIN(domain.tld)dnl
MASQUERADE_AS(domain.tld)
MASQUERADE_DOMAIN(sub.domain.tld)
FEATURE(use_cw_file)
FEATURE(use_ct_file) FEATURE(redirect) FEATURE(relay_entire_domain) FEATURE(always_add_domain) FEATURE(allmasquerade) FEATURE(masquerade_envelope)
FEATURE(domaintable, ‘hash -o /local/site/mail/lib/domaintable’) FEATURE(mailertable, ‘hash -o /local/site/mail/lib/mailertable’) FEATURE(access_db, ‘hash -o /local/site/mail/lib/access_db’)
FEATURE(genericstable, ‘hash -o /local/site/mail/lib/genericstable’) FEATURE(virtusertable, ‘hash -o /local/site/mail/lib/virtusertable’)
FEATURE(local_procmail,‘/local/bin/procmail’)
GENERICS_DOMAIN_FILE(/local/site/mail/lib/sendmail.cG)
EXPOSED_USER(root)
define(‘ALIAS_FILE’, /local/site/mail/lib/aliases)dnl define(‘HELP_FILE’, /local/site/mail/lib/sendmail.hf)dnl define(‘STATUS_FILE’, /local/site/mail/etc/sendmail.st)dnl define(‘QUEUE_DIR’, /var/spool/mqueue) define(‘LOCAL_MAILER_CHARSET’, iso-8859-1) define(‘SMTP_MAIL_CHARSET’, iso-8859-1) define(‘SMTP_MAIL_MAX’,‘2000000’) define(‘confMAX_MESSAGE_SIZE’, ‘20000000’) define(‘confHOST_STATUS_DIRECTORY’, ‘.hoststat’) define(‘confPRIVACY_FLAGS’, ‘authwarnings,noexpn,novrfy’) define(‘confME_TOO’, ‘True’) define(‘confMIME_FORMAT_ERRORS’, ‘False’) define(‘confTIME_ZONE’, ‘MET-1METDST’) define(‘confDEF_CHAR_SET’, ‘iso-8859-1’) define(‘confEIGHT_BIT_HANDLING’, ‘m’) define(‘confCW_FILE’, ‘/local/site/mail/lib/sendmail.cw’)
370 |
CHAPTER 9. APPLICATION-LEVEL SERVICES |
define(‘confCT_FILE’, ‘/local/site/mail/lib/sendmail.ct’) define(‘confUSERDB_SPEC’, ‘/local/site/mail/lib/userdb.db’) define(‘LOCAL_SHELL_PATH’,‘/local/site/mail/bin/smrsh’)
MAILER(local)
MAILER(smtp)
Create a makefile in /usr/local/mail/Makefile
MAKEMAP= |
bin/makemap |
SENDMAIL= |
bin/sendmail |
PIDFILE= |
/var/run/sendmail.pid |
MAILTABLE= |
lib/mailertable |
MCFILE= |
lib/domain.mc |
SUBMIT= |
lib/submit.mc |
ALIASES= |
lib/aliases |
ACCESSDB= |
lib/access_db |
CF_DIR= |
cf/ |
all: sendmail.cf $(ALIASES).db $(MAILTABLE).db $(ACCESSDB).db .restart
$(ALIASES).db: $(ALIASES) $(SENDMAIL) -bi
$(ACCESSDB).db: $(ACCESSDB)
$(MAKEMAP) hash $(ACCESSDB) < $(ACCESSDB)
$(MAILTABLE).db: $(MAILTABLE)
$(MAKEMAP) hash $(MAILTABLE) < $(MAILTABLE)
sendmail.cf: $(MCFILE)
m4 -D_CF_DIR_=$(CF_DIR) cf/m4/cf.m4 $(MCFILE) > sendmail.cf
.restart: sendmail.cf lib/sendmail.cw lib/access_db.db lib/mailertable.db kill -1 ‘head -1 $(PIDFILE)‘
touch .restart
Typing make in the /usr/local/mail directory should now result in a configuration file /usr/local/mail/sendmail.cf. Read the next section before doing this.
We will need to create a file lib/sendmail.cw which contains a list of possible machines or domains for which the sendmail program will accept mail. It is, amongst other things, this file which allows us to send mail of the form mark@domain.tld, i.e. to an entire domain, without specifying a particular machine. This file should contain a list of all the valid addresses, like this:
domain.tld
mailhost.domain.tld
www.domain.tld
mercury.domain.tld
dax.domain.tld
borg.domain.tld
worf.domain.tld
9.7. E-MAIL CONFIGURATION |
371 |
daystrom.domain.tld
regula.domain.tld
ferengi.domain.tld
lore.domain.tld
Finally, we need to make the files readable for normal users. There is no harm in giving everyone read access to all the files and directories.
9.7.6Spam and junk mail
Spam or junk mail is E-mail where a message is sent to a large number of recipients. The term ‘spam’ comes from the Monty Python spam song sketch. Spam mail is most often commercial in nature and unsolicited (and unwanted) by the intended recipient. Spam has become a major problem since it is very easy to send E-mail and very hard to pick out what is useful from what is useless. There are two approaches to the filtering of spam, both of which are needed together:
•Site rules for rejecting mail (ACLs)
•Private user-rules for rejecting mail.
The reason why both of these are needed is that what one user wants to reject, another user might be glad to receive. Users prospecting for financial opportunities or collecting the latest ‘artwork’ might live for the messages which most of us get annoyed with.
Sendmail has rules for filtering mail at the site level. These include the ability to deny access to connecting mailers from certain domains. At the time of writing they seem to be only partially successful in practice [143].
At the user level, users of procmail can use junkfilter to create their own rules for rejecting spam. Filters for mail transfer agents are also emerging now. Many of these use Bayesian learning and filtering methods. See ref. [246].
9.7.7Policy decisions
In order to protect our site from E-mail attacks, even ones made in innocence, we might want to restrict mail by other criteria too. For example, multimedia attachments can now allow users to send huge files by E-mail. This is a very inefficient way of sending large amounts of data and it causes problems for mailbox storage space. A possibility is to limit the size of mail messages handled by sendmail so that mail which is too large will be rejected with an error message. For example, the following rules limit E-mail to approximately 20MB. Even with such a large reject size a handful of messages per month are rejected on the basis of this rule.
define(‘SMTP_MAIL_MAX’,‘2000000’) define(‘confMAX_MESSAGE_SIZE’, ‘20000000’)
Again, this must be a policy decision like garbage collection of users’ files. It is never desirable to restrict the personal freedom of users, but it becomes a matter of survival. If one provides an opening, it will be exploited either through ignorance or malice.
372 |
CHAPTER 9. APPLICATION-LEVEL SERVICES |
9.7.8Filtering outgoing mail
An organization might want to prevent certain types of E-mail from being sent. For example, mail generated by CGI-scripts is impossible to trace to a specific user, but is stamped with the domain name of the WWW server which sent it. CGI mail is therefore readily abused, and many institutions would therefore disallow it. If ordinary users are allowed to write their own CGI-scripts, however, this can be a difficult problem to contain. One can discard such mail however, with a local rule of the form:
HReturn-Path: $>local_ret_path
D{SpamMessage}"553 You are a spammer. Go away."
Slocal_ret_path |
|
R<www> |
$#error $@ $: ${SpamMessage} |
This is not terribly sociable since no-one will be informed that the mail was discarded.
The Milter (http://www.milter.org) interface now allows filtering of messages by content, e.g. to perform virus scanning.
9.7.9Mail aliases
One of the first things to locate on a system is the sendmail alias file. This is a file which contains E-mail aliases for users and system services. Common locations for this file are /etc/aliases and /etc/mail/aliases. On some systems, the mail aliases are in the NIS network database.
If this file actually lies in the /etc directory, or some other place amongst the system files, then we should move it to a special area for site-dependent files and make a symbolic link to /etc/aliases instead. Mail aliases are valuable and we want to make sure that nothing happens to them if we reinstall the OS.
The format of the mail aliases file is as follows:
#Alias for mailer daemon; returned messages from our MAILER-DAEMON
#should be routed to our local Postmaster.
postmaster: mark,otheruser
MAILER-DAEMON: postmaster
nobody: /dev/null
#
# alias: list of addresses
#
sysadm:mark@domain.tld,toreo@domain.tld
root:sysadm
#
# Alias for distribution list, members specified elsewhere: