Added a backwards-compatible interface to a fake DNS resolver for use by
[exim.git] / src / OS / os.Configuring
CommitLineData
61ec970d
PH
1$Cambridge: exim/src/OS/os.Configuring,v 1.1 2004/10/06 15:07:39 ph10 Exp $
2
3Configuring Exim for different Operating Systems
4------------------------------------------------
5
6These notes describe the way in which Exim is configured at the C program level
7for different operating systems. The normal configuration options that apply
8independently of the operating system are specified by creating files in the
9Local directory, as described in chapter 4 of the manual.
10
11These notes cover the os.* files in the OS directory, and contain information
12for people who want to port the program to some new OS, or to modify the
13configuration for an existing port. If you are just wanting to compile Exim on
14a system that it already knows about, you do not need to read further unless
15there are problems.
16
17The os.c-<ostype> files
18-----------------------
19
20There may be an os.c-<ostype> file for each operating system, but for many of
21them it is not necessary. No error occurs is there isn't one. There is a
22generic file called os.c which contains code that is common to two or more OS
23for setting a restarting or a non-restarting signal, for computing the load
24average, and for finding all the network interface addresses. A few OS have
25their own individual code for one or more of these. When they do, the code is
26put into an os.c-<ostype> file, which also defines a macro such as
27OS_RESTARTING_SIGNAL (for example) to cut out the common code in the generic
28os.c.
29
30The os.h-<ostype> files
31-----------------------
32
33For each OS that Exim knows about, there is an os.h-<ostype> file, where
34<ostype> is the OS name. The relevant file is included as a C header file for
35all Exim compilation by pointing a symbolic link called os.h at it from the
36build directory. The settings are as follows:
37
38The select() function
39---------------------
40
41There is a difference in the data type for the second argument to the select()
42function in some OS. The macro SELECT_ARG2_TYPE can be used to define the type.
43If it is not defined in os.h, then it is defaulted to fs_set in exim.h.
44
45The dn_expand() function
46------------------------
47
48There is a difference in the data type for the fourth argument to the
49dn_expand() function in some OS. The macro DN_EXPAND_ARG4_TYPE can be used to
50define the type. If it is not defined in os.h, then it is defaulted to char *
51in exim.h.
52
53The h_errno variable
54--------------------
55
56If NEED_H_ERRNO is defined, then a definition of the form
57
58extern int h_errno
59
60is included in the compiled code of Exim.
61
62The strerror() function
63-----------------------
64
65Most systems provide the ANSI standard strerror() function; older systems may
66instead have an errlist[] variable in which to look up error texts. Defining
67STRERROR_FROM_ERRLIST causes Exim to build its own strerror() function that
68mimics the ANSI function by lookup up the error code in errlist.
69
70Truncating files
71----------------
72
73The fcntl() option for truncating the length of a file is called F_FREESP in
74most systems; in some, however, it is called O_TRUNC. Some os.h files define
75F_FREESP to be O_TRUNC for this reason.
76
77Finding local interfaces
78------------------------
79
80The SIOCGIFCONF ioctl for finding local interfaces behaves differently on BSD
81systems. It returns a vector of ifreq blocks containing sockaddr structures
82that can be longer than their sizeof definition, making the returned ifreq
83blocks longer than their sizeof definitions. BSD sockaddrs structures contain
84an sa_len field giving the actual size. To cope with difference, there is a
85macro called HAVE_SA_LEN. If it is defined, code that works on BSD systems is
86used. Otherwise, the objects returned by SIOCGIFCONF are assumed to be of
87length sizeof(struct ifreq).
88
89On some operating systems, the SIOCGIFCONF ioctl returns the IP addresses
90with the list of interfaces, and there is no need to call SIOCGIFADDR for each
91individual address. Mostly, making the second call does no harm, but on Linux
92when there are IP aliases, it causes things to go wrong. This also happens on
93BSDI. Therefore, there is now a macro to cut it out, called
94SIOCGIFCONF_GIVES_ADDR.
95
96Note that, if IPv6 support is configured, Exim cannot find the IPv6 addresses
97on local interfaces by itself. You need to set the local_interfaces option in
98this situation.
99
100Computing load averages
101-----------------------
102
103There are several different ways that load averages are computed. One-off code
104is put in the os.c-<ostype>, but several OS use similar methods, and these
105are coded in the generic os.c, using a number of parameters to make variations
106between OS.
107
108Sometimes the load average is not available to unprivileged callers. If
109LOAD_AVG_NEEDS_ROOT is set, Exim ensures that it is root before trying to
110obtain a load average value.
111
112(1) If HAVE_BSD_GETLOADAVG is defined, Exim uses a simple call to the
113getloadavg() function.
114
115(2) If HAVE_KSTAT is defined, Exim uses the kstat package as found in Solaris 2
116(but nowhere else as yet). It uses some supplementary definitions:
117
118 LOAD_AVG_KSTAT the kstat to use
119 LOAD_AVG_KSTAT_MODULE the module to access
120 LOAD_AVG_KSTAT_SYMBOL the symbol containing the value we want
121 LOAD_AVG_KSTAT_FIELD the field identity
122
123(3) If HAVE_DEV_KMEM is defined, Exim reads load average values from the
124/dev/kmem device. It uses some supplementary definitions:
125
126 LOAD_AVG_TYPE the data type
127 LOAD_AVG_SYMBOL the symbol to look up
128 KERNEL_PATH the name of the kernel
129 FSCALE a scaling factor
130
131Sometimes FSCALE is defined in system headers so need not be defined in the
132os.h-<ostype> file.
133
134Glibc systems and IP options
135----------------------------
136
137The code for inspecting IP options is the same in all OS except for systems
138using glibc (e.g. Linux), which uses a different structure to return data from
139getsockopt(). To handle this, there is a macro called
140
141 GLIBC_IP_OPTIONS
142
143which should be set for Linux (in os.h-Linux) and any other operating system
144that uses glibc.
145
146Options for statvfs()
147---------------------
148
149The following settings apply to the compilation of the Exim monitor as well as
150to the main Exim binary.
151
152#undefine HAVE_STATFS
153
154Exim has options for checking the amount of space in the spool partition
155before accepting a message, and the monitor has the ability to display a
156stripchart of the percentage fullness of a particular disc partition, usually
157/var/spool/mail. The standard way of finding out the data is to call the
158statvfs() function, but some operating systems use statfs() and some may not
159have the ability at all. The Exim code uses STATVFS() for this function and
160this gets defined appropriately. HAVE_STATFS is defined before including the
161os.h file; undefining it suppresses the code for checking a partition in the
162main binary, and for monitoring disc partition in the monitor.
163
164When HAVE_STATFS is defined, the distinction between statvfs() and statfs() is
165made by checking HAVE_SYS_STATVFS_H. If it is defined, then sys/statvfs.h is
166included. Otherwise, STATVFS() is defined as a macro for statfs(), and some
167further includes are done, according to the following definitions:
168
169#define HAVE_SYS_MOUNT_H
170#define HAVE_VFS_H
171
172Each of those definitions causes the inclusion of the corresponding system
173header file in the Exim monitor compilation. For example, the first one causes
174
175#include <sys/mount.h>
176
177to be obeyed. Different systems may require different combinations of these
178headers.
179
180The sys/resource.h header
181-------------------------
182
183One OS does not have the sys/resource.h header. If NO_SYS_RESOURCE_H is defined
184in an os.h-<ostype> file, then the #include for this header is skipped in
185exim.h.
186
187The crypt_h header
188------------------
189
190Some OS require crypt.h to be included to get a prototype for the crypt()
191function. This is needed only when compiling with AUTH support. If CRYPT_H is
192defined, then this header is included.
193
194mmap() support
195--------------
196
197The CDB support includes the option of handling file operations by using
198mmap()/munmap(). This gives a reasonable performance increase which will
199probably scale over multiple processes (since the files are mapped read-only
200shared). The vast majority of modern operating systems will support mmap
201(certainly in the simplified way that it is being used here). For example any
202BSD 4.x derived or POSIX compliant system will support it, as will pretty much
203any system using dynamically shared link libraries.
204
205If the OS is believed to support mmap() then the symbol HAVE_MMAP is defined.
206Not all systems that support mmap will have had their config files updated to
207reflect this. Currently Linux, Sun, BSD and SGI/mips systems have been updated.
208
209*** End ***